Home / Class/ QuicReadableTest Class — netty Architecture

QuicReadableTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  0534fc57_a356_79f8_f6d7_a0b91d4e819f["QuicReadableTest"]
  a71b43ed_5e90_2523_7288_e971b3b7ed66["QuicReadableTest.java"]
  0534fc57_a356_79f8_f6d7_a0b91d4e819f -->|defined in| a71b43ed_5e90_2523_7288_e971b3b7ed66
  e8b6a2ae_d0eb_fe8d_596b_d737041dbba5["testCorrectlyHandleReadableStreams()"]
  0534fc57_a356_79f8_f6d7_a0b91d4e819f -->|method| e8b6a2ae_d0eb_fe8d_596b_d737041dbba5
  c82510c4_cab1_a723_2999_08939d18ebd9["throwIfNotNull()"]
  0534fc57_a356_79f8_f6d7_a0b91d4e819f -->|method| c82510c4_cab1_a723_2999_08939d18ebd9

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicReadableTest.java lines 33–138

public class QuicReadableTest extends AbstractQuicTest {

    @ParameterizedTest
    @MethodSource("newSslTaskExecutors")
    public void testCorrectlyHandleReadableStreams(Executor executor) throws Throwable  {
        int numOfStreams = 256;
        int readStreams = numOfStreams / 2;
        // We do write longs.
        int expectedDataRead = readStreams * Long.BYTES;
        final CountDownLatch latch = new CountDownLatch(numOfStreams);
        final AtomicInteger bytesRead = new AtomicInteger();
        final AtomicReference<Throwable> serverErrorRef = new AtomicReference<>();
        final AtomicReference<Throwable> clientErrorRef = new AtomicReference<>();

        QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler();
        Channel server = QuicTestUtils.newServer(
                QuicTestUtils.newQuicServerBuilder(executor).initialMaxStreamsBidirectional(5000),
                InsecureQuicTokenHandler.INSTANCE,
                serverHandler, new ChannelInboundHandlerAdapter() {
                    private int counter;
                    @Override
                    public void channelRegistered(ChannelHandlerContext ctx) {
                        // Ensure we dont read from the streams so all of these will be reported as readable
                        ctx.channel().config().setAutoRead(false);
                    }

                    @Override
                    public void channelActive(ChannelHandlerContext ctx) {
                        counter++;
                        latch.countDown();
                        if (counter > readStreams) {
                            // Now set it to readable again for some channels
                            ctx.channel().config().setAutoRead(true);
                        }
                    }

                    @Override
                    public void channelRead(ChannelHandlerContext ctx, Object msg) {
                        ByteBuf buffer = (ByteBuf) msg;
                        bytesRead.addAndGet(buffer.readableBytes());
                        buffer.release();
                    }

                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
                        serverErrorRef.set(cause);
                    }

                    @Override
                    public boolean isSharable() {
                        return true;
                    }
                });
        Channel channel = QuicTestUtils.newClient(executor);
        QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
        ByteBuf data = Unpooled.directBuffer().writeLong(8);
        try {
            QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(clientHandler)
                    .streamHandler(new ChannelInboundHandlerAdapter())
                    .remoteAddress(server.localAddress())
                    .connect()
                    .get();

            List<Channel> streams = new ArrayList<>();
            for (int i = 0; i < numOfStreams; i++) {
                QuicStreamChannel stream = quicChannel.createStream(
                        QuicStreamType.BIDIRECTIONAL, new ChannelInboundHandlerAdapter() {
                            @Override
                            public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
                                clientErrorRef.set(cause);
                            }
                        }).get();
                streams.add(stream.writeAndFlush(data.retainedSlice()).sync().channel());
            }
            latch.await();
            while (bytesRead.get() < expectedDataRead) {
                Thread.sleep(50);
            }
            for (Channel stream: streams) {
                stream.close().sync();

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free