Home / Function/ testHandshakeFailBeforeWritePromise() — netty Function Reference

testHandshakeFailBeforeWritePromise() — netty Function Reference

Architecture documentation for the testHandshakeFailBeforeWritePromise() function in SslHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  42203331_f652_cf96_cee4_b4e4eb2c2ae8["testHandshakeFailBeforeWritePromise()"]
  adaf7dc7_94e2_152f_ffdb_453fdaa4f25e["SslHandlerTest"]
  42203331_f652_cf96_cee4_b4e4eb2c2ae8 -->|defined in| adaf7dc7_94e2_152f_ffdb_453fdaa4f25e
  0fd148d9_de21_9e3d_3bde_be07148f32de["userEventTriggered()"]
  42203331_f652_cf96_cee4_b4e4eb2c2ae8 -->|calls| 0fd148d9_de21_9e3d_3bde_be07148f32de
  style 42203331_f652_cf96_cee4_b4e4eb2c2ae8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java lines 591–681

    @Test
    @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
    public void testHandshakeFailBeforeWritePromise() throws Exception {
        SelfSignedCertificate ssc = CachedSelfSignedCertificate.getCachedCertificate();
        final SslContext sslServerCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
        final CountDownLatch latch = new CountDownLatch(2);
        final CountDownLatch latch2 = new CountDownLatch(2);
        final BlockingQueue<Object> events = new LinkedBlockingQueue<Object>();
        Channel serverChannel = null;
        Channel clientChannel = null;
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory());
        try {
            ServerBootstrap sb = new ServerBootstrap();
            sb.group(group)
                .channel(LocalServerChannel.class)
                .childHandler(new ChannelInitializer<Channel>() {
                  @Override
                  protected void initChannel(Channel ch) {
                      ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc()));
                      ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
                          @Override
                          public void channelActive(ChannelHandlerContext ctx) {
                              ByteBuf buf = ctx.alloc().buffer(10);
                              buf.writeZero(buf.capacity());
                              ctx.writeAndFlush(buf).addListener(future -> {
                                  events.add(future);
                                  latch.countDown();
                              });
                          }

                          @Override
                          public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                              if (evt instanceof SslCompletionEvent) {
                                  events.add(evt);
                                  latch.countDown();
                                  latch2.countDown();
                              }
                          }
                      });
                  }
                });

            Bootstrap cb = new Bootstrap();
            cb.group(group)
                .channel(LocalChannel.class)
                .handler(new ChannelInitializer<Channel>() {
                    @Override
                    protected void initChannel(Channel ch) {
                        ch.pipeline().addFirst(new ChannelInboundHandlerAdapter() {
                            @Override
                            public void channelActive(ChannelHandlerContext ctx) {
                                ByteBuf buf = ctx.alloc().buffer(1000);
                                buf.writeZero(buf.capacity());
                                ctx.writeAndFlush(buf);
                            }
                        });
                    }
                });

            serverChannel = sb.bind(new LocalAddress("SslHandlerTest")).sync().channel();
            clientChannel = cb.connect(serverChannel.localAddress()).sync().channel();
            latch.await();

            SslCompletionEvent evt = (SslCompletionEvent) events.take();
            assertTrue(evt instanceof SslHandshakeCompletionEvent);
            assertInstanceOf(SSLException.class, evt.cause());

            ChannelFuture future = (ChannelFuture) events.take();
            assertInstanceOf(SSLException.class, future.cause());

            serverChannel.close().sync();
            serverChannel = null;
            clientChannel.close().sync();
            clientChannel = null;

            latch2.await();
            evt = (SslCompletionEvent) events.take();
            assertTrue(evt instanceof SslCloseCompletionEvent);
            assertInstanceOf(ClosedChannelException.class, evt.cause());
            assertTrue(events.isEmpty());
        } finally {

Domain

Subdomains

Frequently Asked Questions

What does testHandshakeFailBeforeWritePromise() do?
testHandshakeFailBeforeWritePromise() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java.
Where is testHandshakeFailBeforeWritePromise() defined?
testHandshakeFailBeforeWritePromise() is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java at line 591.
What does testHandshakeFailBeforeWritePromise() call?
testHandshakeFailBeforeWritePromise() calls 1 function(s): userEventTriggered.

Analyze Your Own Codebase

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

Try Supermodel Free