Home / Class/ WebSocketServerHandshaker13Test Class — netty Architecture

WebSocketServerHandshaker13Test Class — netty Architecture

Architecture documentation for the WebSocketServerHandshaker13Test class in WebSocketServerHandshaker13Test.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9["WebSocketServerHandshaker13Test"]
  a89803e6_3303_8cff_fb6b_7a460fa58a39["WebSocketServerHandshaker13Test.java"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|defined in| a89803e6_3303_8cff_fb6b_7a460fa58a39
  0df3ecff_cbd5_5100_172d_c15595d367a3["WebSocketServerHandshaker()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 0df3ecff_cbd5_5100_172d_c15595d367a3
  7d98c534_1a51_a9c4_21d1_a1fcb6ac3532["WebSocketVersion()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 7d98c534_1a51_a9c4_21d1_a1fcb6ac3532
  9ee0b00b_251b_09ed_8b69_a739f49e12f9["testPerformOpeningHandshake()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 9ee0b00b_251b_09ed_8b69_a739f49e12f9
  2430dec6_5812_b341_84c2_b85d115bdba6["testPerformOpeningHandshakeSubProtocolNotSupported()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 2430dec6_5812_b341_84c2_b85d115bdba6
  6bd3fdb0_79e7_8d7b_ab53_b73429c54634["testPerformOpeningHandshake0()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 6bd3fdb0_79e7_8d7b_ab53_b73429c54634
  1bbc4fdb_e2ad_ddc6_1d2f_468924e52bec["testCloseReasonWithEncoderAndDecoder()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 1bbc4fdb_e2ad_ddc6_1d2f_468924e52bec
  f3f4b87f_66cb_42ff_5b65_d4207a1303b8["testCloseReasonWithCodec()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| f3f4b87f_66cb_42ff_5b65_d4207a1303b8
  c2781cba_e95b_7f94_3d5f_19a67488b50d["testHandshakeExceptionWhenConnectionHeaderIsAbsent()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| c2781cba_e95b_7f94_3d5f_19a67488b50d
  3b738f76_d41f_d1e2_5694_9ccd1040a6b0["testHandshakeExceptionWhenInvalidConnectionHeader()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 3b738f76_d41f_d1e2_5694_9ccd1040a6b0
  36f445ca_c719_c6cc_ab52_d29b3109bf77["testHandshakeExceptionWhenInvalidUpgradeHeader()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 36f445ca_c719_c6cc_ab52_d29b3109bf77
  db76d3df_c369_afe2_c78b_74447024f363["testCloseReason0()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| db76d3df_c369_afe2_c78b_74447024f363
  9b413e61_113c_d4ee_061a_59cd3c3e3003["testUpgrade0()"]
  b3c12c47_d3a9_1bed_608c_a4b3745e9ee9 -->|method| 9b413e61_113c_d4ee_061a_59cd3c3e3003

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13Test.java lines 50–225

public class WebSocketServerHandshaker13Test extends WebSocketServerHandshakerTest {

    @Override
    protected WebSocketServerHandshaker newHandshaker(String webSocketURL, String subprotocols,
            WebSocketDecoderConfig decoderConfig) {
        return new WebSocketServerHandshaker13(webSocketURL, subprotocols, decoderConfig);
    }

    @Override
    protected WebSocketVersion webSocketVersion() {
        return WebSocketVersion.V13;
    }

    @Test
    public void testPerformOpeningHandshake() {
        testPerformOpeningHandshake0(true);
    }

    @Test
    public void testPerformOpeningHandshakeSubProtocolNotSupported() {
        testPerformOpeningHandshake0(false);
    }

    private static void testPerformOpeningHandshake0(boolean subProtocol) {
        EmbeddedChannel ch = new EmbeddedChannel(
                new HttpObjectAggregator(42), new HttpResponseEncoder(), new HttpRequestDecoder());

        if (subProtocol) {
            testUpgrade0(ch, new WebSocketServerHandshaker13(
                    "ws://example.com/chat", "chat", false, Integer.MAX_VALUE, false));
        } else {
            testUpgrade0(ch, new WebSocketServerHandshaker13(
                    "ws://example.com/chat", null, false, Integer.MAX_VALUE, false));
        }
        assertFalse(ch.finish());
    }

    @Test
    public void testCloseReasonWithEncoderAndDecoder() {
        testCloseReason0(new HttpResponseEncoder(), new HttpRequestDecoder());
    }

    @Test
    public void testCloseReasonWithCodec() {
        testCloseReason0(new HttpServerCodec());
    }

    @Test
    public void testHandshakeExceptionWhenConnectionHeaderIsAbsent() {
        final WebSocketServerHandshaker serverHandshaker = newHandshaker("ws://example.com/chat",
                                                                         "chat", WebSocketDecoderConfig.DEFAULT);
        final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
                                                                   "ws://example.com/chat");
        request.headers()
               .set(HttpHeaderNames.HOST, "server.example.com")
               .set(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET)
               .set(HttpHeaderNames.SEC_WEBSOCKET_KEY, "dGhlIHNhbXBsZSBub25jZQ==")
               .set(HttpHeaderNames.SEC_WEBSOCKET_ORIGIN, "http://example.com")
               .set(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL, "chat, superchat")
               .set(HttpHeaderNames.SEC_WEBSOCKET_VERSION, "13");
        Throwable exception = assertThrows(WebSocketServerHandshakeException.class, new Executable() {
            @Override
            public void execute() throws Throwable {
                serverHandshaker.handshake(null, request, null, null);
            }
        });

        assertEquals("not a WebSocket request: a |Connection| header must includes a token 'Upgrade'",
                     exception.getMessage());
        assertTrue(request.release());
    }

    @Test
    public void testHandshakeExceptionWhenInvalidConnectionHeader() {
        final WebSocketServerHandshaker serverHandshaker = newHandshaker("ws://example.com/chat",
                                                                         "chat", WebSocketDecoderConfig.DEFAULT);
        final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
                                                                   "ws://example.com/chat");
        request.headers()
               .set(HttpHeaderNames.HOST, "server.example.com")
               .set(HttpHeaderNames.CONNECTION, "close")

Frequently Asked Questions

What is the WebSocketServerHandshaker13Test class?
WebSocketServerHandshaker13Test is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13Test.java.
Where is WebSocketServerHandshaker13Test defined?
WebSocketServerHandshaker13Test is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13Test.java at line 50.

Analyze Your Own Codebase

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

Try Supermodel Free