Search in sources :

Example 1 with NeverStartPollingScheduler

use of io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler in project java-chassis by ServiceComb.

the class SSLOptionTest method testSSLOptionYamlOption2.

@Test
public void testSSLOptionYamlOption2() throws Exception {
    System.setProperty("ssl.protocols", "TLSv1.2");
    YAMLConfigurationSource configSource = new YAMLConfigurationSource();
    DynamicConfiguration configFromYamlFile = new DynamicConfiguration(configSource, new NeverStartPollingScheduler());
    // configuration from system properties
    ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
    ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
    finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
    finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile");
    SSLOption option = SSLOption.buildFromYaml("server", finalConfig);
    String protocols = option.getProtocols();
    option.setProtocols(protocols);
    Assert.assertEquals("TLSv1.2", protocols);
    System.getProperties().clear();
}
Also used : DynamicConfiguration(com.netflix.config.DynamicConfiguration) ConcurrentMapConfiguration(com.netflix.config.ConcurrentMapConfiguration) YAMLConfigurationSource(io.servicecomb.config.archaius.sources.YAMLConfigurationSource) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) NeverStartPollingScheduler(io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) Test(org.junit.Test)

Example 2 with NeverStartPollingScheduler

use of io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler in project java-chassis by ServiceComb.

the class SSLOptionTest method testSSLOptionYamlOption.

@Test
public void testSSLOptionYamlOption() throws Exception {
    YAMLConfigurationSource configSource = new YAMLConfigurationSource();
    DynamicConfiguration configFromYamlFile = new DynamicConfiguration(configSource, new NeverStartPollingScheduler());
    // configuration from system properties
    ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
    ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
    finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
    finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile");
    SSLOption option = SSLOption.buildFromYaml("server", finalConfig);
    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) YAMLConfigurationSource(io.servicecomb.config.archaius.sources.YAMLConfigurationSource) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) NeverStartPollingScheduler(io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) Test(org.junit.Test)

Example 3 with NeverStartPollingScheduler

use of io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler in project java-chassis by ServiceComb.

the class TestPropertiesLoader method init.

@BeforeClass
public static void init() {
    ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
    YAMLConfigurationSource yamlConfigurationSource = new YAMLConfigurationSource();
    DynamicConfiguration configFromYamlFile = new DynamicConfiguration(yamlConfigurationSource, new NeverStartPollingScheduler());
    finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile");
    ConfigurationManager.install(finalConfig);
}
Also used : DynamicConfiguration(com.netflix.config.DynamicConfiguration) YAMLConfigurationSource(io.servicecomb.config.archaius.sources.YAMLConfigurationSource) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) NeverStartPollingScheduler(io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler) BeforeClass(org.junit.BeforeClass)

Example 4 with NeverStartPollingScheduler

use of io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler in project java-chassis by ServiceComb.

the class TestYAMLConfigurationSource method testFullOperation.

@Test
public void testFullOperation() {
    // configuration from system properties
    ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
    // configuration from yaml file
    YAMLConfigurationSource configSource = new YAMLConfigurationSource();
    DynamicConfiguration configFromYamlFile = new DynamicConfiguration(configSource, new NeverStartPollingScheduler());
    // create a hierarchy of configuration that makes
    // 1) dynamic configuration source override system properties
    ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
    finalConfig.addConfiguration(configFromYamlFile, "yamlConfig");
    finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
    ConfigurationManager.install(finalConfig);
    DynamicDoubleProperty myprop = DynamicPropertyFactory.getInstance().getDoubleProperty("trace.handler.sampler.percent", 0.1);
    Assert.assertEquals(0.5, myprop.getValue().doubleValue(), 0.5);
    //        DynamicStringListProperty property = new DynamicStringListProperty("trace.handler.tlist", "|", DynamicStringListProperty.DEFAULT_DELIMITER);
    //        List<String> ll = property.get();
    //        for (String s : ll) {
    //            System.out.println(s);
    //        }
    Object o = ConfigUtil.getProperty("zq");
    @SuppressWarnings("unchecked") List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
    Assert.assertEquals(3, listO.size());
}
Also used : ConcurrentMapConfiguration(com.netflix.config.ConcurrentMapConfiguration) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) NeverStartPollingScheduler(io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) DynamicDoubleProperty(com.netflix.config.DynamicDoubleProperty) DynamicConfiguration(com.netflix.config.DynamicConfiguration) List(java.util.List) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)4 DynamicConfiguration (com.netflix.config.DynamicConfiguration)4 NeverStartPollingScheduler (io.servicecomb.config.archaius.scheduler.NeverStartPollingScheduler)4 ConcurrentMapConfiguration (com.netflix.config.ConcurrentMapConfiguration)3 YAMLConfigurationSource (io.servicecomb.config.archaius.sources.YAMLConfigurationSource)3 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)3 Test (org.junit.Test)3 DynamicDoubleProperty (com.netflix.config.DynamicDoubleProperty)1 List (java.util.List)1 Map (java.util.Map)1 BeforeClass (org.junit.BeforeClass)1