use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class TcpDataSenderTest method connectAndSend.
@Test
public void connectAndSend() {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
PinpointClientFactory clientFactory = createPinpointClientFactory();
TcpDataSender<Object> sender = new TcpDataSender<>(this.getClass().getName(), TestPinpointServerAcceptor.LOCALHOST, bindPort, clientFactory);
try {
sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi"));
sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi"));
serverMessageListener.awaitAssertExpectedSendCount(2, 1000);
} finally {
sender.stop();
if (clientFactory != null) {
clientFactory.release();
}
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ControlPacketServerTest method registerAgentTest2.
// Test for being possible to send messages in case of success of registering packet ( return code : 0)
@Test
public void registerAgentTest2() 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);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class HandshakeTest method handshakeTest1.
// simple test
@Test
public void handshakeTest1() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestPinpointClient testPinpointClient1 = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
TestPinpointClient testPinpointClient2 = new TestPinpointClient(PinpointRPCTestUtils.getParams());
try {
testPinpointClient1.connect(bindPort);
testPinpointClient2.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(2, 3000);
} finally {
testPinpointClient1.closeAll();
testPinpointClient2.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class HandshakeTest method handshakeTest2.
@Test
public void handshakeTest2() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
Map<String, Object> params = PinpointRPCTestUtils.getParams();
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), params);
try {
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1, 3000);
PinpointSocket writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()), testPinpointServerAcceptor.getConnectedPinpointSocketList());
Assert.assertNotNull(writableServer);
writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()) + 1, testPinpointServerAcceptor.getConnectedPinpointSocketList());
Assert.assertNull(writableServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseByPeerTest.
@Test
public void unexpectedCloseByPeerTest() throws IOException, ProtocolException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
try {
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
testRawSocket.connect(bindPort);
testRawSocket.sendHandshakePacket(PinpointRPCTestUtils.getParams());
testPinpointServerAcceptor.assertAwaitClientConnected(1, 1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
if (!(pinpointServer instanceof PinpointServer)) {
testRawSocket.close();
Assert.fail();
}
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testRawSocket.close();
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_CLIENT, (PinpointServer) pinpointServer);
} finally {
testPinpointServerAcceptor.close();
}
}
Aggregations