Search in sources :

Example 11 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project chassis by Kixeye.

the class ZookeeperConfigurationWriterTest method basePathExists_noOverwrite.

@Test
public void basePathExists_noOverwrite() throws Exception {
    Assert.assertNull(curatorFramework.checkExists().forPath(base));
    try (CuratorFramework zkCurator = createCuratorFramework()) {
        ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, false);
        writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
        Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
        Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
        try {
            writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
            Assert.fail();
        } catch (BootstrapException e) {
        //expected
        }
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) MapConfiguration(org.apache.commons.configuration.MapConfiguration) DefaultPropertyFilter(com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter) ZookeeperConfigurationWriter(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationWriter) Test(org.junit.Test)

Example 12 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project chassis by Kixeye.

the class CuratorFrameworkBuilderTest method buildWithConfiguration.

@Test
public void buildWithConfiguration() {
    HashMap<String, Object> map = new HashMap<>();
    map.put(BootstrapConfigKeys.ZOOKEEPER_MAX_RETRIES.getPropertyName(), 1);
    MapConfiguration configuration = new MapConfiguration(map);
    try (CuratorFramework curatorFramework = new CuratorFrameworkBuilder(false).withZookeeper("localhost:2181").withConfiguration(configuration).build()) {
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) CuratorFrameworkBuilder(com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder) Test(org.junit.Test)

Aggregations

MapConfiguration (org.apache.commons.configuration.MapConfiguration)12 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 Test (org.junit.Test)5 DefaultPropertyFilter (com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter)4 ZookeeperConfigurationWriter (com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationWriter)4 Properties (java.util.Properties)4 HashMap (java.util.HashMap)3 File (java.io.File)2 ApiClient (com.intel.mtwilson.ApiClient)1 SimpleKeystore (com.intel.mtwilson.util.crypto.SimpleKeystore)1 CuratorFrameworkBuilder (com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder)1 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)1 MetricName (com.yammer.metrics.core.MetricName)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 HttpSession (javax.servlet.http.HttpSession)1