Home / Function/ testClientHandshakerForceClose() — netty Function Reference

testClientHandshakerForceClose() — netty Function Reference

Architecture documentation for the testClientHandshakerForceClose() function in WebSocketHandshakeHandOverTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  70999066_6bf3_6340_8da2_5b0391bf3457["testClientHandshakerForceClose()"]
  f9cd3101_4b2b_a61c_41fe_b9876a6a0902["WebSocketHandshakeHandOverTest"]
  70999066_6bf3_6340_8da2_5b0391bf3457 -->|defined in| f9cd3101_4b2b_a61c_41fe_b9876a6a0902
  316d52ff_05be_e73e_531d_de0a7d8b4907["CloseNoOpServerProtocolHandler()"]
  70999066_6bf3_6340_8da2_5b0391bf3457 -->|calls| 316d52ff_05be_e73e_531d_de0a7d8b4907
  8e12a079_6d1e_af18_a1a8_3016f84016ff["transferAllDataWithMerge()"]
  70999066_6bf3_6340_8da2_5b0391bf3457 -->|calls| 8e12a079_6d1e_af18_a1a8_3016f84016ff
  style 70999066_6bf3_6340_8da2_5b0391bf3457 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketHandshakeHandOverTest.java lines 231–283

    @Test
    @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
    public void testClientHandshakerForceClose() throws Exception {
        final WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(
                new URI("ws://localhost:1234/test"), WebSocketVersion.V13, null, true,
                EmptyHttpHeaders.INSTANCE, Integer.MAX_VALUE, true, false, 20);

        EmbeddedChannel serverChannel = createServerChannel(
                new CloseNoOpServerProtocolHandler("/test"),
                new SimpleChannelInboundHandler<Object>() {
                    @Override
                    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
                    }
                });

        EmbeddedChannel clientChannel = createClientChannel(handshaker, new SimpleChannelInboundHandler<Object>() {
            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                if (evt == ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) {
                    ctx.channel().closeFuture().addListener(future -> clientForceClosed = true);
                    handshaker.close(ctx.channel(), new CloseWebSocketFrame());
                }
            }
            @Override
            protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
            }
        });

        // Transfer the handshake from the client to the server
        transferAllDataWithMerge(clientChannel, serverChannel);
        // Transfer the handshake from the server to client
        transferAllDataWithMerge(serverChannel, clientChannel);

        // Transfer closing handshake
        transferAllDataWithMerge(clientChannel, serverChannel);
        assertTrue(serverReceivedCloseHandshake);
        // Should not be closed yet as we disabled closing the connection on the server
        assertFalse(clientForceClosed);

        while (!clientForceClosed) {
            Thread.sleep(10);
            // We need to run all pending tasks as the force close timeout is scheduled on the EventLoop.
            clientChannel.runPendingTasks();
        }

        // clientForceClosed would be set to TRUE after any close,
        // so check here that force close timeout was actually fired
        assertTrue(handshaker.isForceCloseComplete());

        // Both should be empty
        assertFalse(serverChannel.finishAndReleaseAll());
        assertFalse(clientChannel.finishAndReleaseAll());
    }

Domain

Subdomains

Frequently Asked Questions

What does testClientHandshakerForceClose() do?
testClientHandshakerForceClose() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketHandshakeHandOverTest.java.
Where is testClientHandshakerForceClose() defined?
testClientHandshakerForceClose() is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketHandshakeHandOverTest.java at line 231.
What does testClientHandshakerForceClose() call?
testClientHandshakerForceClose() calls 2 function(s): CloseNoOpServerProtocolHandler, transferAllDataWithMerge.

Analyze Your Own Codebase

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

Try Supermodel Free