Search in sources :

Example 11 with TestServerMessageListenerFactory

use of com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory in project pinpoint by naver.

the class PinpointClientFactoryTest method requestAndResponse.

@Test
public void requestAndResponse() 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(20);
        byte[] response = PinpointRPCTestUtils.request(client, randomByte);
        Assert.assertArrayEquals(randomByte, response);
        PinpointRPCTestUtils.close(client);
    } finally {
        testPinpointServerAcceptor.close();
    }
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) TestServerMessageListenerFactory(com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory) Test(org.junit.Test)

Aggregations

TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)11 TestServerMessageListenerFactory (com.navercorp.pinpoint.test.server.TestServerMessageListenerFactory)11 Test (org.junit.Test)11 TestRawSocket (com.navercorp.pinpoint.test.client.TestRawSocket)6 ProtocolException (com.navercorp.pinpoint.rpc.control.ProtocolException)3 PingPayloadPacket (com.navercorp.pinpoint.rpc.packet.PingPayloadPacket)3 IOException (java.io.IOException)3 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)1 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)1 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)1 PingPacket (com.navercorp.pinpoint.rpc.packet.PingPacket)1 PingSimplePacket (com.navercorp.pinpoint.rpc.packet.PingSimplePacket)1 TestPinpointClient (com.navercorp.pinpoint.test.client.TestPinpointClient)1 TApiMetaData (com.navercorp.pinpoint.thrift.dto.TApiMetaData)1 Ignore (org.junit.Ignore)1