Search in sources :

Example 1 with ZkTestServer

use of com.ctrip.xpipe.zk.ZkTestServer in project x-pipe by ctripcorp.

the class AbstractTest method startZk.

protected ZkTestServer startZk(int zkPort) {
    try {
        logger.info(remarkableMessage("[startZK]{}"), zkPort);
        ZkTestServer zkTestServer = new ZkTestServer(zkPort);
        zkTestServer.initialize();
        zkTestServer.start();
        add(zkTestServer);
        return zkTestServer;
    } catch (Exception e) {
        logger.error("[startZk]", e);
        throw new IllegalStateException("[startZk]" + zkPort, e);
    }
}
Also used : ZkTestServer(com.ctrip.xpipe.zk.ZkTestServer)

Example 2 with ZkTestServer

use of com.ctrip.xpipe.zk.ZkTestServer in project x-pipe by ctripcorp.

the class TestZkClientTest method test.

@Test
public void test() throws Exception {
    ZkTestServer zkTestServer = startRandomZk();
    TestZkClient testZkClient = new TestZkClient();
    testZkClient.setZkAddress(String.format("127.0.0.1:%d", zkTestServer.getZkPort()));
    Assert.assertNull(testZkClient.get());
    testZkClient.initialize();
    testZkClient.start();
    Assert.assertNotNull(testZkClient.get());
    testZkClient.stop();
    Assert.assertNull(testZkClient.get());
}
Also used : ZkTestServer(com.ctrip.xpipe.zk.ZkTestServer) Test(org.junit.Test) AbstractTest(com.ctrip.xpipe.AbstractTest)

Example 3 with ZkTestServer

use of com.ctrip.xpipe.zk.ZkTestServer in project x-pipe by ctripcorp.

the class TestProfile method getZkTestServer.

@Bean
public ZkTestServer getZkTestServer() throws Exception {
    int zkPort = AbstractTest.randomPort();
    ZkTestServer zkTestServer = new ZkTestServer(zkPort);
    zkTestServer.initialize();
    zkTestServer.start();
    return zkTestServer;
}
Also used : ZkTestServer(com.ctrip.xpipe.zk.ZkTestServer) Bean(org.springframework.context.annotation.Bean)

Aggregations

ZkTestServer (com.ctrip.xpipe.zk.ZkTestServer)3 AbstractTest (com.ctrip.xpipe.AbstractTest)1 Test (org.junit.Test)1 Bean (org.springframework.context.annotation.Bean)1