use of com.navercorp.pinpoint.test.client.TestRawSocket in project pinpoint by naver.
the class HealthCheckTest method stateSyncFailTest.
@Test
public void stateSyncFailTest() throws Exception {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
boolean isSuccess = false;
TestRawSocket testRawSocket = new TestRawSocket();
try {
testRawSocket.connect(bindPort);
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
isSuccess = true;
sendPingAndReceivePongPacket(testRawSocket, new PingPayloadPacket(1, (byte) 1, (byte) 1));
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(isSuccess);
} 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 legacyHealthCheckTest2.
@Test
public void legacyHealthCheckTest2() 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 PingPacket(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 registerAgentFailTest.
@Test
public void registerAgentFailTest() throws Exception {
ThrowExceptionEventHandler eventHandler = new ThrowExceptionEventHandler();
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.assertTrue(eventHandler.getErrorCount() > 0);
} finally {
testRawSocket.close();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
Aggregations