Home / Function/ testSessionReuse() — netty Function Reference

testSessionReuse() — netty Function Reference

Architecture documentation for the testSessionReuse() function in QuicChannelConnectTest.java from the netty codebase.

Function java Buffer Allocators calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  ba11076a_54a4_da71_9380_74debaccbf3e["testSessionReuse()"]
  1e1bc485_1969_4537_ef9b_f28971b2f663["QuicChannelConnectTest"]
  ba11076a_54a4_da71_9380_74debaccbf3e -->|defined in| 1e1bc485_1969_4537_ef9b_f28971b2f663
  ba60d199_c0ed_60b5_5fde_06d9b0fa4fd5["testSessionTickets()"]
  ba60d199_c0ed_60b5_5fde_06d9b0fa4fd5 -->|calls| ba11076a_54a4_da71_9380_74debaccbf3e
  58df2b9c_b3bd_0558_286b_ffef86477edb["testSessionReusedOnClientSide()"]
  58df2b9c_b3bd_0558_286b_ffef86477edb -->|calls| ba11076a_54a4_da71_9380_74debaccbf3e
  50ae9935_9ff5_26ef_46de_b1c885717ce2["BytesCountingHandler()"]
  ba11076a_54a4_da71_9380_74debaccbf3e -->|calls| 50ae9935_9ff5_26ef_46de_b1c885717ce2
  a4ce97cb_bc5b_41dd_e5c6_193cc8bf2306["assertSessionReused()"]
  ba11076a_54a4_da71_9380_74debaccbf3e -->|calls| a4ce97cb_bc5b_41dd_e5c6_193cc8bf2306
  f4776383_2a2c_409c_80cc_6e7b63f7a62f["channelActive()"]
  ba11076a_54a4_da71_9380_74debaccbf3e -->|calls| f4776383_2a2c_409c_80cc_6e7b63f7a62f
  style ba11076a_54a4_da71_9380_74debaccbf3e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java lines 1656–1757

    private static void testSessionReuse(Executor executor, boolean ticketKey) throws Exception {
        QuicSslContext sslServerCtx = QuicSslContextBuilder.forServer(
                        QuicTestUtils.SELF_SIGNED_CERTIFICATE.key(), null,
                        QuicTestUtils.SELF_SIGNED_CERTIFICATE.cert())
                .applicationProtocols(QuicTestUtils.PROTOS)
                .build();
        QuicSslContext sslClientCtx = QuicSslContextBuilder.forClient()
                .trustManager(InsecureTrustManagerFactory.INSTANCE).applicationProtocols(QuicTestUtils.PROTOS).build();

        if (ticketKey) {

            SslSessionTicketKey key = new SslSessionTicketKey(new byte[SslSessionTicketKey.NAME_SIZE],
                    new byte[SslSessionTicketKey.HMAC_KEY_SIZE], new byte[SslSessionTicketKey.AES_KEY_SIZE]);
            sslClientCtx.sessionContext().setTicketKeys(key);
            sslServerCtx.sessionContext().setTicketKeys(key);
        }
        CountDownLatch serverSslCompletionEventLatch = new CountDownLatch(2);
        Channel server = QuicTestUtils.newServer(QuicTestUtils.newQuicServerBuilder(executor, sslServerCtx),
                TestQuicTokenHandler.INSTANCE,
                new ChannelInboundHandlerAdapter() {
                    @Override
                    public boolean isSharable() {
                        return true;
                    }

                    @Override
                    public void channelActive(ChannelHandlerContext ctx) {
                        ((QuicChannel) ctx.channel()).createStream(QuicStreamType.BIDIRECTIONAL,
                                new ChannelInboundHandlerAdapter() {
                                    @Override
                                    public void channelActive(ChannelHandlerContext ctx) {
                                        ctx.writeAndFlush(ctx.alloc().directBuffer(10).writeZero(10))
                                                .addListener(f -> ctx.close());
                                    }
                                });
                        ctx.fireChannelActive();
                    }

                    @Override
                    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
                        if (evt instanceof SslHandshakeCompletionEvent) {
                            serverSslCompletionEventLatch.countDown();
                        }
                    }
                },
                new ChannelInboundHandlerAdapter());
        InetSocketAddress address = (InetSocketAddress) server.localAddress();

        Channel channel = QuicTestUtils.newClient(QuicTestUtils.newQuicClientBuilder(executor).sslEngineProvider(c ->
                sslClientCtx.newEngine(c.alloc(), "localhost", 9999)));
        try {
            CountDownLatch clientSslCompletionEventLatch = new CountDownLatch(2);

            QuicChannelBootstrap bootstrap = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(new ChannelInboundHandlerAdapter() {
                        @Override
                        public boolean isSharable() {
                            return true;
                        }

                        @Override
                        public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
                            if (evt instanceof SslHandshakeCompletionEvent) {
                                clientSslCompletionEventLatch.countDown();
                            }
                        }
                    })
                    .streamHandler(new ChannelInboundHandlerAdapter())
                    .remoteAddress(address);

            CountDownLatch latch1 = new CountDownLatch(1);
            QuicChannel quicChannel1 = bootstrap
                    .streamHandler(new BytesCountingHandler(latch1, 10))
                    .connect()
                    .get();
            latch1.await();
            assertSessionReused(quicChannel1, false);

            CountDownLatch latch2 = new CountDownLatch(1);
            QuicChannel quicChannel2 = bootstrap
                    .streamHandler(new BytesCountingHandler(latch2, 10))

Domain

Subdomains

Frequently Asked Questions

What does testSessionReuse() do?
testSessionReuse() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java.
Where is testSessionReuse() defined?
testSessionReuse() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java at line 1656.
What does testSessionReuse() call?
testSessionReuse() calls 3 function(s): BytesCountingHandler, assertSessionReused, channelActive.
What calls testSessionReuse()?
testSessionReuse() is called by 2 function(s): testSessionReusedOnClientSide, testSessionTickets.

Analyze Your Own Codebase

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

Try Supermodel Free