use of com.navercorp.pinpoint.rpc.TestAwaitTaskUtils in project pinpoint by naver.
the class ClientMessageListenerTest method assertAvaiableWritableSocket.
private void assertAvaiableWritableSocket(final PinpointServerAcceptor serverAcceptor, final int expectedWritableSocketSize) {
boolean pass = awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return serverAcceptor.getWritableSocketList().size() == expectedWritableSocketSize;
}
});
Assert.assertTrue(pass);
}
use of com.navercorp.pinpoint.rpc.TestAwaitTaskUtils in project pinpoint by naver.
the class HandshakeTest method handshakeTest2.
@Test
public void handshakeTest2() throws InterruptedException {
final PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
Map<String, Object> params = PinpointRPCTestUtils.getParams();
PinpointClientFactory clientFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
try {
PinpointClient client = clientFactory1.connect("127.0.0.1", bindPort);
awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
return writableServerList.size() == 1;
}
});
PinpointSocket writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()), serverAcceptor.getWritableSocketList());
Assert.assertNotNull(writableServer);
writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()) + 1, serverAcceptor.getWritableSocketList());
Assert.assertNull(writableServer);
PinpointRPCTestUtils.close(client);
} finally {
clientFactory1.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.TestAwaitTaskUtils in project pinpoint by naver.
the class HandshakeTest method handshakeTest1.
// simple test
@Test
public void handshakeTest1() throws InterruptedException {
final PinpointServerAcceptor serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, SimpleServerMessageListener.DUPLEX_INSTANCE);
PinpointClientFactory clientFactory1 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), PinpointRPCTestUtils.createEchoClientListener());
PinpointClientFactory clientFactory2 = PinpointRPCTestUtils.createClientFactory(PinpointRPCTestUtils.getParams(), null);
try {
PinpointClient client = clientFactory1.connect("127.0.0.1", bindPort);
PinpointClient client2 = clientFactory2.connect("127.0.0.1", bindPort);
awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
return writableServerList.size() == 2;
}
});
List<PinpointSocket> writableServerList = serverAcceptor.getWritableSocketList();
if (writableServerList.size() != 2) {
Assert.fail();
}
PinpointRPCTestUtils.close(client, client2);
} finally {
clientFactory1.release();
clientFactory2.release();
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.TestAwaitTaskUtils in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseByPeerTest.
@Test
public void unexpectedCloseByPeerTest() throws InterruptedException, IOException, ProtocolException {
PinpointServerAcceptor serverAcceptor = null;
try {
serverAcceptor = PinpointRPCTestUtils.createPinpointServerFactory(bindPort, PinpointRPCTestUtils.createEchoServerListener());
Socket socket = new Socket("127.0.0.1", bindPort);
socket.getOutputStream().write(createHandshakePayload(PinpointRPCTestUtils.getParams()));
socket.getOutputStream().flush();
final PinpointServerAcceptor ImmutableServerAcceptor = serverAcceptor;
awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return ImmutableServerAcceptor.getWritableSocketList().size() == 1;
}
});
List<PinpointSocket> pinpointServerList = serverAcceptor.getWritableSocketList();
PinpointSocket pinpointServer = pinpointServerList.get(0);
if (!(pinpointServer instanceof PinpointServer)) {
socket.close();
Assert.fail();
}
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
socket.close();
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_CLIENT, (PinpointServer) pinpointServer);
} finally {
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of com.navercorp.pinpoint.rpc.TestAwaitTaskUtils in project pinpoint by naver.
the class PinpointServerStateTest method assertPinpointServerState.
private void assertPinpointServerState(final SocketStateCode stateCode, final PinpointServer pinpointServer) {
boolean passed = awaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return pinpointServer.getCurrentStateCode() == stateCode;
}
});
Assert.assertTrue(passed);
}
Aggregations