use of com.netflix.config.ConcurrentCompositeConfiguration in project java-chassis by ServiceComb.
the class TestYAMLConfigurationSource method testFullOperation.
@Test
public void testFullOperation() {
// configuration from system properties
ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
// configuration from yaml file
YAMLConfigurationSource configSource = new YAMLConfigurationSource();
DynamicConfiguration configFromYamlFile = new DynamicConfiguration(configSource, 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");
ConfigurationManager.install(finalConfig);
DynamicDoubleProperty myprop = DynamicPropertyFactory.getInstance().getDoubleProperty("trace.handler.sampler.percent", 0.1);
Assert.assertEquals(0.5, myprop.getValue().doubleValue(), 0.5);
// DynamicStringListProperty property = new DynamicStringListProperty("trace.handler.tlist", "|", DynamicStringListProperty.DEFAULT_DELIMITER);
// List<String> ll = property.get();
// for (String s : ll) {
// System.out.println(s);
// }
Object o = ConfigUtil.getProperty("zq");
@SuppressWarnings("unchecked") List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
Assert.assertEquals(3, listO.size());
}
Aggregations