Search in sources :

Example 6 with RecordedStreamChannelMessageListener

use of com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener in project pinpoint by naver.

the class StreamChannelManagerTest method streamClosedTest1.

@Test(expected = StreamException.class)
public void streamClosedTest1() throws IOException, InterruptedException, StreamException {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
    int bindPort = testPinpointServerAcceptor.bind();
    TestPinpointClient testPinpointClient = new TestPinpointClient();
    try {
        testPinpointClient.connect(bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        testPinpointClient.openStream(new byte[0], clientListener);
    } 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 7 with RecordedStreamChannelMessageListener

use of com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener in project pinpoint by naver.

the class StreamChannelTest method stateChangeTest.

@Test
public void stateChangeTest() throws Exception {
    Channel mockChannel = Mockito.mock(Channel.class);
    NettyClientStreamChannel sc = new NettyClientStreamChannel(mockChannel, 1, new StreamChannelRepository(), new RecordedStreamChannelMessageListener(0));
    sc.init();
    Assert.assertEquals(StreamChannelStateCode.OPEN, sc.getCurrentState());
    boolean isChanged = sc.changeStateConnected();
    Assert.assertFalse(isChanged);
    Assert.assertEquals(StreamChannelStateCode.ILLEGAL_STATE, sc.getCurrentState());
}
Also used : Channel(org.jboss.netty.channel.Channel) RecordedStreamChannelMessageListener(com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener) Test(org.junit.Test)

Example 8 with RecordedStreamChannelMessageListener

use of com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener 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)

Aggregations

RecordedStreamChannelMessageListener (com.navercorp.pinpoint.rpc.RecordedStreamChannelMessageListener)8 Test (org.junit.Test)8 TestPinpointClient (com.navercorp.pinpoint.test.client.TestPinpointClient)6 TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)6 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)2 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)2 Channel (org.jboss.netty.channel.Channel)2 PinpointSocketException (com.navercorp.pinpoint.rpc.PinpointSocketException)1 IOException (java.io.IOException)1