PropertiesConfigLoader implements ConfigLoader { @Override public Config getConfig() { try { InputStream in = new FileInputStream(path); Properties props = new Properties(); props.load(in); in.close(); LOG.debug("got config {} from path {}", props, path); Map<String, String> config = new HashMap<>(props.size()); props.forEach((key, value) -> config.put(key.toString(), value.toString())); return new MapConfig(config); } catch (IOException e) { throw new SamzaException("Failed to read from " + path); } } PropertiesConfigLoader(String path); @Override Config getConfig();  }
@Test public void testCanReadPropertiesConfigFiles() { ConfigLoader loader = new PropertiesConfigLoaderFactory().getLoader( new MapConfig(Collections.singletonMap("path", getClass().getResource("/test.properties").getPath()))); Config config = loader.getConfig(); assertEquals("bar", config.get("foo")); }
@Test(expected = SamzaException.class) public void testCanNotReadWithoutPath() { ConfigLoader loader = new PropertiesConfigLoaderFactory().getLoader(new MapConfig()); loader.getConfig(); }