use of com.navercorp.pinpoint.test.client.TestPinpointClient in project pinpoint by naver.
the class HandshakeTest method handshakeTest2.
@Test
public void handshakeTest2() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
Map<String, Object> params = PinpointRPCTestUtils.getParams();
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), params);
try {
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1, 3000);
PinpointSocket writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()), testPinpointServerAcceptor.getConnectedPinpointSocketList());
Assert.assertNotNull(writableServer);
writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()) + 1, testPinpointServerAcceptor.getConnectedPinpointSocketList());
Assert.assertNull(writableServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestPinpointClient in project pinpoint by naver.
the class StreamChannelManagerTest method streamSuccessTest2.
// Client to Server Stream
@Test
public void streamSuccessTest2() throws IOException, InterruptedException, StreamException {
SimpleStreamBO bo = new SimpleStreamBO();
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory, new ServerListener(bo));
int bindPort = testPinpointServerAcceptor.bind();
TestPinpointClient testPinpointClient = new TestPinpointClient();
try {
testPinpointClient.connect(bindPort);
RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
ClientStreamChannel clientStreamChannel = testPinpointClient.openStream(new byte[0], clientListener);
RecordedStreamChannelMessageListener clientListener2 = new RecordedStreamChannelMessageListener(8);
ClientStreamChannel clientStreamChannel2 = testPinpointClient.openStream(new byte[0], clientListener2);
int sendCount = 4;
for (int i = 0; i < sendCount; i++) {
sendRandomBytes(bo);
}
clientListener.getLatch().await();
Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
clientStreamChannel.close();
sendCount = 4;
for (int i = 0; i < sendCount; i++) {
sendRandomBytes(bo);
}
clientListener2.getLatch().await();
Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
Assert.assertEquals(8, clientListener2.getReceivedMessage().size());
clientStreamChannel2.close();
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestPinpointClient in project pinpoint by naver.
the class ClientMessageListenerTest method clientMessageListenerTest1.
@Test
public void clientMessageListenerTest1() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
EchoClientListener echoMessageListener = new EchoClientListener();
TestPinpointClient testPinpointClient = new TestPinpointClient(echoMessageListener, PinpointRPCTestUtils.getParams());
try {
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1, 1000);
PinpointSocket writableServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
assertSendMessage(writableServer, "simple", echoMessageListener);
assertRequestMessage(writableServer, "request", echoMessageListener);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.test.client.TestPinpointClient in project pinpoint by naver.
the class ClusterTest method clusterTest3.
@Test
public void clusterTest3() throws Exception {
ZooKeeper zookeeper = null;
TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE);
try {
zookeeper = new ZooKeeper(zookeeperAddress, 5000, null);
awaitZookeeperConnected(zookeeper);
Assert.assertEquals(0, clusterConnectionManager.getClusterList().size());
testPinpointClient.connect(DEFAULT_IP, acceptorPort);
awaitPinpointClientConnected(clusterConnectionManager);
Assert.assertEquals(1, clusterConnectionManager.getClusterList().size());
} finally {
testPinpointClient.closeAll();
if (zookeeper != null) {
zookeeper.close();
}
}
}
Aggregations