Search in sources :

Example 1 with SettableConfig

use of com.netflix.archaius.api.config.SettableConfig in project iep by Netflix.

the class PlatformServiceModuleTest method runtime.

@Test
public void runtime() {
    Key<SettableConfig> key = Key.get(SettableConfig.class, RuntimeLayer.class);
    Injector injector = Guice.createInjector(testModule);
    SettableConfig c1 = injector.getInstance(key);
    SettableConfig c2 = injector.getInstance(key);
    Assert.assertSame(c1, c2);
}
Also used : DefaultSettableConfig(com.netflix.archaius.config.DefaultSettableConfig) SettableConfig(com.netflix.archaius.api.config.SettableConfig) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 2 with SettableConfig

use of com.netflix.archaius.api.config.SettableConfig in project iep by Netflix.

the class ArchaiusModuleTest method getValueRuntime.

@Test
public void getValueRuntime() {
    Key<SettableConfig> key = Key.get(SettableConfig.class, RuntimeLayer.class);
    Injector injector = Guice.createInjector(testModule);
    SettableConfig runtime = injector.getInstance(key);
    Configuration root = injector.getInstance(IEP_CONFIG);
    Assert.assertEquals("b", root.getString("a"));
    Assert.assertEquals("dynamic", root.getString("c"));
    runtime.setProperty("a", "runtime");
    runtime.setProperty("c", "runtime");
    Assert.assertEquals("runtime", root.getString("a"));
    Assert.assertEquals("runtime", root.getString("c"));
    runtime.clearProperty("a");
    Assert.assertEquals("b", root.getString("a"));
    Assert.assertEquals("runtime", root.getString("c"));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) StaticAbstractConfiguration(com.netflix.archaius.bridge.StaticAbstractConfiguration) DefaultSettableConfig(com.netflix.archaius.config.DefaultSettableConfig) SettableConfig(com.netflix.archaius.api.config.SettableConfig) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 3 with SettableConfig

use of com.netflix.archaius.api.config.SettableConfig in project iep by Netflix.

the class PlatformServiceModuleTest method getValueRuntime.

@Test
public void getValueRuntime() {
    Key<SettableConfig> key = Key.get(SettableConfig.class, RuntimeLayer.class);
    Injector injector = Guice.createInjector(testModule);
    SettableConfig runtime = injector.getInstance(key);
    Config root = injector.getInstance(Config.class);
    Assert.assertEquals("b", root.getString("a"));
    Assert.assertEquals("dynamic", root.getString("c"));
    runtime.setProperty("a", "runtime");
    runtime.setProperty("c", "runtime");
    Assert.assertEquals("runtime", root.getString("a"));
    Assert.assertEquals("runtime", root.getString("c"));
    runtime.clearProperty("a");
    Assert.assertEquals("b", root.getString("a"));
    Assert.assertEquals("runtime", root.getString("c"));
}
Also used : DefaultSettableConfig(com.netflix.archaius.config.DefaultSettableConfig) SettableConfig(com.netflix.archaius.api.config.SettableConfig) Injector(com.google.inject.Injector) Config(com.netflix.archaius.api.Config) DefaultSettableConfig(com.netflix.archaius.config.DefaultSettableConfig) SettableConfig(com.netflix.archaius.api.config.SettableConfig) Test(org.junit.Test)

Aggregations

Injector (com.google.inject.Injector)3 SettableConfig (com.netflix.archaius.api.config.SettableConfig)3 DefaultSettableConfig (com.netflix.archaius.config.DefaultSettableConfig)3 Test (org.junit.Test)3 Config (com.netflix.archaius.api.Config)1 StaticAbstractConfiguration (com.netflix.archaius.bridge.StaticAbstractConfiguration)1 Configuration (org.apache.commons.configuration.Configuration)1