use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class PinpointServerStateTest method closeByPeerTest.
@Test
public void closeByPeerTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
try {
int bindPort = testPinpointServerAcceptor.bind();
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
if (pinpointServer instanceof PinpointServer) {
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testPinpointClient.disconnect();
assertPinpointServerState(SocketStateCode.CLOSED_BY_CLIENT, (PinpointServer) pinpointServer);
} else {
Assert.fail();
}
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class PinpointServerStateTest method closeTest.
@Test
public void closeTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
try {
int bindPort = testPinpointServerAcceptor.bind();
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
testPinpointServerAcceptor.close();
assertPinpointServerState(SocketStateCode.CLOSED_BY_SERVER, (PinpointServer) pinpointServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class PinpointServerStateTest method unexpectedCloseTest.
@Test
public void unexpectedCloseTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), PinpointRPCTestUtils.getParams());
try {
int bindPort = testPinpointServerAcceptor.bind();
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
PinpointSocket pinpointServer = testPinpointServerAcceptor.getConnectedPinpointSocketList().get(0);
Assert.assertEquals(SocketStateCode.RUN_DUPLEX, ((PinpointServer) pinpointServer).getCurrentStateCode());
((DefaultPinpointServer) pinpointServer).stop(true);
assertPinpointServerState(SocketStateCode.UNEXPECTED_CLOSE_BY_SERVER, (PinpointServer) pinpointServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class StreamChannelManagerTest method streamClosedTest3.
// ServerSocket to Client Stream
// ServerStreamChannel first close.
@Test(expected = PinpointSocketException.class)
public void streamClosedTest3() throws IOException, InterruptedException, StreamException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
SimpleStreamBO bo = new SimpleStreamBO();
ServerListener serverStreamChannelMessageHandler = new ServerListener(bo);
TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE, serverStreamChannelMessageHandler);
testPinpointClient.connect(bindPort);
try {
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
List<PinpointSocket> writableServerList = testPinpointServerAcceptor.getConnectedPinpointSocketList();
Assert.assertEquals(1, writableServerList.size());
PinpointSocket writableServer = writableServerList.get(0);
if (writableServer instanceof PinpointServer) {
RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
ClientStreamChannel clientStreamChannel = ((PinpointServer) writableServer).openStreamAndAwait(new byte[0], clientListener, 3000);
StreamChannel streamChannel = serverStreamChannelMessageHandler.bo.serverStreamChannelList.get(0);
streamChannel.close();
sendRandomBytes(bo);
Thread.sleep(100);
clientStreamChannel.close();
} else {
Assert.fail();
}
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class StreamChannelManagerTest method streamSuccessTest3.
@Test
public void streamSuccessTest3() throws IOException, InterruptedException, StreamException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
SimpleStreamBO bo = new SimpleStreamBO();
TestPinpointClient testPinpointClient = new TestPinpointClient(SimpleMessageListener.INSTANCE, new ServerListener(bo));
try {
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1000);
List<PinpointSocket> writableServerList = testPinpointServerAcceptor.getConnectedPinpointSocketList();
Assert.assertEquals(1, writableServerList.size());
PinpointSocket writableServer = writableServerList.get(0);
RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
if (writableServer instanceof PinpointServer) {
ClientStreamChannel clientStreamChannel = ((PinpointServer) writableServer).openStreamAndAwait(new byte[0], clientListener, 3000);
int sendCount = 4;
for (int i = 0; i < sendCount; i++) {
sendRandomBytes(bo);
}
clientListener.getLatch().await();
Assert.assertEquals(sendCount, clientListener.getReceivedMessage().size());
clientStreamChannel.close();
} else {
Assert.fail();
}
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
Aggregations