Home / Function/ testUnidirectionalCreatedByServer() — netty Function Reference

testUnidirectionalCreatedByServer() — netty Function Reference

Architecture documentation for the testUnidirectionalCreatedByServer() function in QuicStreamTypeTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  faa5598b_5dcd_3af7_3806_c5124d307694["testUnidirectionalCreatedByServer()"]
  0ec01d66_c523_3778_a23c_e5c6e8cb6d2e["QuicStreamTypeTest"]
  faa5598b_5dcd_3af7_3806_c5124d307694 -->|defined in| 0ec01d66_c523_3778_a23c_e5c6e8cb6d2e
  style faa5598b_5dcd_3af7_3806_c5124d307694 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamTypeTest.java lines 91–156

    @ParameterizedTest
    @MethodSource("newSslTaskExecutors")
    public void testUnidirectionalCreatedByServer(Executor executor) throws Throwable {
        Channel server = null;
        Channel channel = null;
        Promise<Void> serverWritePromise = ImmediateEventExecutor.INSTANCE.newPromise();
        Promise<Throwable> clientWritePromise = ImmediateEventExecutor.INSTANCE.newPromise();

        QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler() {
            @Override
            public void channelActive(ChannelHandlerContext ctx) {
                super.channelActive(ctx);
                QuicChannel channel = (QuicChannel) ctx.channel();
                channel.createStream(QuicStreamType.UNIDIRECTIONAL, new ChannelInboundHandlerAdapter() {
                    @Override
                    public void channelActive(ChannelHandlerContext ctx) {
                        // Do the write which should succeed
                        ctx.writeAndFlush(Unpooled.buffer().writeZero(8))
                                .addListener(new PromiseNotifier<>(serverWritePromise));
                    }
                });
            }
        };
        QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
        try {
            server = QuicTestUtils.newServer(executor, serverHandler, new ChannelInboundHandlerAdapter());

            channel = QuicTestUtils.newClient(executor);
            QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(clientHandler)
                    .streamHandler(new ChannelInboundHandlerAdapter() {
                        @Override
                        public void channelActive(ChannelHandlerContext ctx) {
                            // Do the write should fail
                            ctx.writeAndFlush(Unpooled.buffer().writeZero(8))
                                    .addListener(future -> clientWritePromise.setSuccess(future.cause()));
                        }

                        @Override
                        public void channelInactive(ChannelHandlerContext ctx) {
                            // Close the QUIC channel as well.
                            ctx.channel().parent().close();
                        }

                        @Override
                        public void channelRead(ChannelHandlerContext ctx, Object msg) {
                            ReferenceCountUtil.release(msg);
                            // Let's close the stream
                            ctx.close();
                        }
                    })
                    .remoteAddress(server.localAddress())
                    .connect()
                    .get();

            quicChannel.closeFuture().sync();
            assertTrue(serverWritePromise.await().isSuccess());
            assertInstanceOf(UnsupportedOperationException.class, clientWritePromise.get());

            serverHandler.assertState();
            clientHandler.assertState();
        } finally {
            QuicTestUtils.closeIfNotNull(channel);
            QuicTestUtils.closeIfNotNull(server);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testUnidirectionalCreatedByServer() do?
testUnidirectionalCreatedByServer() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamTypeTest.java.
Where is testUnidirectionalCreatedByServer() defined?
testUnidirectionalCreatedByServer() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamTypeTest.java at line 91.

Analyze Your Own Codebase

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

Try Supermodel Free