use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory in project pinpoint by naver.
the class PinpointClientFactoryTest method pingInternal.
@Test
public void pingInternal() throws IOException, InterruptedException {
TestServerMessageListenerFactory testServerMessageListenerFactory = new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX, true);
final TestServerMessageListenerFactory.TestServerMessageListener serverMessageListener = testServerMessageListenerFactory.create();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
Awaitility.await().pollDelay(100, TimeUnit.MILLISECONDS).timeout(3000, TimeUnit.MILLISECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() {
return serverMessageListener.hasReceivedPing();
}
});
PinpointRPCTestUtils.close(client);
} finally {
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory in project pinpoint by naver.
the class PinpointClientFactoryTest method pingAndRequestResponse.
@Test
public void pingAndRequestResponse() throws IOException, InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new TestServerMessageListenerFactory(TestServerMessageListenerFactory.HandshakeType.DUPLEX));
int bindPort = testPinpointServerAcceptor.bind();
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
byte[] randomByte = TestByteUtils.createRandomByte(10);
byte[] response = PinpointRPCTestUtils.request(client, randomByte);
Assert.assertArrayEquals(randomByte, response);
PinpointRPCTestUtils.close(client);
} finally {
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory in project pinpoint by naver.
the class ClientMessageListenerTest method clientMessageListenerTest2.
@Test
public void clientMessageListenerTest2() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener1 = testServerMessageListenerFactory.create();
TestPinpointClient testPinpointClient1 = new TestPinpointClient(echoMessageListener1, PinpointRPCTestUtils.getParams());
TestServerMessageListenerFactory.TestServerMessageListener echoMessageListener2 = testServerMessageListenerFactory.create();
TestPinpointClient testPinpointClient2 = new TestPinpointClient(echoMessageListener2, PinpointRPCTestUtils.getParams());
try {
testPinpointClient1.connect(bindPort);
testPinpointClient2.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(2, 1000);
PinpointSocket writableServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
assertRequestMessage(writableServer, "socket1", null);
PinpointSocket writableServer2 = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(1);
assertRequestMessage(writableServer2, "socket2", null);
echoMessageListener1.awaitAssertExpectedRequestCount(1, 0);
echoMessageListener2.awaitAssertExpectedRequestCount(1, 0);
} finally {
testPinpointClient1.closeAll();
testPinpointClient2.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory 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.server.TestServerMessageListenerFactory 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());
}
Aggregations