PropertyBasedPropertiesProvider implements PropertiesProvider { @Override public Properties getProperties(InputStream inputStream) { Properties properties = new Properties(); try { properties.load(inputStream); } catch (IOException | IllegalArgumentException e) { throw new IllegalStateException("Unable to load properties from provided stream", e); } return properties; }  @Override Properties getProperties(InputStream inputStream);  }
@Test void loadsProperties() throws Exception { String path = "org/cfg4j/source/propertiesprovider/PropertyBasedPropertiesProviderTest_loadsProperties.properties"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThat(provider.getProperties(input)).containsExactly(MapEntry.entry("property", "abc")); } }
@Test void throwsOnMalformedFile() throws Exception { String path = "org/cfg4j/source/propertiesprovider/PropertyBasedPropertiesProviderTest_throwsOnMalformedFile.properties"; try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) { assertThatThrownBy(() -> provider.getProperties(input)).isExactlyInstanceOf(IllegalStateException.class); } }