Search in sources :

Example 21 with DynamicConfiguration

use of com.netflix.config.DynamicConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestPropertiesLoader method testExtendedClassCompatible.

@Test
public void testExtendedClassCompatible() {
    Configuration configuration = new DynamicConfiguration();
    configuration.setProperty(CONFIG_SERVICE_DESCRIPTION_KEY + AbstractPropertiesLoader.EXTENDED_CLASS, "invalidClass");
    AbstractPropertiesLoader loader = MicroservicePropertiesLoader.INSTANCE;
    try {
        loader.loadProperties(configuration);
        Assert.fail("Must throw exception");
    } catch (Error e) {
        Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass());
        Assert.assertEquals("invalidClass", e.getCause().getMessage());
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) DynamicConfiguration(com.netflix.config.DynamicConfiguration) DynamicConfiguration(com.netflix.config.DynamicConfiguration) Test(org.junit.Test)

Example 22 with DynamicConfiguration

use of com.netflix.config.DynamicConfiguration in project ff4j by ff4j.

the class PropertyStoreArchaiusPolledSourceTest method initArchauis.

@BeforeClass
public static void initArchauis() throws InterruptedException {
    // Sample FF4J Store
    PropertyStore ff4jStore = new InMemoryPropertyStore("ff4j-properties.xml");
    // FF4Store as polling Source for Archiaus
    PolledConfigurationSource ff4jSource = new FF4jPolledConfigurationSource(ff4jStore);
    // Working Thread (polling from ff4j => Archaius)
    AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 1000, true);
    // Define configuration with polling and source
    configuration = new DynamicConfiguration(ff4jSource, scheduler);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) DynamicConfiguration(com.netflix.config.DynamicConfiguration) AbstractPollingScheduler(com.netflix.config.AbstractPollingScheduler) FixedDelayPollingScheduler(com.netflix.config.FixedDelayPollingScheduler) PolledConfigurationSource(com.netflix.config.PolledConfigurationSource) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) BeforeClass(org.junit.BeforeClass)

Example 23 with DynamicConfiguration

use of com.netflix.config.DynamicConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestConfigUtil method testConvertEnvVariable.

@Test
public void testConvertEnvVariable() {
    String someProperty = "cse_service_registry_address";
    AbstractConfiguration config = new DynamicConfiguration();
    config.addProperty(someProperty, "testing");
    AbstractConfiguration result = ConfigUtil.convertEnvVariable(config);
    assertThat(result.getString("cse.service.registry.address"), equalTo("testing"));
    assertThat(result.getString("cse_service_registry_address"), equalTo("testing"));
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) DynamicConfiguration(com.netflix.config.DynamicConfiguration) Test(org.junit.Test)

Example 24 with DynamicConfiguration

use of com.netflix.config.DynamicConfiguration in project incubator-servicecomb-java-chassis by apache.

the class SSLOptionTest method testSSLOptionYaml.

