Home / Class/ SnappyFrameEncoderTest Class — netty Architecture

SnappyFrameEncoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7bf4ca4f_ca32_181e_5b9a_f9630200b493["SnappyFrameEncoderTest"]
  df885696_4b1d_1e0c_bc44_7fe227f4d9be["SnappyFrameEncoderTest.java"]
  7bf4ca4f_ca32_181e_5b9a_f9630200b493 -->|defined in| df885696_4b1d_1e0c_bc44_7fe227f4d9be
  70294b16_3712_66ba_1eab_97663ebbaf29["setUp()"]
  7bf4ca4f_ca32_181e_5b9a_f9630200b493 -->|method| 70294b16_3712_66ba_1eab_97663ebbaf29
  78c8d087_2d78_7bf2_2eee_ebb1af553260["testSmallAmountOfDataIsUncompressed()"]
  7bf4ca4f_ca32_181e_5b9a_f9630200b493 -->|method| 78c8d087_2d78_7bf2_2eee_ebb1af553260
  66d71513_85a0_8930_1def_4a7f3318f35e["testLargeAmountOfDataIsCompressed()"]
  7bf4ca4f_ca32_181e_5b9a_f9630200b493 -->|method| 66d71513_85a0_8930_1def_4a7f3318f35e
  e4300c58_d4f6_ba43_6eac_dae6be335876["testStreamStartIsOnlyWrittenOnce()"]
  7bf4ca4f_ca32_181e_5b9a_f9630200b493 -->|method| e4300c58_d4f6_ba43_6eac_dae6be335876
  a8b69576_b4b8_c878_c12b_b86ab0df86c9["testInputBufferOverseek()"]
  7bf4ca4f_ca32_181e_5b9a_f9630200b493 -->|method| a8b69576_b4b8_c878_c12b_b86ab0df86c9

Relationship Graph

Source Code

codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyFrameEncoderTest.java lines 27–156

public class SnappyFrameEncoderTest {
    private EmbeddedChannel channel;

    @BeforeEach
    public void setUp() {
        channel = new EmbeddedChannel(new SnappyFrameEncoder());
    }

    @Test
    public void testSmallAmountOfDataIsUncompressed() throws Exception {
        ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
            'n', 'e', 't', 't', 'y'
        });

        channel.writeOutbound(in);
        assertTrue(channel.finish());
        ByteBuf expected = Unpooled.wrappedBuffer(new byte[] {
            (byte) 0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59,
             0x01, 0x09, 0x00, 0x00, 0x6f, -0x68, 0x2e, -0x47, 'n', 'e', 't', 't', 'y'
        });
        ByteBuf actual = channel.readOutbound();
        assertEquals(expected, actual);

        expected.release();
        actual.release();
    }

    @Test
    public void testLargeAmountOfDataIsCompressed() throws Exception {
        ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
            'n', 'e', 't', 't', 'y', 'n', 'e', 't', 't', 'y',
            'n', 'e', 't', 't', 'y', 'n', 'e', 't', 't', 'y'
        });

        channel.writeOutbound(in);
        assertTrue(channel.finish());

        ByteBuf expected = Unpooled.wrappedBuffer(new byte[] {
            (byte) 0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59,
             0x00, 0x0E, 0x00, 0x00, 0x3b, 0x36, -0x7f, 0x37,
                   0x14, 0x10,
                   'n', 'e', 't', 't', 'y',
                   0x3a, 0x05, 0x00
        });
        ByteBuf actual = channel.readOutbound();
        assertEquals(expected, actual);

        expected.release();
        actual.release();
    }

    @Test
    public void testStreamStartIsOnlyWrittenOnce() throws Exception {
        ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
            'n', 'e', 't', 't', 'y'
        });

        channel.writeOutbound(in.retain());
        in.resetReaderIndex(); // rewind the buffer to write the same data
        channel.writeOutbound(in);
        assertTrue(channel.finish());

        ByteBuf expected = Unpooled.wrappedBuffer(new byte[] {
            (byte) 0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59,
             0x01, 0x09, 0x00, 0x00, 0x6f, -0x68, 0x2e, -0x47, 'n', 'e', 't', 't', 'y',
             0x01, 0x09, 0x00, 0x00, 0x6f, -0x68, 0x2e, -0x47, 'n', 'e', 't', 't', 'y',
        });

        CompositeByteBuf actual = Unpooled.compositeBuffer();
        for (;;) {
            ByteBuf m = channel.readOutbound();
            if (m == null) {
                break;
            }
            actual.addComponent(true, m);
        }
        assertEquals(expected, actual);

        expected.release();
        actual.release();
    }

Frequently Asked Questions

What is the SnappyFrameEncoderTest class?
SnappyFrameEncoderTest is a class in the netty codebase, defined in codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyFrameEncoderTest.java.
Where is SnappyFrameEncoderTest defined?
SnappyFrameEncoderTest is defined in codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyFrameEncoderTest.java at line 27.

Analyze Your Own Codebase

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

Try Supermodel Free