Search in sources :

Example 1 with CuratorFrameworkBuilder

use of com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder 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)

Example 2 with CuratorFrameworkBuilder

use of com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder in project chassis by Kixeye.

the class CuratorFrameworkBuilderTest method zookeeperStarted.

@Test
public void zookeeperStarted() throws Exception {
    testingServer = new TestingServer(SocketUtils.findAvailableTcpPort());
    try (CuratorFramework curatorFramework = new CuratorFrameworkBuilder(true).withZookeeper(testingServer.getConnectString()).build()) {
        Assert.assertEquals(CuratorFrameworkState.STARTED, curatorFramework.getState());
        Assert.assertNull(curatorFramework.checkExists().forPath("/test"));
        curatorFramework.create().forPath("/test");
        Assert.assertNotNull(curatorFramework.checkExists().forPath("/test"));
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFramework(org.apache.curator.framework.CuratorFramework) CuratorFrameworkBuilder(com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder) Test(org.junit.Test)

Aggregations

CuratorFrameworkBuilder (com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 MapConfiguration (org.apache.commons.configuration.MapConfiguration)1 TestingServer (org.apache.curator.test.TestingServer)1