use of com.netflix.config.FixedDelayPollingScheduler in project archaius by Netflix.
the class BlobStoreBackedConfigurationTest method testPropertyChange.
@Test
public void testPropertyChange() throws Exception {
BlobStoreConfigurationSource source = new BlobStoreConfigurationSource(ctx);
FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 1000, false);
DynamicConfiguration dynamicConfig = new DynamicConfiguration(source, scheduler);
ConfigurationManager.loadPropertiesFromConfiguration(dynamicConfig);
DynamicStringProperty test1 = DynamicPropertyFactory.getInstance().getStringProperty("test1", "");
DynamicStringProperty test2 = DynamicPropertyFactory.getInstance().getStringProperty("test2", "");
DynamicStringProperty test3 = DynamicPropertyFactory.getInstance().getStringProperty("test3", "");
assertEquals("val1", test1.get());
assertEquals("val2", test2.get());
assertEquals("val3", test3.get());
update();
Thread.sleep(1250);
assertEquals("vala", test1.get());
assertEquals("valb", test2.get());
assertEquals("valc", test3.get());
}
use of com.netflix.config.FixedDelayPollingScheduler in project archaius by Netflix.
the class TypesafeConfigurationSourceTest method props.
private static DynamicPropertyFactory props() {
FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, false);
DynamicConfiguration configuration = new DynamicConfiguration(source(), scheduler);
DynamicPropertyFactory.initWithConfigurationSource(configuration);
return DynamicPropertyFactory.getInstance();
}
use of com.netflix.config.FixedDelayPollingScheduler in project archaius by Netflix.
the class JDBCConfigurationSourceTest method testSimpleInMemoryJDBCDynamicPropertySource.
@Test
public void testSimpleInMemoryJDBCDynamicPropertySource() throws Throwable {
final String dbName = "MySiteConfiguration";
DataSource ds = createDataConfigSource(dbName);
try {
JDBCConfigurationSource source = new JDBCConfigurationSource(ds, "select distinct property_key, property_value from MySiteProperties", "property_key", "property_value");
FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, false);
DynamicConfiguration configuration = new DynamicConfiguration(source, scheduler);
DynamicPropertyFactory.initWithConfigurationSource(configuration);
DynamicStringProperty defaultProp = DynamicPropertyFactory.getInstance().getStringProperty("this.prop.does.not.exist.use.default", "default");
assertEquals("default", defaultProp.get());
DynamicStringProperty prop1 = DynamicPropertyFactory.getInstance().getStringProperty("prop1", "default");
assertEquals("value1", prop1.get());
} finally {
//Clean up the data files generated by the embedded DB.
FileUtils.deleteDirectory(new File(".", dbName));
}
}
use of com.netflix.config.FixedDelayPollingScheduler in project java-chassis by ServiceComb.
the class SSLOptionTest method testSSLOptionYaml.
@Test
public void testSSLOptionYaml() {
// configuration from yaml files: default microservice.yaml
DynamicConfiguration configFromYamlFile = new DynamicConfiguration(new YAMLConfigurationSource(), 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());
}
Aggregations