Home / Function/ testPacketsAreDispatchedToCorrectChannel() — netty Function Reference

testPacketsAreDispatchedToCorrectChannel() — netty Function Reference

Architecture documentation for the testPacketsAreDispatchedToCorrectChannel() function in QuicCodecDispatcherTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  109ae264_d03b_6be0_7e28_dc77cf8e0c51["testPacketsAreDispatchedToCorrectChannel()"]
  fadd0a68_af3f_4e94_ce6f_6f6ce1e2f7b1["QuicCodecDispatcherTest"]
  109ae264_d03b_6be0_7e28_dc77cf8e0c51 -->|defined in| fadd0a68_af3f_4e94_ce6f_6f6ce1e2f7b1
  6f052415_e9c7_32ed_5dfc_d9feba53afc9["writePacket()"]
  109ae264_d03b_6be0_7e28_dc77cf8e0c51 -->|calls| 6f052415_e9c7_32ed_5dfc_d9feba53afc9
  style 109ae264_d03b_6be0_7e28_dc77cf8e0c51 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicCodecDispatcherTest.java lines 37–89

    @Test
    public void testPacketsAreDispatchedToCorrectChannel() throws QuicException {
        short localConnectionIdLength = 16;

        AtomicInteger initChannelCalled = new AtomicInteger();
        QuicCodecDispatcher dispatcher = new QuicCodecDispatcher(localConnectionIdLength) {
            @Override
            protected void initChannel(Channel channel, int localConnectionIdLength,
                                       QuicConnectionIdGenerator idGenerator) {
                initChannelCalled.incrementAndGet();
            }
        };

        EmbeddedChannel[] channels = new EmbeddedChannel[8];
        for (int i = 0; i < channels.length; i++) {
            channels[i] = new EmbeddedChannel(dispatcher);
        }

        int numPackets = 0;
        for (int i = 0; i < 100; i++) {
            writePacket(channels, false, localConnectionIdLength);
            numPackets++;
            writePacket(channels, true, localConnectionIdLength);
            numPackets++;
        }

        for (int idx = 0; idx < channels.length; idx++) {
            EmbeddedChannel channel = channels[idx];
            for (;;) {
                DatagramPacket packet = channel.readInbound();
                    if (packet == null) {
                        break;
                    }
                try {
                    boolean hasShortHeader = QuicCodecDispatcher.hasShortHeader(packet.content());
                    ByteBuf id = QuicCodecDispatcher.getDestinationConnectionId(
                            packet.content(), localConnectionIdLength);
                    if (hasShortHeader) {
                        assertNotNull(id);
                        assertEquals(idx, QuicCodecDispatcher.decodeIdx(id));
                    } else {
                        assertNull(id);
                    }
                    numPackets--;
                } finally {
                    packet.release();
                }
            }
            assertFalse(channel.finishAndReleaseAll());
        }
        assertEquals(0, numPackets);
        assertEquals(channels.length, initChannelCalled.get());
    }

Domain

Subdomains

Frequently Asked Questions

What does testPacketsAreDispatchedToCorrectChannel() do?
testPacketsAreDispatchedToCorrectChannel() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicCodecDispatcherTest.java.
Where is testPacketsAreDispatchedToCorrectChannel() defined?
testPacketsAreDispatchedToCorrectChannel() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicCodecDispatcherTest.java at line 37.
What does testPacketsAreDispatchedToCorrectChannel() call?
testPacketsAreDispatchedToCorrectChannel() calls 1 function(s): writePacket.

Analyze Your Own Codebase

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

Try Supermodel Free