Home / Function/ testHandover() — netty Function Reference

testHandover() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  9ed7bce0_e335_5d6a_b465_b14a56ba6a90["testHandover()"]
  f9cd3101_4b2b_a61c_41fe_b9876a6a0902["WebSocketHandshakeHandOverTest"]
  9ed7bce0_e335_5d6a_b465_b14a56ba6a90 -->|defined in| f9cd3101_4b2b_a61c_41fe_b9876a6a0902
  8e12a079_6d1e_af18_a1a8_3016f84016ff["transferAllDataWithMerge()"]
  9ed7bce0_e335_5d6a_b465_b14a56ba6a90 -->|calls| 8e12a079_6d1e_af18_a1a8_3016f84016ff
  style 9ed7bce0_e335_5d6a_b465_b14a56ba6a90 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketHandshakeHandOverTest.java lines 85–130

    @Test
    public void testHandover() throws Exception {
        EmbeddedChannel serverChannel = createServerChannel(new SimpleChannelInboundHandler<Object>() {
            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                if (evt == ServerHandshakeStateEvent.HANDSHAKE_COMPLETE) {
                    serverReceivedHandshake = true;
                    // immediately send a message to the client on connect
                    ctx.writeAndFlush(new TextWebSocketFrame("abc"));
                } else if (evt instanceof WebSocketServerProtocolHandler.HandshakeComplete) {
                    serverHandshakeComplete = (WebSocketServerProtocolHandler.HandshakeComplete) evt;
                }
            }
            @Override
            protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
            }
        });

        EmbeddedChannel clientChannel = createClientChannel(new SimpleChannelInboundHandler<Object>() {
            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                if (evt == ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) {
                    clientReceivedHandshake = true;
                }
            }
            @Override
            protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
                if (msg instanceof TextWebSocketFrame) {
                    clientReceivedMessage = true;
                }
            }
        });

        // Transfer the handshake from the client to the server
        transferAllDataWithMerge(clientChannel, serverChannel);
        assertTrue(serverReceivedHandshake);
        assertNotNull(serverHandshakeComplete);
        assertEquals("/test", serverHandshakeComplete.requestUri());
        assertEquals(8, serverHandshakeComplete.requestHeaders().size());
        assertEquals("test-proto-2", serverHandshakeComplete.selectedSubprotocol());

        // Transfer the handshake response and the websocket message to the client
        transferAllDataWithMerge(serverChannel, clientChannel);
        assertTrue(clientReceivedHandshake);
        assertTrue(clientReceivedMessage);
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free