Home / Function/ testWebSocketProtocolViolation() — netty Function Reference

testWebSocketProtocolViolation() — netty Function Reference

Architecture documentation for the testWebSocketProtocolViolation() function in WebSocket08EncoderDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  1a0bc198_3cbd_937a_5778_4a6c5c16cecf["testWebSocketProtocolViolation()"]
  1641b287_2aaf_ce3b_c2c6_654ccc82886d["WebSocket08EncoderDecoderTest"]
  1a0bc198_3cbd_937a_5778_4a6c5c16cecf -->|defined in| 1641b287_2aaf_ce3b_c2c6_654ccc82886d
  56256270_4a10_737f_73a0_6c3b146a6140["initTestData()"]
  1a0bc198_3cbd_937a_5778_4a6c5c16cecf -->|calls| 56256270_4a10_737f_73a0_6c3b146a6140
  82de8b8e_7786_8b3a_c2e0_97889a7caa9d["executeProtocolViolationTest()"]
  1a0bc198_3cbd_937a_5778_4a6c5c16cecf -->|calls| 82de8b8e_7786_8b3a_c2e0_97889a7caa9d
  style 1a0bc198_3cbd_937a_5778_4a6c5c16cecf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08EncoderDecoderTest.java lines 61–107

    @Test
    public void testWebSocketProtocolViolation() {
        // Given
        initTestData();

        int maxPayloadLength = 255;
        String errorMessage = "Max frame length of " + maxPayloadLength + " has been exceeded.";
        WebSocketCloseStatus expectedStatus = WebSocketCloseStatus.MESSAGE_TOO_BIG;

        // With auto-close
        WebSocketDecoderConfig config = WebSocketDecoderConfig.newBuilder()
            .maxFramePayloadLength(maxPayloadLength)
            .closeOnProtocolViolation(true)
            .build();
        EmbeddedChannel inChannel = new EmbeddedChannel(new WebSocket08FrameDecoder(config));
        EmbeddedChannel outChannel = new EmbeddedChannel(new WebSocket08FrameEncoder(true));

        executeProtocolViolationTest(outChannel, inChannel, maxPayloadLength + 1, expectedStatus, errorMessage);

        CloseWebSocketFrame response = inChannel.readOutbound();
        assertNotNull(response);
        assertEquals(expectedStatus.code(), response.statusCode());
        assertEquals(errorMessage, response.reasonText());
        response.release();

        assertFalse(inChannel.finish());
        assertFalse(outChannel.finish());

        // Without auto-close
        config = WebSocketDecoderConfig.newBuilder()
            .maxFramePayloadLength(maxPayloadLength)
            .closeOnProtocolViolation(false)
            .build();
        inChannel = new EmbeddedChannel(new WebSocket08FrameDecoder(config));
        outChannel = new EmbeddedChannel(new WebSocket08FrameEncoder(true));

        executeProtocolViolationTest(outChannel, inChannel, maxPayloadLength + 1, expectedStatus, errorMessage);

        response = inChannel.readOutbound();
        assertNull(response);

        assertFalse(inChannel.finish());
        assertFalse(outChannel.finish());

        // Release test data
        binTestData.release();
    }

Domain

Subdomains

Frequently Asked Questions

What does testWebSocketProtocolViolation() do?
testWebSocketProtocolViolation() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08EncoderDecoderTest.java.
Where is testWebSocketProtocolViolation() defined?
testWebSocketProtocolViolation() is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08EncoderDecoderTest.java at line 61.
What does testWebSocketProtocolViolation() call?
testWebSocketProtocolViolation() calls 2 function(s): executeProtocolViolationTest, initTestData.

Analyze Your Own Codebase

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

Try Supermodel Free