Search in sources :

Example 11 with TestPinpointClient

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();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) Test(org.junit.Test)

Example 12 with TestPinpointClient

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();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) Test(org.junit.Test)

Example 13 with TestPinpointClient

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();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) EchoClientListener(com.navercorp.pinpoint.rpc.util.PinpointRPCTestUtils.EchoClientListener) Test(org.junit.Test)

Example 14 with TestPinpointClient

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();
        }
    }
}
Also used : ZooKeeper(org.apache.zookeeper.ZooKeeper) TestPinpointClient(com.navercorp.pinpoint.test.client.TestPinpointClient) Test(org.junit.Test)

Aggregations

TestPinpointClient (com.navercorp.pinpoint.test.client.TestPinpointClient)14 Test (org.junit.Test)14 TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)13 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)8 RecordedStreamChannelMessageListener (com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener)6 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)2 PinpointSocketException (com.navercorp.pinpoint.rpc.PinpointSocketException)1 EchoClientListener (com.navercorp.pinpoint.rpc.util.PinpointRPCTestUtils.EchoClientListener)1 TestServerMessageListenerFactory (com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory)1 IOException (java.io.IOException)1 ZooKeeper (org.apache.zookeeper.ZooKeeper)1