Home / Function/ testSimpleQueryTest() — netty Function Reference

testSimpleQueryTest() — netty Function Reference

Architecture documentation for the testSimpleQueryTest() function in OCSPTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  e5937798_f45f_a653_4c16_4f5c423d4f7a["testSimpleQueryTest()"]
  d651cfe3_452c_bc2f_8ab1_5b28b9161b54["OCSPTest"]
  e5937798_f45f_a653_4c16_4f5c423d4f7a -->|defined in| d651cfe3_452c_bc2f_8ab1_5b28b9161b54
  style e5937798_f45f_a653_4c16_4f5c423d4f7a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/OCSPTest.java lines 46–99

    @Test
    public void testSimpleQueryTest() throws Exception {
        final AtomicBoolean ocspStatus = new AtomicBoolean();
        EventLoopGroup eventLoopGroup = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());

        try {
            final CountDownLatch latch = new CountDownLatch(1);
            final SslContext sslContext = SslContextBuilder.forClient()
                    .trustManager(InsecureTrustManagerFactory.INSTANCE)
                    .build();

            Bootstrap bootstrap = new Bootstrap()
                    .group(eventLoopGroup)
                    .channel(NioSocketChannel.class)
                    .option(ChannelOption.TCP_NODELAY, true)
                    .handler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) {
                            ChannelPipeline pipeline = ch.pipeline();
                            pipeline.addLast(sslContext.newHandler(ch.alloc(), "netty.io", 443));
                            pipeline.addLast(new OcspServerCertificateValidator(false));
                            pipeline.addLast(new SimpleChannelInboundHandler<>() {
                                @Override
                                protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
                                    // NOOP
                                }

                                @Override
                                public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                                    if (evt instanceof OcspValidationEvent) {
                                        OcspValidationEvent event = (OcspValidationEvent) evt;

                                        ocspStatus.set(event.response().status() == OcspResponse.Status.VALID);
                                        ctx.channel().close();
                                        latch.countDown();
                                    }
                                }
                            });
                        }
                    });

            ChannelFuture channelFuture = bootstrap.connect("netty.io", 443);
            channelFuture.sync();

            // Wait for maximum of 1 minute for Ocsp validation to happen
            latch.await(1, TimeUnit.MINUTES);
            assertTrue(ocspStatus.get());

            // Wait for Channel to be closed
            channelFuture.channel().closeFuture().sync();
        } finally {
            eventLoopGroup.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSimpleQueryTest() do?
testSimpleQueryTest() is a function in the netty codebase, defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/OCSPTest.java.
Where is testSimpleQueryTest() defined?
testSimpleQueryTest() is defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/OCSPTest.java at line 46.

Analyze Your Own Codebase

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

Try Supermodel Free