use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class HealthCheckTest method legacyHealthCheckTest1.
@Test
public void legacyHealthCheckTest1() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendPingAndReceivePongPacket(testRawSocket, PingPacket.PING_PACKET);
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class HealthCheckTest method healthCheckSimplePingTest.
@Test
public void healthCheckSimplePingTest() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendPingAndReceivePongPacket(testRawSocket, new PingSimplePacket());
Assert.fail();
} catch (Exception e) {
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertFalse(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class HealthCheckTest method healthCheckTest.
@Test
public void healthCheckTest() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
// RUN_WITHOUT_HANDSHAKE
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 10));
} finally {
testRawSocket.close();
testPinpointServerAcceptor.close();
}
Assert.assertTrue(serverMessageListener.hasReceivedPing());
}
use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class EventHandlerTest method registerAgentSuccessTest.
// Test for being possible to send messages in case of failure of registering packet ( return code : 2, lack of parameter)
@Test
public void registerAgentSuccessTest() throws Exception {
EventHandler eventHandler = new EventHandler();
PinpointServerAcceptor serverAcceptor = new PinpointServerAcceptor();
serverAcceptor.addStateChangeEventHandler(eventHandler);
serverAcceptor.setMessageListenerFactory(testServerMessageListenerFactory);
serverAcceptor.bind("127.0.0.1", bindPort);
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendAndReceiveSimplePacket(testRawSocket);
Assert.assertEquals(eventHandler.getCode(), SocketStateCode.RUN_WITHOUT_HANDSHAKE);
int code = sendAndReceiveRegisterPacket(testRawSocket, PinpointRPCTestUtils.getParams());
Assert.assertEquals(eventHandler.getCode(), SocketStateCode.RUN_DUPLEX);
sendAndReceiveSimplePacket(testRawSocket);
} finally {
testRawSocket.close();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.test.client.TestRawSocket 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();
}
}
Aggregations