Home / Function/ testPingPongFlowControlWhenAutoReadIsDisabled() — netty Function Reference

testPingPongFlowControlWhenAutoReadIsDisabled() — netty Function Reference

Architecture documentation for the testPingPongFlowControlWhenAutoReadIsDisabled() function in WebSocketProtocolHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  412c6c21_7ca3_782b_9331_ffe3c4a94392["testPingPongFlowControlWhenAutoReadIsDisabled()"]
  4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5["WebSocketProtocolHandlerTest"]
  412c6c21_7ca3_782b_9331_ffe3c4a94392 -->|defined in| 4e6acdd6_0a1b_2423_42e3_58c47c3a2cd5
  style 412c6c21_7ca3_782b_9331_ffe3c4a94392 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandlerTest.java lines 60–117

    @Test
    public void testPingPongFlowControlWhenAutoReadIsDisabled() {
        String text1 = "Hello, world #1";
        String text2 = "Hello, world #2";
        String text3 = "Hello, world #3";
        String text4 = "Hello, world #4";

        EmbeddedChannel channel = new EmbeddedChannel();
        channel.config().setAutoRead(false);
        channel.pipeline().addLast(new FlowControlHandler());
        channel.pipeline().addLast(new WebSocketProtocolHandler() { });

        // When
        assertFalse(channel.writeInbound(
            new PingWebSocketFrame(Unpooled.copiedBuffer(text1, UTF_8)),
            new TextWebSocketFrame(text2),
            new TextWebSocketFrame(text3),
            new PingWebSocketFrame(Unpooled.copiedBuffer(text4, UTF_8))
        ));

        // Then - no messages were handled or propagated
        assertNull(channel.readInbound());
        assertNull(channel.readOutbound());

        // When
        channel.read();

        // Then - pong frame was written to the outbound
        PongWebSocketFrame response1 = channel.readOutbound();
        assertEquals(text1, response1.content().toString(UTF_8));

        // And - one requested message was handled and propagated inbound
        TextWebSocketFrame message2 = channel.readInbound();
        assertEquals(text2, message2.text());

        // And - no more messages were handled or propagated
        assertNull(channel.readInbound());
        assertNull(channel.readOutbound());

        // When
        channel.read();

        // Then - one requested message was handled and propagated inbound
        TextWebSocketFrame message3 = channel.readInbound();
        assertEquals(text3, message3.text());

        // And - no more messages were handled or propagated
        // Precisely, ping frame 'text4' was NOT read or handled.
        // It would be handle ONLY on the next 'channel.read()' call.
        assertNull(channel.readInbound());
        assertNull(channel.readOutbound());

        // Cleanup
        response1.release();
        message2.release();
        message3.release();
        assertFalse(channel.finish());
    }

Domain

Subdomains

Frequently Asked Questions

What does testPingPongFlowControlWhenAutoReadIsDisabled() do?
testPingPongFlowControlWhenAutoReadIsDisabled() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandlerTest.java.
Where is testPingPongFlowControlWhenAutoReadIsDisabled() defined?
testPingPongFlowControlWhenAutoReadIsDisabled() is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketProtocolHandlerTest.java at line 60.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free