@Test
public void testSSLOptionYaml() {
    // configuration from yaml files: default microservice.yaml
    DynamicConfiguration configFromYamlFile = new DynamicConfiguration(yamlConfigSource(), new FixedDelayPollingScheduler());
    // configuration from system properties
    ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
    // create a hierarchy of configuration that makes
    // 1) dynamic configuration source override system properties
    ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
    finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
    finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile");
    ConfigurationManager.install(finalConfig);
    SSLOption option = SSLOption.buildFromYaml("server");
    String protocols = option.getProtocols();
    option.setProtocols(protocols);
    Assert.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols);
    String ciphers = option.getCiphers();
    option.setCiphers(ciphers);
    Assert.assertEquals("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SH" + "A,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA", ciphers);
    boolean authPeer = option.isAuthPeer();
    option.setAuthPeer(authPeer);
    Assert.assertEquals(true, authPeer);
    boolean checkCNHost = option.isCheckCNHost();
    option.setCheckCNHost(checkCNHost);
    Assert.assertEquals(true, checkCNHost);
    boolean checkCNWhite = option.isCheckCNWhite();
    option.setCheckCNWhite(checkCNWhite);
    Assert.assertEquals(true, checkCNWhite);
    String checkCNWhiteFile = option.getCheckCNWhiteFile();
    option.setCheckCNWhiteFile(checkCNWhiteFile);
    Assert.assertEquals("white.list", checkCNWhiteFile);
    boolean allowRenegociate = option.isAllowRenegociate();
    option.setAllowRenegociate(allowRenegociate);
    Assert.assertEquals(false, allowRenegociate);
    String storePath = option.getStorePath();
    option.setStorePath(storePath);
    Assert.assertEquals("internal", storePath);
    String trustStore = option.getTrustStore();
    option.setTrustStore(trustStore);
    Assert.assertEquals("trust.jks", trustStore);
    String trustStoreType = option.getTrustStoreType();
    option.setTrustStoreType(trustStoreType);
    Assert.assertEquals("JKS", trustStoreType);
    String trustStoreValue = option.getTrustStoreValue();
    option.setTrustStoreValue(trustStoreValue);
    Assert.assertEquals("Changeme_123", trustStoreValue);
    String keyStore = option.getKeyStore();
    option.setKeyStore(keyStore);
    Assert.assertEquals("server.p12", keyStore);
    String keyStoreType = option.getKeyStoreType();
    option.setKeyStoreType(keyStoreType);
    Assert.assertEquals("PKCS12", keyStoreType);
    String keyStoreValue = option.getKeyStoreValue();
    option.setKeyStoreValue(keyStoreValue);
    Assert.assertEquals("Changeme_123", keyStoreValue);
    String crl = option.getCrl();
    option.setCrl(crl);
    Assert.assertEquals("revoke.crl", crl);
    option.setSslCustomClass("123");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    Assert.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray());
}
Also used : DynamicConfiguration(com.netflix.config.DynamicConfiguration) ConcurrentMapConfiguration(com.netflix.config.ConcurrentMapConfiguration) FixedDelayPollingScheduler(com.netflix.config.FixedDelayPollingScheduler) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) Test(org.junit.Test)

Example 25 with DynamicConfiguration

use of com.netflix.config.DynamicConfiguration in project servicecomb-java-chassis by apache.

the class TestConfigUtil method duplicateServiceCombConfigToCseListValue.

@Test
public void duplicateServiceCombConfigToCseListValue() {
    List<String> list = Arrays.asList("a", "b");
    AbstractConfiguration config = new DynamicConfiguration();
    config.addProperty("cse.list", list);
    Deencapsulation.invoke(ConfigUtil.class, "duplicateCseConfigToServicecomb", config);
    Object result = config.getProperty("servicecomb.list");
    assertThat(result, instanceOf(List.class));
    assertThat(result, equalTo(list));
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) DynamicConfiguration(com.netflix.config.DynamicConfiguration) List(java.util.List) Test(org.junit.Test)

Aggregations

DynamicConfiguration (com.netflix.config.DynamicConfiguration)27 Test (org.junit.Test)22 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)12 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)11 ConcurrentMapConfiguration (com.netflix.config.ConcurrentMapConfiguration)10 FixedDelayPollingScheduler (com.netflix.config.FixedDelayPollingScheduler)9 List (java.util.List)7 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)6 NeverStartPollingScheduler (io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler)4 YAMLConfigurationSource (io.servicecomb.config.archaius.sources.YAMLConfigurationSource)4 Map (java.util.Map)4 Configuration (org.apache.commons.configuration.Configuration)4 NeverStartPollingScheduler (org.apache.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler)3 BeforeClass (org.junit.BeforeClass)3 AbstractPollingScheduler (com.netflix.config.AbstractPollingScheduler)2 DynamicStringProperty (com.netflix.config.DynamicStringProperty)2 PolledConfigurationSource (com.netflix.config.PolledConfigurationSource)2 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)2 PropertyStore (org.ff4j.property.store.PropertyStore)2 DynamicDoubleProperty (com.netflix.config.DynamicDoubleProperty)1