Home / Function/ testCloseAsync() — netty Function Reference

testCloseAsync() — netty Function Reference

Architecture documentation for the testCloseAsync() function in SimpleChannelPoolTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  73d3bc7c_1d20_5ad5_27e1_f8cb91620dee["testCloseAsync()"]
  dfb428cc_ecc3_d271_5689_7e428381a986["SimpleChannelPoolTest"]
  73d3bc7c_1d20_5ad5_27e1_f8cb91620dee -->|defined in| dfb428cc_ecc3_d271_5689_7e428381a986
  style 73d3bc7c_1d20_5ad5_27e1_f8cb91620dee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java lines 314–354

    @Test
    public void testCloseAsync() throws Exception {
        final LocalAddress addr = new LocalAddress(getLocalAddrId());
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory());

        // Start server
        final ServerBootstrap sb = new ServerBootstrap()
                .group(group)
                .channel(LocalServerChannel.class)
                .childHandler(new ChannelInitializer<LocalChannel>() {
                    @Override
                    protected void initChannel(LocalChannel ch) throws Exception {
                        ch.pipeline().addLast(new ChannelInboundHandlerAdapter());
                    }
                });
        final Channel sc = sb.bind(addr).syncUninterruptibly().channel();

        // Create pool, acquire and return channels
        final Bootstrap bootstrap = new Bootstrap()
                .channel(LocalChannel.class).group(group).remoteAddress(addr);
        final SimpleChannelPool pool = new SimpleChannelPool(bootstrap, new CountingChannelPoolHandler());
        Channel ch1 = pool.acquire().syncUninterruptibly().getNow();
        Channel ch2 = pool.acquire().syncUninterruptibly().getNow();
        pool.release(ch1).get(1, TimeUnit.SECONDS);
        pool.release(ch2).get(1, TimeUnit.SECONDS);

        // Assert that returned channels are open before close
        assertTrue(ch1.isOpen());
        assertTrue(ch2.isOpen());

        // Close asynchronously with timeout
        pool.closeAsync().get(1, TimeUnit.SECONDS);

        // Assert channels were indeed closed
        assertFalse(ch1.isOpen());
        assertFalse(ch2.isOpen());

        sc.close().sync();
        pool.close();
        group.shutdownGracefully();
    }

Domain

Subdomains

Frequently Asked Questions

What does testCloseAsync() do?
testCloseAsync() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java.
Where is testCloseAsync() defined?
testCloseAsync() is defined in transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java at line 314.

Analyze Your Own Codebase

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

Try Supermodel Free