Home / Class/ Bzip2DecoderTest Class — netty Architecture

Bzip2DecoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  53eb2ef4_6844_0384_3483_6c7a17c214e0["Bzip2DecoderTest"]
  d6a952f1_2104_9a29_cc56_dbb087ff213a["Bzip2DecoderTest.java"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|defined in| d6a952f1_2104_9a29_cc56_dbb087ff213a
  b0d3b5b4_332b_9efd_0fa3_1735dcbe00b8["Bzip2DecoderTest()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| b0d3b5b4_332b_9efd_0fa3_1735dcbe00b8
  e226562f_a0e3_acc6_62c5_66a5274368e6["EmbeddedChannel()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| e226562f_a0e3_acc6_62c5_66a5274368e6
  dcecdd6e_d887_ea2f_883f_18b973e0a770["writeInboundDestroyAndExpectDecompressionException()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| dcecdd6e_d887_ea2f_883f_18b973e0a770
  4e1f0acb_f7df_0898_0872_473cb78e5da2["testUnexpectedStreamIdentifier()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 4e1f0acb_f7df_0898_0872_473cb78e5da2
  80bf34e7_f084_fd02_9f92_8f13cf264310["testInvalidBlockSize()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 80bf34e7_f084_fd02_9f92_8f13cf264310
  e2389c34_f2e9_6a0d_73df_be15b2f6d25e["testBadBlockHeader()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| e2389c34_f2e9_6a0d_73df_be15b2f6d25e
  c0e5e7a4_7580_4ece_1871_cc4c24347da5["testStreamCrcErrorOfEmptyBlock()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| c0e5e7a4_7580_4ece_1871_cc4c24347da5
  3379c942_1165_5976_785f_f5bd93722788["testStreamCrcError()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 3379c942_1165_5976_785f_f5bd93722788
  434a964d_0b73_348d_6c3c_2e298b0711a8["testIncorrectHuffmanGroupsNumber()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 434a964d_0b73_348d_6c3c_2e298b0711a8
  121ee5d2_38c9_e31e_e91d_11a3480226fb["testIncorrectSelectorsNumber()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 121ee5d2_38c9_e31e_e91d_11a3480226fb
  95403a00_6bc1_88b0_7b58_a394b3d64227["testBlockCrcError()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 95403a00_6bc1_88b0_7b58_a394b3d64227
  155a58e3_bedb_c680_1990_785c68539890["testStartPointerInvalid()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 155a58e3_bedb_c680_1990_785c68539890
  0dde75d1_dce9_b970_b363_1fe5a9c1285f["compress()"]
  53eb2ef4_6844_0384_3483_6c7a17c214e0 -->|method| 0dde75d1_dce9_b970_b363_1fe5a9c1285f

Relationship Graph

Source Code

codec-compression/src/test/java/io/netty/handler/codec/compression/Bzip2DecoderTest.java lines 32–200

public class Bzip2DecoderTest extends AbstractDecoderTest {

    private static final byte[] DATA = { 0x42, 0x5A, 0x68, 0x37, 0x31, 0x41, 0x59, 0x26, 0x53,
                                         0x59, 0x77, 0x7B, (byte) 0xCA, (byte) 0xC0, 0x00, 0x00,
                                         0x00, 0x05, (byte) 0x80, 0x00, 0x01, 0x02, 0x00, 0x04,
                                         0x20, 0x20, 0x00, 0x30, (byte) 0xCD, 0x34, 0x19, (byte) 0xA6,
                                         (byte) 0x89, (byte) 0x99, (byte) 0xC5, (byte) 0xDC, (byte) 0x91,
                                         0x4E, 0x14, 0x24, 0x1D, (byte) 0xDE, (byte) 0xF2, (byte) 0xB0, 0x00 };

    public Bzip2DecoderTest() throws Exception {
    }

    @Override
    protected EmbeddedChannel createChannel() {
        return new EmbeddedChannel(new Bzip2Decoder());
    }

    private void writeInboundDestroyAndExpectDecompressionException(ByteBuf in) {
        try {
            channel.writeInbound(in);
        } finally {
            try {
                destroyChannel();
                fail();
            } catch (DecompressionException ignored) {
                // expected
            }
        }
    }

    @Test
    public void testUnexpectedStreamIdentifier() {
        final ByteBuf in = Unpooled.buffer();
        in.writeLong(1823080128301928729L); //random value
        assertThrows(DecompressionException.class, new Executable() {
            @Override
            public void execute() {
                writeInboundDestroyAndExpectDecompressionException(in);
            }
        }, "Unexpected stream identifier contents");
    }

    @Test
    public void testInvalidBlockSize() {
        final ByteBuf in = Unpooled.buffer();
        in.writeMedium(MAGIC_NUMBER);
        in.writeByte('0');  //incorrect block size

        assertThrows(DecompressionException.class, new Executable() {
            @Override
            public void execute() {
                channel.writeInbound(in);
            }
        }, "block size is invalid");
    }

    @Test
    public void testBadBlockHeader() {
        final ByteBuf in = Unpooled.buffer();
        in.writeMedium(MAGIC_NUMBER);
        in.writeByte('1');  //block size
        in.writeMedium(11); //incorrect block header
        in.writeMedium(11); //incorrect block header
        in.writeInt(11111); //block CRC

        assertThrows(DecompressionException.class, new Executable() {
            @Override
            public void execute() {
                channel.writeInbound(in);
            }
        }, "bad block header");
    }

    @Test
    public void testStreamCrcErrorOfEmptyBlock() {
        final ByteBuf in = Unpooled.buffer();
        in.writeMedium(MAGIC_NUMBER);
        in.writeByte('1');  //block size
        in.writeMedium(END_OF_STREAM_MAGIC_1);
        in.writeMedium(END_OF_STREAM_MAGIC_2);
        in.writeInt(1);  //wrong storedCombinedCRC

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free