use of org.apache.samza.config.ConfigLoader in project samza by apache.
the class TestPropertiesConfigLoader method testCanReadPropertiesConfigFiles.
@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"));
}
use of org.apache.samza.config.ConfigLoader in project samza by apache.
the class ConfigUtil method loadConfig.
/**
* Load full job config with {@link ConfigLoaderFactory} when present.
*
* @param original config
* @return full job config
*/
public static Config loadConfig(Config original) {
JobConfig jobConfig = new JobConfig(original);
if (!jobConfig.getConfigLoaderFactory().isPresent()) {
throw new ConfigException("Missing key " + JobConfig.CONFIG_LOADER_FACTORY + ".");
}
ConfigLoaderFactory factory = ReflectionUtil.getObj(jobConfig.getConfigLoaderFactory().get(), ConfigLoaderFactory.class);
ConfigLoader loader = factory.getLoader(original.subset(ConfigLoaderFactory.CONFIG_LOADER_PROPERTIES_PREFIX));
// overrides config loaded with original config, which may contain overridden values.
return rewriteConfig(override(loader.getConfig(), original));
}
use of org.apache.samza.config.ConfigLoader in project samza by apache.
the class TestPropertiesConfigLoader method testCanNotReadWithoutPath.
@Test(expected = SamzaException.class)
public void testCanNotReadWithoutPath() {
ConfigLoader loader = new PropertiesConfigLoaderFactory().getLoader(new MapConfig());
loader.getConfig();
}
Aggregations