Home / Function/ testFlushAfterGatheredFlush() — netty Function Reference

testFlushAfterGatheredFlush() — netty Function Reference

Architecture documentation for the testFlushAfterGatheredFlush() function in NioSocketChannelTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f4e680dd_c16e_0e80_f6ec_7a4abf24decc["testFlushAfterGatheredFlush()"]
  6562d13f_0b72_6889_33f9_c7688a2de3fc["NioSocketChannelTest"]
  f4e680dd_c16e_0e80_f6ec_7a4abf24decc -->|defined in| 6562d13f_0b72_6889_33f9_c7688a2de3fc
  style f4e680dd_c16e_0e80_f6ec_7a4abf24decc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/socket/nio/NioSocketChannelTest.java lines 128–162

    @Test
    public void testFlushAfterGatheredFlush() throws Exception {
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
        try {
            ServerBootstrap sb = new ServerBootstrap();
            sb.group(group).channel(NioServerSocketChannel.class);
            sb.childHandler(new ChannelInboundHandlerAdapter() {
                @Override
                public void channelActive(final ChannelHandlerContext ctx) throws Exception {
                    // Trigger a gathering write by writing two buffers.
                    ctx.write(Unpooled.wrappedBuffer(new byte[] { 'a' }));
                    ChannelFuture f = ctx.write(Unpooled.wrappedBuffer(new byte[] { 'b' }));
                    f.addListener(future -> {
                        // This message must be flushed
                        ctx.writeAndFlush(Unpooled.wrappedBuffer(new byte[]{'c'}));
                    });
                    ctx.flush();
                }
            });

            SocketAddress address = sb.bind(0).sync().channel().localAddress();

            Socket s = new Socket(NetUtil.LOCALHOST, ((InetSocketAddress) address).getPort());

            DataInput in = new DataInputStream(s.getInputStream());
            byte[] buf = new byte[3];
            in.readFully(buf);

            assertEquals("abc", new String(buf, CharsetUtil.US_ASCII));

            s.close();
        } finally {
            group.shutdownGracefully().sync();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testFlushAfterGatheredFlush() do?
testFlushAfterGatheredFlush() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/socket/nio/NioSocketChannelTest.java.
Where is testFlushAfterGatheredFlush() defined?
testFlushAfterGatheredFlush() is defined in transport/src/test/java/io/netty/channel/socket/nio/NioSocketChannelTest.java at line 128.

Analyze Your Own Codebase

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

Try Supermodel Free