use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class XpipeNettyClientKeyedObjectPoolTest method testSingleReuse.
@Test
public void testSingleReuse() throws Exception {
Server echoServer = startEchoServer();
Assert.assertEquals(0, echoServer.getTotalConnected());
for (int i = 0; i < testCount; i++) {
InetSocketAddress key = new InetSocketAddress("localhost", echoServer.getPort());
NettyClient client = pool.borrowObject(key);
sleep(10);
Assert.assertEquals(1, echoServer.getTotalConnected());
pool.returnObject(key, client);
}
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class XpipeNettyClientKeyedObjectPoolTest method testDispose.
@Test
public void testDispose() throws Exception {
Server echoServer = startEchoServer();
InetSocketAddress key = new InetSocketAddress("localhost", echoServer.getPort());
Assert.assertEquals(0, echoServer.getConnected());
for (int i = 0; i < maxPerKey; i++) {
pool.borrowObject(key);
int finalI = i;
waitConditionUntilTimeOut(() -> echoServer.getConnected() == finalI + 1);
}
LifecycleHelper.stopIfPossible(pool);
LifecycleHelper.disposeIfPossible(pool);
waitConditionUntilTimeOut(() -> echoServer.getConnected() == 0);
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class SimpleTest method testServer.
@Test
public void testServer() throws Exception {
Server server = startServer(6379, new Function<String, String>() {
@Override
public String apply(String request) {
if (request == null) {
return null;
}
if (request.equalsIgnoreCase("PING")) {
return "+PONG\r\n";
}
if (request.indexOf("SYNC") >= 0) {
return "-ERRORXX\r\n";
}
return "+OK\r\n";
}
});
waitForAnyKey();
}
Aggregations