Home / Function/ testEmptyContent() — netty Function Reference

testEmptyContent() — netty Function Reference

Architecture documentation for the testEmptyContent() function in HttpResponseEncoderTest.java from the netty codebase.

Function java Buffer Allocators calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  456aa908_1ae2_4247_eb3b_d9c766b9d30b["testEmptyContent()"]
  9235a1ad_cba8_50c2_25b1_57ce61f5b623["HttpResponseEncoderTest"]
  456aa908_1ae2_4247_eb3b_d9c766b9d30b -->|defined in| 9235a1ad_cba8_50c2_25b1_57ce61f5b623
  4c92d5b0_1159_b618_f293_76633ba7e1ab["testEmptyContentChunked()"]
  4c92d5b0_1159_b618_f293_76633ba7e1ab -->|calls| 456aa908_1ae2_4247_eb3b_d9c766b9d30b
  2f741aa2_809f_b63a_4948_98ebf00a132d["testEmptyContentNotChunked()"]
  2f741aa2_809f_b63a_4948_98ebf00a132d -->|calls| 456aa908_1ae2_4247_eb3b_d9c766b9d30b
  dc0150e4_fa1e_faa8_3643_9c1860fad9ee["release()"]
  456aa908_1ae2_4247_eb3b_d9c766b9d30b -->|calls| dc0150e4_fa1e_faa8_3643_9c1860fad9ee
  style 456aa908_1ae2_4247_eb3b_d9c766b9d30b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java lines 166–199

    private static void testEmptyContent(boolean chunked) throws Exception {
        String content = "netty rocks";
        ByteBuf contentBuffer = Unpooled.copiedBuffer(content, CharsetUtil.US_ASCII);
        int length = contentBuffer.readableBytes();

        EmbeddedChannel channel = new EmbeddedChannel(new HttpResponseEncoder());
        HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        if (!chunked) {
            HttpUtil.setContentLength(response, length);
        }
        assertTrue(channel.writeOutbound(response));
        assertTrue(channel.writeOutbound(new DefaultHttpContent(Unpooled.EMPTY_BUFFER)));
        assertTrue(channel.writeOutbound(new DefaultLastHttpContent(contentBuffer)));

        ByteBuf buffer = channel.readOutbound();
        if (!chunked) {
            assertEquals("HTTP/1.1 200 OK\r\ncontent-length: " + length + "\r\n\r\n",
                    buffer.toString(CharsetUtil.US_ASCII));
        } else {
            assertEquals("HTTP/1.1 200 OK\r\n\r\n", buffer.toString(CharsetUtil.US_ASCII));
        }
        buffer.release();

        // Test writing an empty buffer works when the encoder is not at ST_INIT.
        buffer = channel.readOutbound();
        assertEquals(0, buffer.readableBytes());
        buffer.release();

        buffer = channel.readOutbound();
        assertEquals(length, buffer.readableBytes());
        buffer.release();

        assertFalse(channel.finish());
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does testEmptyContent() do?
testEmptyContent() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java.
Where is testEmptyContent() defined?
testEmptyContent() is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java at line 166.
What does testEmptyContent() call?
testEmptyContent() calls 1 function(s): release.
What calls testEmptyContent()?
testEmptyContent() is called by 2 function(s): testEmptyContentChunked, testEmptyContentNotChunked.

Analyze Your Own Codebase

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

Try Supermodel Free