Home / Class/ ProtobufVarint32FrameDecoderTest Class — netty Architecture

ProtobufVarint32FrameDecoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  89708b8b_0bd5_7657_39f7_5e017cf8f339["ProtobufVarint32FrameDecoderTest"]
  0efe300e_bf7d_9af0_73d6_8898fab86696["ProtobufVarint32FrameDecoderTest.java"]
  89708b8b_0bd5_7657_39f7_5e017cf8f339 -->|defined in| 0efe300e_bf7d_9af0_73d6_8898fab86696
  7a99b4d4_8132_3a66_5695_6de003d4023c["setUp()"]
  89708b8b_0bd5_7657_39f7_5e017cf8f339 -->|method| 7a99b4d4_8132_3a66_5695_6de003d4023c
  28dd185c_ae80_5bac_4620_200249b30603["testTinyDecode()"]
  89708b8b_0bd5_7657_39f7_5e017cf8f339 -->|method| 28dd185c_ae80_5bac_4620_200249b30603
  875e611e_920a_ab3f_4981_07cad11f9592["testRegularDecode()"]
  89708b8b_0bd5_7657_39f7_5e017cf8f339 -->|method| 875e611e_920a_ab3f_4981_07cad11f9592

Relationship Graph

Source Code

codec-protobuf/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoderTest.java lines 30–82

public class ProtobufVarint32FrameDecoderTest {

    private EmbeddedChannel ch;

    @BeforeEach
    public void setUp() {
        ch = new EmbeddedChannel(new ProtobufVarint32FrameDecoder());
    }

    @Test
    public void testTinyDecode() {
        byte[] b = { 4, 1, 1, 1, 1 };
        assertFalse(ch.writeInbound(wrappedBuffer(b, 0, 1)));
        assertNull(ch.readInbound());
        assertFalse(ch.writeInbound(wrappedBuffer(b, 1, 2)));
        assertNull(ch.readInbound());
        assertTrue(ch.writeInbound(wrappedBuffer(b, 3, b.length - 3)));

        ByteBuf expected = wrappedBuffer(new byte[] { 1, 1, 1, 1 });
        ByteBuf actual = ch.readInbound();

        assertEquals(expected, actual);
        assertFalse(ch.finish());

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

    @Test
    public void testRegularDecode() {
        byte[] b = new byte[2048];
        for (int i = 2; i < 2048; i ++) {
            b[i] = 1;
        }
        b[0] = -2;
        b[1] = 15;
        assertFalse(ch.writeInbound(wrappedBuffer(b, 0, 1)));
        assertNull(ch.readInbound());
        assertFalse(ch.writeInbound(wrappedBuffer(b, 1, 127)));
        assertNull(ch.readInbound());
        assertFalse(ch.writeInbound(wrappedBuffer(b, 127, 600)));
        assertNull(ch.readInbound());
        assertTrue(ch.writeInbound(wrappedBuffer(b, 727, b.length - 727)));

        ByteBuf expected = wrappedBuffer(b, 2, b.length - 2);
        ByteBuf actual = ch.readInbound();
        assertEquals(expected, actual);
        assertFalse(ch.finish());

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

Frequently Asked Questions

What is the ProtobufVarint32FrameDecoderTest class?
ProtobufVarint32FrameDecoderTest is a class in the netty codebase, defined in codec-protobuf/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoderTest.java.
Where is ProtobufVarint32FrameDecoderTest defined?
ProtobufVarint32FrameDecoderTest is defined in codec-protobuf/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoderTest.java at line 30.

Analyze Your Own Codebase

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

Try Supermodel Free