use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor 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.TestPinpointServerAcceptor 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.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientFactoryTest method connect.
@Test
public void connect() throws IOException, InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor();
int bindPort = testPinpointServerAcceptor.bind();
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
PinpointRPCTestUtils.close(client);
} finally {
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class PinpointClientFactoryTest method ping.
@Test
public void ping() throws IOException, InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor();
int bindPort = testPinpointServerAcceptor.bind();
try {
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
client.sendPing();
PinpointRPCTestUtils.close(client);
} finally {
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor in project pinpoint by naver.
the class ReconnectTest method serverFirstClose.
@Test
public void serverFirstClose() throws IOException, InterruptedException {
// when abnormal case in which server has been closed first, confirm that a socket should be closed properly.
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor();
int bindPort = testPinpointServerAcceptor.bind();
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
byte[] randomByte = TestByteUtils.createRandomByte(10);
Future<ResponseMessage> response = client.request(randomByte);
response.await();
try {
response.getResult();
} catch (Exception e) {
logger.debug("timeout.", e);
}
// close server by force
testPinpointServerAcceptor.close();
assertClientDisconnected(client);
PinpointRPCTestUtils.close(client);
}
Aggregations