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();
}
}
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());
}
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();
}
}
Aggregations