Home / Function/ testEchoStartedFromClient() — netty Function Reference

testEchoStartedFromClient() — netty Function Reference

Architecture documentation for the testEchoStartedFromClient() function in QuicChannelEchoTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  517fed06_cd16_bd40_97ea_e48339ad0706["testEchoStartedFromClient()"]
  949dbf36_222b_a1d5_95aa_68ae528fcaf5["QuicChannelEchoTest"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|defined in| 949dbf36_222b_a1d5_95aa_68ae528fcaf5
  dc18ab1e_9653_f54e_3875_3668a65b6f02["EchoHandler()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| dc18ab1e_9653_f54e_3875_3668a65b6f02
  e1045f62_6ee7_c954_17a5_31211f40f0cd["channelActive()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| e1045f62_6ee7_c954_17a5_31211f40f0cd
  e3494b32_ba2d_9829_4946_ef33056b5189["setAllocator()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| e3494b32_ba2d_9829_4946_ef33056b5189
  8f952ffb_218c_70bf_ea7f_e5e10f16983e["channelReadComplete()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| 8f952ffb_218c_70bf_ea7f_e5e10f16983e
  39d53d07_1929_f59b_be60_a52cbdc52542["writeAllData()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| 39d53d07_1929_f59b_be60_a52cbdc52542
  b05ab098_a6d5_f522_4cfc_e7b527ff5c1b["waitForData()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| b05ab098_a6d5_f522_4cfc_e7b527ff5c1b
  d03da1b0_2a83_47ce_bc9b_48796be3e619["checkForException()"]
  517fed06_cd16_bd40_97ea_e48339ad0706 -->|calls| d03da1b0_2a83_47ce_bc9b_48796be3e619
  style 517fed06_cd16_bd40_97ea_e48339ad0706 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelEchoTest.java lines 213–309

    @ParameterizedTest(name =
            "{index}: autoRead = {0}, directBuffer = {1}, composite = {2}")
    @MethodSource("data")
    public void testEchoStartedFromClient(boolean autoRead, boolean directBuffer, boolean composite) throws Throwable {
        ByteBufAllocator allocator = getAllocator(directBuffer);

        final EchoHandler sh = new EchoHandler(true, autoRead, allocator);
        final EchoHandler ch = new EchoHandler(false, autoRead, allocator);
        QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler() {
            @Override
            public void channelActive(ChannelHandlerContext ctx) {
                super.channelActive(ctx);
                setAllocator(ctx.channel(), allocator);
                ctx.channel().config().setAutoRead(autoRead);
                if (!autoRead) {
                    ctx.read();
                }
            }

            @Override
            public void channelReadComplete(ChannelHandlerContext ctx) {
                if (!autoRead) {
                    ctx.read();
                }
            }
        };

        Channel server = QuicTestUtils.newServer(ImmediateExecutor.INSTANCE, serverHandler, sh);
        setAllocator(server, allocator);
        InetSocketAddress address = (InetSocketAddress) server.localAddress();
        Channel channel = QuicTestUtils.newClient(ImmediateExecutor.INSTANCE);
        QuicChannel quicChannel = null;
        try {
            QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler() {
                @Override
                public void channelActive(ChannelHandlerContext ctx) {
                    if (!autoRead) {
                        ctx.read();
                    }
                }

                @Override
                public void channelReadComplete(ChannelHandlerContext ctx) {
                    if (!autoRead) {
                        ctx.read();
                    }
                }
            };
            quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(clientHandler)
                    .streamHandler(ch)
                    // Use the same allocator for the streams.
                    .streamOption(ChannelOption.ALLOCATOR, allocator)
                    .remoteAddress(address)
                    .option(ChannelOption.AUTO_READ, autoRead)
                    .option(ChannelOption.ALLOCATOR, allocator)
                    .connect()
                    .get();

            QuicStreamChannel stream = quicChannel.createStream(QuicStreamType.BIDIRECTIONAL, ch).sync().getNow();
            setAllocator(stream, allocator);

            assertEquals(QuicStreamType.BIDIRECTIONAL, stream.type());
            assertEquals(0, stream.streamId());
            assertTrue(stream.isLocalCreated());

            for (int i = 0; i < 5; i++) {
                ch.counter = 0;
                sh.counter = 0;
                List<ChannelFuture> futures = writeAllData(stream, composite, allocator);

                for (ChannelFuture f : futures) {
                    f.sync();
                }
                waitForData(ch, sh);
                waitForData(sh, ch);
                Thread.sleep(100);
            }

            // Close underlying streams.
            sh.channel.close().sync();

Domain

Subdomains

Frequently Asked Questions

What does testEchoStartedFromClient() do?
testEchoStartedFromClient() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelEchoTest.java.
Where is testEchoStartedFromClient() defined?
testEchoStartedFromClient() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelEchoTest.java at line 213.
What does testEchoStartedFromClient() call?
testEchoStartedFromClient() calls 7 function(s): EchoHandler, channelActive, channelReadComplete, checkForException, setAllocator, waitForData, writeAllData.

Analyze Your Own Codebase

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

Try Supermodel Free