use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class AbstractTest method startServer.
protected Server startServer(int serverPort, IoActionFactory ioActionFactory) throws Exception {
Server server = new Server(serverPort, ioActionFactory);
server.initialize();
server.start();
add(server);
return server;
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class StreamTest method testSendBuff.
@Test
public void testSendBuff() throws Exception {
Server server = startEchoServer();
@SuppressWarnings("resource") Socket socket = new Socket();
socket.connect(new InetSocketAddress("localhost", server.getPort()));
System.out.println(socket.getSendBufferSize());
System.out.println(socket.getReceiveBufferSize());
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class TcpPortCheckTest method testCheck.
@Test
public void testCheck() throws Exception {
int port = randomPort();
Assert.assertFalse(new TcpPortCheck("localhost", port).checkOpen());
Server server = startEchoServer(port);
Assert.assertTrue(new TcpPortCheck("localhost", port).checkOpen());
sleep(100);
Assert.assertEquals(0, server.getConnected());
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class RoleCommandTest method testMaster.
@Test
public void testMaster() throws Exception {
Server master = startServer("*3\r\n" + "$6\r\nmaster\r\n" + ":43\r\n" + "*3\r\n" + "$9\r\n127.0.0.1\r\n" + "$4\r\n6479\r\n" + "$1\r\n0\r\n");
RoleCommand roleCommand = new RoleCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(localhostInetAddress(master.getPort())), 2000, false, scheduled);
Role role = roleCommand.execute().get();
Assert.assertEquals(SERVER_ROLE.MASTER, role.getServerRole());
}
use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.
the class RoleCommandTest method testSlave.
@Test
public void testSlave() throws Exception {
for (MASTER_STATE masterState : MASTER_STATE.values()) {
Server slave = startServer("*5\r\n" + "$5\r\nslave\r\n" + "$9\r\nlocalhost\r\n" + ":6379\r\n" + "$" + masterState.getDesc().length() + "\r\n" + masterState.getDesc() + "\r\n" + ":477\r\n");
RoleCommand roleCommand = new RoleCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(localhostInetAddress(slave.getPort())), 2000, false, scheduled);
SlaveRole role = (SlaveRole) roleCommand.execute().get();
Assert.assertEquals(SERVER_ROLE.SLAVE, role.getServerRole());
Assert.assertEquals("localhost", role.getMasterHost());
Assert.assertEquals(6379, role.getMasterPort());
Assert.assertEquals(masterState, role.getMasterState());
Assert.assertEquals(477, role.getMasterOffset());
}
}
Aggregations