Home / Function/ testSelectiveRequestAggregation() — netty Function Reference

testSelectiveRequestAggregation() — netty Function Reference

Architecture documentation for the testSelectiveRequestAggregation() function in HttpObjectAggregatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  755ae81f_c322_1086_8aae_7f3d5a3b3d00["testSelectiveRequestAggregation()"]
  32ca569a_2b67_1114_bbc8_cbf703c91b95["HttpObjectAggregatorTest"]
  755ae81f_c322_1086_8aae_7f3d5a3b3d00 -->|defined in| 32ca569a_2b67_1114_bbc8_cbf703c91b95
  style 755ae81f_c322_1086_8aae_7f3d5a3b3d00 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java lines 627–684

    @Test
    public void testSelectiveRequestAggregation() {
        HttpObjectAggregator myPostAggregator = new HttpObjectAggregator(1024 * 1024) {
            @Override
            protected boolean isStartMessage(HttpObject msg) throws Exception {
                if (msg instanceof HttpRequest) {
                    HttpRequest request = (HttpRequest) msg;
                    HttpMethod method = request.method();

                    if (method.equals(HttpMethod.POST)) {
                        return true;
                    }
                }

                return false;
            }
        };

        EmbeddedChannel channel = new EmbeddedChannel(myPostAggregator);

        try {
            // Aggregate: POST
            HttpRequest request1 = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
            HttpContent content1 = new DefaultHttpContent(Unpooled.copiedBuffer("Hello, World!", CharsetUtil.UTF_8));
            request1.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);

            assertTrue(channel.writeInbound(request1, content1, LastHttpContent.EMPTY_LAST_CONTENT));

            // Getting an aggregated response out
            Object msg1 = channel.readInbound();
            try {
                assertTrue(msg1 instanceof FullHttpRequest);
            } finally {
                ReferenceCountUtil.release(msg1);
            }

            // Don't aggregate: non-POST
            HttpRequest request2 = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PUT, "/");
            HttpContent content2 = new DefaultHttpContent(Unpooled.copiedBuffer("Hello, World!", CharsetUtil.UTF_8));
            request2.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);

            try {
                assertTrue(channel.writeInbound(request2, content2, LastHttpContent.EMPTY_LAST_CONTENT));

                // Getting the same response objects out
                assertSame(request2, channel.readInbound());
                assertSame(content2, channel.readInbound());
                assertSame(LastHttpContent.EMPTY_LAST_CONTENT, channel.readInbound());
            } finally {
              ReferenceCountUtil.release(request2);
              ReferenceCountUtil.release(content2);
            }

            assertFalse(channel.finish());
        } finally {
          channel.close();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSelectiveRequestAggregation() do?
testSelectiveRequestAggregation() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java.
Where is testSelectiveRequestAggregation() defined?
testSelectiveRequestAggregation() is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java at line 627.

Analyze Your Own Codebase

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

Try Supermodel Free