Search in sources :

Example 1 with DynamicURLConfiguration

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");
    }
}
Also used : DynamicURLConfiguration(com.netflix.config.DynamicURLConfiguration) Test(org.junit.Test)

Example 2 with DynamicURLConfiguration

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"));
}
Also used : DynamicURLConfiguration(com.netflix.config.DynamicURLConfiguration) Test(org.junit.Test)

Example 3 with DynamicURLConfiguration

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"));
}
Also used : DynamicURLConfiguration(com.netflix.config.DynamicURLConfiguration) File(java.io.File) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 4 with DynamicURLConfiguration

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");
//        }
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) EnvironmentConfiguration(org.apache.commons.configuration.EnvironmentConfiguration) DynamicURLConfiguration(com.netflix.config.DynamicURLConfiguration) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration)

Example 5 with DynamicURLConfiguration

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"));
}
Also used : DynamicURLConfiguration(com.netflix.config.DynamicURLConfiguration) Test(org.junit.Test)

Aggregations

DynamicURLConfiguration (com.netflix.config.DynamicURLConfiguration)6 Test (org.junit.Test)4 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)2 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)2 EnvironmentConfiguration (org.apache.commons.configuration.EnvironmentConfiguration)2 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)2 File (java.io.File)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1