use of com.netflix.config.DynamicConfiguration in project servicecomb-java-chassis by apache.
the class TestYAMLConfigurationSource method testFullOperation.
@Test
public void testFullOperation() {
// configuration from system properties
ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
// configuration from yaml file
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
DynamicConfiguration configFromYamlFile = new DynamicConfiguration(new MicroserviceConfigurationSource(loader.getConfigModels()), new NeverStartPollingScheduler());
// create a hierarchy of configuration that makes
// 1) dynamic configuration source override system properties
ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
finalConfig.addConfiguration(configFromYamlFile, "yamlConfig");
finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
Assertions.assertEquals(0.5, finalConfig.getDouble("trace.handler.sampler.percent"), 0.5);
Object o = finalConfig.getProperty("zq");
@SuppressWarnings("unchecked") List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
Assertions.assertEquals(3, listO.size());
}
use of com.netflix.config.DynamicConfiguration in project servicecomb-java-chassis by apache.
the class TestAbstractPropertiesLoader method testExtendedClassCompatible.
@Test
public void testExtendedClassCompatible() {
Configuration configuration = new DynamicConfiguration();
configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_EXTENDED_CLASS, "invalidClass");
AbstractPropertiesLoader loader = MicroservicePropertiesLoader.INSTANCE;
try {
loader.loadProperties(configuration);
Assertions.fail("Must throw exception");
} catch (Error e) {
Assertions.assertEquals(ClassNotFoundException.class, e.getCause().getClass());
Assertions.assertEquals("invalidClass", e.getCause().getMessage());
}
}
Aggregations