Home / Class/ LengthFieldBasedFrameDecoderTest Class — netty Architecture

LengthFieldBasedFrameDecoderTest Class — netty Architecture

Architecture documentation for the LengthFieldBasedFrameDecoderTest class in LengthFieldBasedFrameDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7e734a18_9dbb_0188_2134_ac583286d1f8["LengthFieldBasedFrameDecoderTest"]
  1b8cf119_c55d_3ddc_ff37_500b6550c1d7["LengthFieldBasedFrameDecoderTest.java"]
  7e734a18_9dbb_0188_2134_ac583286d1f8 -->|defined in| 1b8cf119_c55d_3ddc_ff37_500b6550c1d7
  d584ab2a_2e3c_64f1_0783_99c29b3cefaf["testFailSlowTooLongFrameRecovery()"]
  7e734a18_9dbb_0188_2134_ac583286d1f8 -->|method| d584ab2a_2e3c_64f1_0783_99c29b3cefaf
  ed61b291_0e7c_ca7d_504b_43eda7496731["testFailFastTooLongFrameRecovery()"]
  7e734a18_9dbb_0188_2134_ac583286d1f8 -->|method| ed61b291_0e7c_ca7d_504b_43eda7496731

Relationship Graph

Source Code

codec-base/src/test/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoderTest.java lines 32–73

public class LengthFieldBasedFrameDecoderTest {
    @Test
    public void testFailSlowTooLongFrameRecovery() throws Exception {
        EmbeddedChannel ch = new EmbeddedChannel(
                new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4, false));

        for (int i = 0; i < 2; i ++) {
            assertFalse(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
            try {
                assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0 })));
                fail(DecoderException.class.getSimpleName() + " must be raised.");
            } catch (TooLongFrameException e) {
                // Expected
            }

            ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 1, 'A' }));
            ByteBuf buf = ch.readInbound();
            assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
            buf.release();
        }
    }

    @Test
    public void testFailFastTooLongFrameRecovery() throws Exception {
        EmbeddedChannel ch = new EmbeddedChannel(
                new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4));

        for (int i = 0; i < 2; i ++) {
            try {
                assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
                fail(DecoderException.class.getSimpleName() + " must be raised.");
            } catch (TooLongFrameException e) {
                // Expected
            }

            ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' }));
            ByteBuf buf = ch.readInbound();
            assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
            buf.release();
        }
    }
}

Frequently Asked Questions

What is the LengthFieldBasedFrameDecoderTest class?
LengthFieldBasedFrameDecoderTest is a class in the netty codebase, defined in codec-base/src/test/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoderTest.java.
Where is LengthFieldBasedFrameDecoderTest defined?
LengthFieldBasedFrameDecoderTest is defined in codec-base/src/test/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoderTest.java at line 32.

Analyze Your Own Codebase

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

Try Supermodel Free