use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientStateTest method closeStateTest.
@Test
public void closeStateTest() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
DefaultPinpointClientFactory clientSocketFactory = null;
DefaultPinpointClientHandler handler = null;
try {
clientSocketFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), testServerMessageListenerFactory.create());
handler = connect(clientSocketFactory, bindPort);
assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
handler.close();
assertHandlerState(SocketStateCode.CLOSED_BY_CLIENT, handler);
} finally {
closeHandler(handler);
closeSocketFactory(clientSocketFactory);
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientStateTest method unexpectedCloseByPeerStateTest.
@Test
public void unexpectedCloseByPeerStateTest() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
DefaultPinpointClientFactory clientFactory = null;
DefaultPinpointClientHandler handler = null;
try {
clientFactory = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), testServerMessageListenerFactory.create());
handler = connect(clientFactory, bindPort);
assertHandlerState(SocketStateCode.RUN_DUPLEX, handler);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
((DefaultPinpointServer) pinpointServer).stop(true);
assertHandlerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, handler);
} finally {
closeHandler(handler);
closeSocketFactory(clientFactory);
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointServerSocketTest method testBind.
@Test
public void testBind() throws Exception {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new DiscardServerHandler());
int bindPort = testPinpointServerAcceptor.bind();
Socket socket = new Socket("127.0.0.1", bindPort);
socket.getOutputStream().write(new byte[0]);
socket.getOutputStream().flush();
socket.close();
Thread.sleep(1000);
testPinpointServerAcceptor.close();
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest3.
// when failure of registering and retrying to register, confirm to return same code ( return code : 2
@Test
public void registerAgentTest3() throws Exception {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new HandshakeVerifyMessageListenerFactory());
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
int code = sendAndReceiveRegisterPacket(testRawSocket);
Assert.assertEquals(2, code);
code = sendAndReceiveRegisterPacket(testRawSocket);
Assert.assertEquals(2, code);
sendAndReceiveSimplePacket(testRawSocket);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest4.
// after success of registering, when success message are sent repeatedly.
// test 1) confirm to return success code, 2) confirm to return already success code.
@Test
public void registerAgentTest4() throws Exception {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new HandshakeVerifyMessageListenerFactory());
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendAndReceiveSimplePacket(testRawSocket);
int code = sendAndReceiveRegisterPacket(testRawSocket, PinpointRPCTestUtils.getParams());
Assert.assertEquals(0, code);
sendAndReceiveSimplePacket(testRawSocket);
code = sendAndReceiveRegisterPacket(testRawSocket, PinpointRPCTestUtils.getParams());
Assert.assertEquals(1, code);
sendAndReceiveSimplePacket(testRawSocket);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
}
Aggregations