use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest1.
// Test for being possible to send messages in case of failure of registering packet ( return code : 2, lack of parameter)
@Test
public void registerAgentTest1() 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);
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 PinpointServerStateTest method closeByPeerTest.
@Test
public void closeByPeerTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
try {
int bindPort = testPinpointServerAcceptor.bind();
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
if (pinpointServer instanceof PinpointServer) {
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testPinpointClient.disconnect();
assertPinpointServerState(SocketStateCode.CLOSED_BY_CLIENT, (PinpointServer) pinpointServer);
} else {
Assert.fail();
}
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointServerStateTest method closeTest.
@Test
public void closeTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
try {
int bindPort = testPinpointServerAcceptor.bind();
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testPinpointServerAcceptor.close();
assertPinpointServerState(SocketStateCode.CLOSED_BY_SERVER, (PinpointServer) pinpointServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseTest.
@Test
public void unexpectedCloseTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
try {
int bindPort = testPinpointServerAcceptor.bind();
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
((DefaultPinpointServer) pinpointServer).stop(true);
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, (PinpointServer) pinpointServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class StreamChannelManagerTest method streamClosedTest3.
// ServerSocket to Client Stream
// ServerStreamChannel first close.
@Test(expected = PinpointSocketException.class)
public void streamClosedTest3() throws IOException, InterruptedException, StreamException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
SimpleStreamBO bo = new SimpleStreamBO();
ServerListener serverStreamChannelMessageHandler = new ServerListener(bo);
TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE, serverStreamChannelMessageHandler);
testPinpointClient.connect(bindPort);
try {
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
List<PinpointSocket> writableServerList = testPinpointServerAcceptor.getConnectedPinpointSocketList();
Assert.assertEquals(1, writableServerList.size());
PinpointSocket writableServer = writableServerList.get(0);
if (writableServer instanceof PinpointServer) {
RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
ClientStreamChannel clientStreamChannel = ((PinpointServer) writableServer).openStreamAndAwait(new byte[0], clientListener, 3000);
StreamChannel streamChannel = serverStreamChannelMessageHandler.bo.serverStreamChannelList.get(0);
streamChannel.close();
sendRandomBytes(bo);
Thread.sleep(100);
clientStreamChannel.close();
} else {
Assert.fail();
}
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
Aggregations