Search in sources :

Example 1 with DiscardServerHandler

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

the class PinpointServerSocketTest method testBind.

@Test
public void testBind() throws Exception {
    TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(new DiscardServerHandler());
    int bindPort = testPinpointServerAcceptor.bind();
    Socket socket = new Socket("127.0.0.1", bindPort);
    socket.getOutputStream().write(new byte[0]);
    socket.getOutputStream().flush();
    socket.close();
    Thread.sleep(1000);
    testPinpointServerAcceptor.close();
}
Also used : TestPinpointServerAcceptor(com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor) DiscardServerHandler(com.navercorp.pinpoint.rpc.DiscardServerHandler) Socket(java.net.Socket) Test(org.junit.Test)

Example 2 with DiscardServerHandler

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

the class PipelineFactoryTest method testBind.

@Test
public void testBind() throws Exception {
    PinpointServerAcceptor serverAcceptor = null;
    Socket socket = null;
    try {
        serverAcceptor = new PinpointServerAcceptor(ChannelFilter.BYPASS, new TestPipelineFactory());
        final DiscardServerHandler discardServerHandler = new DiscardServerHandler();
        serverAcceptor.setMessageHandler(discardServerHandler);
        serverAcceptor.bind("127.0.0.1", bindPort);
        socket = new Socket("127.0.0.1", bindPort);
        socket.getOutputStream().write((START_KEY + "Test").getBytes());
        socket.getOutputStream().flush();
        assertMessageReceivedCount(1, discardServerHandler);
        socket.getOutputStream().write(('@' + "Test").getBytes());
        socket.getOutputStream().flush();
        try {
            assertMessageReceivedCount(2, discardServerHandler);
            Assert.fail();
        } catch (ConditionTimeoutException e) {
        // ignore
        }
    } finally {
        IOUtils.closeQuietly(socket);
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : ConditionTimeoutException(org.awaitility.core.ConditionTimeoutException) DiscardServerHandler(com.navercorp.pinpoint.rpc.DiscardServerHandler) Socket(java.net.Socket) Test(org.junit.Test)

Aggregations

DiscardServerHandler (com.navercorp.pinpoint.rpc.DiscardServerHandler)2 Socket (java.net.Socket)2 Test (org.junit.Test)2 TestPinpointServerAcceptor (com.navercorp.pinpoint.test.server.TestPinpointServerAcceptor)1 ConditionTimeoutException (org.awaitility.core.ConditionTimeoutException)1