use of com.netflix.config.DynamicURLConfiguration in project archaius by Netflix.
the class DynamicURLConfigurationTest method testNoURLsAvailable.
@Test
public void testNoURLsAvailable() {
try {
DynamicURLConfiguration config = new DynamicURLConfiguration();
assertFalse(config.getKeys().hasNext());
} catch (Throwable e) {
fail("Unexpected exception");
}
}
use of com.netflix.config.DynamicURLConfiguration in project archaius by Netflix.
the class DynamicURLConfigurationTestWithFileURL method testFileURL.
@Test
public void testFileURL() {
DynamicURLConfiguration config = new DynamicURLConfiguration();
Assert.assertEquals(5, config.getInt("com.netflix.config.samples.SampleApp.SampleBean.numSeeds"));
}
use of com.netflix.config.DynamicURLConfiguration in project archaius by Netflix.
the class DynamicURLConfigurationTestWithFileURL method testFileURLWithPropertiesUpdatedDynamically.
@Test
public void testFileURLWithPropertiesUpdatedDynamically() throws IOException, InterruptedException {
File file = File.createTempFile("DynamicURLConfigurationTestWithFileURL", "testFileURLWithPropertiesUpdatedDynamically");
populateFile(file, "test.host=12312,123213", "test.host1=13212");
AbstractConfiguration.setDefaultListDelimiter(',');
DynamicURLConfiguration config = new DynamicURLConfiguration(0, 500, false, file.toURI().toString());
Thread.sleep(1000);
Assert.assertEquals(13212, config.getInt("test.host1"));
Thread.sleep(1000);
populateFile(file, "test.host=12312,123213", "test.host1=13212");
populateFile(file, "test.host=12312,123213", "test.host1=13212");
CopyOnWriteArrayList writeList = new CopyOnWriteArrayList();
writeList.add("12312");
writeList.add("123213");
config.setProperty("sample.domain", "google,yahoo");
Assert.assertEquals(writeList, config.getProperty("test.host"));
}
use of com.netflix.config.DynamicURLConfiguration in project java-chassis by ServiceComb.
the class CseAutoConfiguration method configureArchaius.
protected void configureArchaius(ConfigurableEnvironmentConfiguration envConfig) {
if (INITIALIZED.compareAndSet(false, true)) {
String appName = this.env.getProperty("spring.application.name");
if (appName == null) {
appName = "application";
//log.warn("No spring.application.name found, defaulting to 'application'");
}
System.setProperty(DeploymentContext.ContextKey.appId.getKey(), appName);
ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
// etc...)
if (this.externalConfigurations != null) {
for (AbstractConfiguration externalConfig : this.externalConfigurations) {
config.addConfiguration(externalConfig);
}
}
config.addConfiguration(envConfig, ConfigurableEnvironmentConfiguration.class.getSimpleName());
// below come from ConfigurationManager.createDefaultConfigInstance()
DynamicURLConfiguration defaultURLConfig = new DynamicURLConfiguration();
try {
config.addConfiguration(defaultURLConfig, URL_CONFIG_NAME);
} catch (Throwable ex) {
//log.error("Cannot create config from " + defaultURLConfig, ex);
}
// TODO: sys/env above urls?
if (!Boolean.getBoolean(DISABLE_DEFAULT_SYS_CONFIG)) {
SystemConfiguration sysConfig = new SystemConfiguration();
config.addConfiguration(sysConfig, SYS_CONFIG_NAME);
}
if (!Boolean.getBoolean(DISABLE_DEFAULT_ENV_CONFIG)) {
EnvironmentConfiguration environmentConfiguration = new EnvironmentConfiguration();
config.addConfiguration(environmentConfiguration, ENV_CONFIG_NAME);
}
ConcurrentCompositeConfiguration appOverrideConfig = new ConcurrentCompositeConfiguration();
config.addConfiguration(appOverrideConfig, APPLICATION_PROPERTIES);
config.setContainerConfigurationIndex(config.getIndexOfConfiguration(appOverrideConfig));
addArchaiusConfiguration(config);
}
// else {
// // TODO: reinstall ConfigurationManager
// //log.warn(
// // "Netflix ConfigurationManager has already been installed, unable to re-install");
// }
}
use of com.netflix.config.DynamicURLConfiguration in project archaius by Netflix.
the class DynamicURLConfigurationTestWithFileURL method testChineseCharacters.
@Test
public void testChineseCharacters() {
DynamicURLConfiguration config = new DynamicURLConfiguration();
Assert.assertEquals("\u4E2D\u6587\u6D4B\u8BD5", config.getString("com.netflix.test-subject"));
}
Aggregations