Home / Class/ QuicStreamLimitTest Class — netty Architecture

QuicStreamLimitTest Class — netty Architecture

Architecture documentation for the QuicStreamLimitTest class in QuicStreamLimitTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  e7f62e39_432b_500c_cf3e_39f7c392f237["QuicStreamLimitTest"]
  952c6981_832a_5610_9698_f8b55494d94b["QuicStreamLimitTest.java"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|defined in| 952c6981_832a_5610_9698_f8b55494d94b
  e11d58e0_02a1_1edb_aaee_b86722937470["testStreamLimitEnforcedWhenCreatingViaClientBidirectional()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|method| e11d58e0_02a1_1edb_aaee_b86722937470
  cad6a7ca_5f3c_9c68_bcdb_3cd032a8fe5e["testStreamLimitEnforcedWhenCreatingViaClientUnidirectional()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|method| cad6a7ca_5f3c_9c68_bcdb_3cd032a8fe5e
  8f43dc59_1236_68c1_a2ec_3a8f896b51f4["testStreamLimitEnforcedWhenCreatingViaClient()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|method| 8f43dc59_1236_68c1_a2ec_3a8f896b51f4
  c5261b56_975e_d40e_3236_bfa8bc77897e["testStreamLimitEnforcedWhenCreatingViaServerBidirectional()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|method| c5261b56_975e_d40e_3236_bfa8bc77897e
  b58ca41c_1155_4d92_89cc_c7f69fbe601f["testStreamLimitEnforcedWhenCreatingViaServerUnidirectional()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|method| b58ca41c_1155_4d92_89cc_c7f69fbe601f
  62d51dbc_607c_6f07_5f31_26f609c0169b["testStreamLimitEnforcedWhenCreatingViaServer()"]
  e7f62e39_432b_500c_cf3e_39f7c392f237 -->|method| 62d51dbc_607c_6f07_5f31_26f609c0169b

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamLimitTest.java lines 35–194

public class QuicStreamLimitTest extends AbstractQuicTest {

    @ParameterizedTest
    @MethodSource("newSslTaskExecutors")
    public void testStreamLimitEnforcedWhenCreatingViaClientBidirectional(Executor executor) throws Throwable {
        testStreamLimitEnforcedWhenCreatingViaClient(executor, QuicStreamType.BIDIRECTIONAL);
    }

    @ParameterizedTest
    @MethodSource("newSslTaskExecutors")
    public void testStreamLimitEnforcedWhenCreatingViaClientUnidirectional(Executor executor) throws Throwable {
        testStreamLimitEnforcedWhenCreatingViaClient(executor, QuicStreamType.UNIDIRECTIONAL);
    }

    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.

Frequently Asked Questions

What is the QuicStreamLimitTest class?
QuicStreamLimitTest is a class in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamLimitTest.java.
Where is QuicStreamLimitTest defined?
QuicStreamLimitTest is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamLimitTest.java at line 35.

Analyze Your Own Codebase

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

Try Supermodel Free