Home / Function/ testFailureWhenLastChunkFailed() — netty Function Reference

testFailureWhenLastChunkFailed() — netty Function Reference

Architecture documentation for the testFailureWhenLastChunkFailed() function in ChunkedWriteHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  bcbb8dcf_a88e_c568_03ed_1374a4cfc035["testFailureWhenLastChunkFailed()"]
  56a5cec9_e7c0_8a2d_a9b0_56df2226f2bb["ChunkedWriteHandlerTest"]
  bcbb8dcf_a88e_c568_03ed_1374a4cfc035 -->|defined in| 56a5cec9_e7c0_8a2d_a9b0_56df2226f2bb
  style bcbb8dcf_a88e_c568_03ed_1374a4cfc035 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java lines 315–350

    @Test
    public void testFailureWhenLastChunkFailed() throws IOException {
        ChannelOutboundHandlerAdapter failLast = new ChannelOutboundHandlerAdapter() {
            private int passedWrites;

            @Override
            public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
                if (++this.passedWrites < 4) {
                    ctx.write(msg, promise);
                } else {
                    ReferenceCountUtil.release(msg);
                    promise.tryFailure(new RuntimeException());
                }
            }
        };

        EmbeddedChannel ch = new EmbeddedChannel(failLast, new ChunkedWriteHandler());
        ChannelFuture r = ch.writeAndFlush(new ChunkedFile(TMP, 1024 * 16)); // 4 chunks
        assertTrue(ch.finish());

        assertFalse(r.isSuccess());
        assertTrue(r.cause() instanceof RuntimeException);

        // 3 out of 4 chunks were already written
        int read = 0;
        for (;;) {
            ByteBuf buffer = ch.readOutbound();
            if (buffer == null) {
                break;
            }
            read += buffer.readableBytes();
            buffer.release();
        }

        assertEquals(1024 * 16 * 3, read);
    }

Domain

Subdomains

Frequently Asked Questions

What does testFailureWhenLastChunkFailed() do?
testFailureWhenLastChunkFailed() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java.
Where is testFailureWhenLastChunkFailed() defined?
testFailureWhenLastChunkFailed() is defined in handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java at line 315.

Analyze Your Own Codebase

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

Try Supermodel Free