Home / Function/ testIllegalStateWhenCompressionInProgress() — netty Function Reference

testIllegalStateWhenCompressionInProgress() — netty Function Reference

Architecture documentation for the testIllegalStateWhenCompressionInProgress() function in PerMessageDeflateEncoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  413e93f0_dd38_2f95_d162_26b8865a53f8["testIllegalStateWhenCompressionInProgress()"]
  74922fa4_3ca7_d958_57dc_fafad72e442c["PerMessageDeflateEncoderTest"]
  413e93f0_dd38_2f95_d162_26b8865a53f8 -->|defined in| 74922fa4_3ca7_d958_57dc_fafad72e442c
  style 413e93f0_dd38_2f95_d162_26b8865a53f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateEncoderTest.java lines 245–285

    @Test
    public void testIllegalStateWhenCompressionInProgress() {
        WebSocketExtensionFilter selectivityCompressionFilter = new WebSocketExtensionFilter() {
            @Override
            public boolean mustSkip(WebSocketFrame frame) {
                return frame.content().readableBytes() < 100;
            }
        };
        final EmbeddedChannel encoderChannel = new EmbeddedChannel(
                new PerMessageDeflateEncoder(9, 15, false, selectivityCompressionFilter));

        byte[] firstPayload = new byte[200];
        random.nextBytes(firstPayload);

        byte[] finalPayload = new byte[90];
        random.nextBytes(finalPayload);

        BinaryWebSocketFrame firstPart = new BinaryWebSocketFrame(false, 0, Unpooled.wrappedBuffer(firstPayload));
        final ContinuationWebSocketFrame finalPart = new ContinuationWebSocketFrame(true, 0,
                                                                              Unpooled.wrappedBuffer(finalPayload));
        assertTrue(encoderChannel.writeOutbound(firstPart));

        BinaryWebSocketFrame outboundFirstPart = encoderChannel.readOutbound();
        //first part is compressed
        assertEquals(WebSocketExtension.RSV1, outboundFirstPart.rsv());
        assertFalse(Arrays.equals(firstPayload, ByteBufUtil.getBytes(outboundFirstPart.content())));
        assertTrue(outboundFirstPart.release());

        //final part throwing exception
        try {
            assertThrows(EncoderException.class, new Executable() {
                @Override
                public void execute() throws Throwable {
                    encoderChannel.writeOutbound(finalPart);
                }
            });
        } finally {
            assertTrue(finalPart.release());
            assertFalse(encoderChannel.finishAndReleaseAll());
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testIllegalStateWhenCompressionInProgress() do?
testIllegalStateWhenCompressionInProgress() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateEncoderTest.java.
Where is testIllegalStateWhenCompressionInProgress() defined?
testIllegalStateWhenCompressionInProgress() is defined in codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateEncoderTest.java at line 245.

Analyze Your Own Codebase

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

Try Supermodel Free