use of com.netflix.archaius.api.Config in project titus-control-plane by Netflix.
the class Archaius2Ext method newConfiguration.
/**
* Create Archaius based configuration object initialized with default values. Defaults can be overridden
* by providing key/value pairs as parameters.
*/
public static <C> C newConfiguration(Class<C> configType, String... keyValuePairs) {
if (keyValuePairs.length == 0) {
return DEFAULT_CONFIG_PROXY_FACTORY.newProxy(configType);
}
Preconditions.checkArgument(keyValuePairs.length % 2 == 0, "Expected even number of arguments");
Map<String, String> props = new HashMap<>();
int len = keyValuePairs.length / 2;
for (int i = 0; i < len; i++) {
props.put(keyValuePairs[i * 2], keyValuePairs[i * 2 + 1]);
}
Config config = new MapConfig(props);
return newConfiguration(configType, config);
}
use of com.netflix.archaius.api.Config in project spectator by Netflix.
the class NetflixConfigTest method defaultOverrides.
@Test
public void defaultOverrides() {
Config overrides = MapConfig.builder().put("NETFLIX_ENVIRONMENT", "prod").put("substitutions", "${NETFLIX_ENVIRONMENT}-${EC2_OWNER_ID}").build();
Config config = NetflixConfig.createConfig(overrides);
Assertions.assertEquals("prod", config.getString("NETFLIX_ENVIRONMENT"));
Assertions.assertEquals("unknown", config.getString("EC2_OWNER_ID"));
Assertions.assertEquals("us-east-1", config.getString("EC2_REGION"));
Assertions.assertEquals("prod-unknown", config.getString("substitutions"));
}
use of com.netflix.archaius.api.Config in project spectator by Netflix.
the class NetflixConfigTest method defaultEnvVarsAreSet.
@Test
public void defaultEnvVarsAreSet() {
Config config = NetflixConfig.loadPropFiles();
Assertions.assertEquals("test", config.getString("NETFLIX_ENVIRONMENT"));
Assertions.assertEquals("unknown", config.getString("EC2_OWNER_ID"));
Assertions.assertEquals("us-east-1", config.getString("EC2_REGION"));
}
use of com.netflix.archaius.api.Config in project iep by Netflix.
the class PlatformServiceModuleTest method getValues.
@Test
public void getValues() {
Config cfg = Guice.createInjector(testModule).getInstance(Config.class);
Assert.assertEquals("b", cfg.getString("a"));
Assert.assertEquals("dynamic", cfg.getString("c"));
}
use of com.netflix.archaius.api.Config 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"));
}
Aggregations