Home / Function/ testStreamLimitEnforcedWhenCreatingViaClient() — netty Function Reference

testStreamLimitEnforcedWhenCreatingViaClient() — netty Function Reference

Architecture documentation for the testStreamLimitEnforcedWhenCreatingViaClient() function in QuicStreamLimitTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  8f43dc59_1236_68c1_a2ec_3a8f896b51f4["testStreamLimitEnforcedWhenCreatingViaClient()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237["QuicStreamLimitTest"]
  8f43dc59_1236_68c1_a2ec_3a8f896b51f4 -->|defined in| e7f62e39_432b_500c_cf3e_39f7c392f237
  e11d58e0_02a1_1edb_aaee_b86722937470["testStreamLimitEnforcedWhenCreatingViaClientBidirectional()"]
  e11d58e0_02a1_1edb_aaee_b86722937470 -->|calls| 8f43dc59_1236_68c1_a2ec_3a8f896b51f4
  cad6a7ca_5f3c_9c68_bcdb_3cd032a8fe5e["testStreamLimitEnforcedWhenCreatingViaClientUnidirectional()"]
  cad6a7ca_5f3c_9c68_bcdb_3cd032a8fe5e -->|calls| 8f43dc59_1236_68c1_a2ec_3a8f896b51f4
  style 8f43dc59_1236_68c1_a2ec_3a8f896b51f4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamLimitTest.java lines 49–120

    private static void testStreamLimitEnforcedWhenCreatingViaClient(Executor executor, QuicStreamType type)
            throws Throwable {
        QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler();
        Channel server = QuicTestUtils.newServer(
                QuicTestUtils.newQuicServerBuilder(executor).initialMaxStreamsBidirectional(1)
                        .initialMaxStreamsUnidirectional(1),
                InsecureQuicTokenHandler.INSTANCE,
                serverHandler, new ChannelInboundHandlerAdapter() {
                    @Override
                    public boolean isSharable() {
                        return true;
                    }

                    @Override
                    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
                        if (evt == ChannelInputShutdownReadComplete.INSTANCE) {
                            ctx.close();
                        }
                    }
                });
        InetSocketAddress address = (InetSocketAddress) server.localAddress();
        Channel channel = QuicTestUtils.newClient(executor);

        CountDownLatch latch = new CountDownLatch(1);
        CountDownLatch latch2 = new CountDownLatch(1);
        QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler() {
            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
                if (evt instanceof QuicStreamLimitChangedEvent) {
                    if (latch.getCount() == 0) {
                        latch2.countDown();
                    } else {
                        latch.countDown();
                    }
                }
                super.userEventTriggered(ctx, evt);
            }
        };
        try {
            QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(clientHandler)
                    .streamHandler(new ChannelInboundHandlerAdapter())
                    .remoteAddress(address)
                    .connect().get();
            latch.await();
            assertEquals(1, quicChannel.peerAllowedStreams(QuicStreamType.UNIDIRECTIONAL));
            assertEquals(1, quicChannel.peerAllowedStreams(QuicStreamType.BIDIRECTIONAL));
            QuicStreamChannel stream = quicChannel.createStream(
                    type, new ChannelInboundHandlerAdapter()).get();

            assertEquals(0, quicChannel.peerAllowedStreams(type));

            // Second stream creation should fail.
            Throwable cause = quicChannel.createStream(
                    type, new ChannelInboundHandlerAdapter()).await().cause();
            assertInstanceOf(QuicException.class, cause);
            stream.close().sync();
            latch2.await();

            assertEquals(1, quicChannel.peerAllowedStreams(type));
            quicChannel.close().sync();

            serverHandler.assertState();
            clientHandler.assertState();
        } finally {
            server.close().sync();
            // Close the parent Datagram channel as well.
            channel.close().sync();

            shutdown(executor);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testStreamLimitEnforcedWhenCreatingViaClient() do?
testStreamLimitEnforcedWhenCreatingViaClient() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamLimitTest.java.
Where is testStreamLimitEnforcedWhenCreatingViaClient() defined?
testStreamLimitEnforcedWhenCreatingViaClient() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamLimitTest.java at line 49.
What calls testStreamLimitEnforcedWhenCreatingViaClient()?
testStreamLimitEnforcedWhenCreatingViaClient() is called by 2 function(s): testStreamLimitEnforcedWhenCreatingViaClientBidirectional, testStreamLimitEnforcedWhenCreatingViaClientUnidirectional.

Analyze Your Own Codebase

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

Try Supermodel Free