Home / Class/ BrotliDecoderTest Class — netty Architecture

BrotliDecoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  63f55b46_4f95_0492_5bc8_569080fc26cd["BrotliDecoderTest"]
  d07400ea_462c_128c_9d54_7346d06dda75["BrotliDecoderTest.java"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|defined in| d07400ea_462c_128c_9d54_7346d06dda75
  25995d7b_b926_e532_50be_5c4469f5a587["setUp()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 25995d7b_b926_e532_50be_5c4469f5a587
  b1564547_5340_46b2_edf0_ed67e8e16952["fillArrayWithCompressibleData()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| b1564547_5340_46b2_edf0_ed67e8e16952
  5b9f4bf0_624a_cfd9_dfd5_a17f547d3c9b["compress()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 5b9f4bf0_624a_cfd9_dfd5_a17f547d3c9b
  52b38629_f579_abe2_34a1_c9dc719cf4e6["initChannel()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 52b38629_f579_abe2_34a1_c9dc719cf4e6
  94955683_e7e0_746a_3d1d_164ab46db820["destroyChannel()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 94955683_e7e0_746a_3d1d_164ab46db820
  6a95d9f8_8a4b_0bad_151b_0361cb6048b3["smallData()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 6a95d9f8_8a4b_0bad_151b_0361cb6048b3
  82fa0a12_14c8_0772_2831_e826e1ffedbc["largeData()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 82fa0a12_14c8_0772_2831_e826e1ffedbc
  f947ac88_28c3_3642_fb59_ec0f2e6c72bf["testDecompressionOfSmallChunkOfData()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| f947ac88_28c3_3642_fb59_ec0f2e6c72bf
  3ab89e7a_a924_9c0d_2505_2ddcf3100bc2["testDecompressionOfLargeChunkOfData()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 3ab89e7a_a924_9c0d_2505_2ddcf3100bc2
  0238edf1_c515_37bf_6bab_ff694f8edaec["testDecompressionOfBatchedFlowOfData()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 0238edf1_c515_37bf_6bab_ff694f8edaec
  b4524d09_49ab_d052_f6f6_61f736d2c78a["testDecompression()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| b4524d09_49ab_d052_f6f6_61f736d2c78a
  b2407867_eb57_474b_c57e_f79e082129bf["testDecompressionOfBatchedFlow()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| b2407867_eb57_474b_c57e_f79e082129bf
  7102a9ca_f9bc_c021_f392_1fb666ac7276["ByteBuf()"]
  63f55b46_4f95_0492_5bc8_569080fc26cd -->|method| 7102a9ca_f9bc_c021_f392_1fb666ac7276

Relationship Graph

Source Code

codec-compression/src/test/java/io/netty/handler/codec/compression/BrotliDecoderTest.java lines 37–162

public class BrotliDecoderTest {

    private static Random RANDOM;
    private static final byte[] BYTES_SMALL = new byte[256];
    private static final byte[] BYTES_LARGE = new byte[256 * 1024];
    private static byte[] COMPRESSED_BYTES_SMALL;
    private static byte[] COMPRESSED_BYTES_LARGE;

    @BeforeAll
    static void setUp() {
        try {
            Brotli.ensureAvailability();

            RANDOM = new Random();
            fillArrayWithCompressibleData(BYTES_SMALL);
            fillArrayWithCompressibleData(BYTES_LARGE);
            COMPRESSED_BYTES_SMALL = compress(BYTES_SMALL);
            COMPRESSED_BYTES_LARGE = compress(BYTES_LARGE);
        } catch (Throwable throwable) {
            throw new ExceptionInInitializerError(throwable);
        }
    }

    private static final ByteBuf WRAPPED_BYTES_SMALL = Unpooled.unreleasableBuffer(
            Unpooled.wrappedBuffer(BYTES_SMALL)).asReadOnly();
    private static final ByteBuf WRAPPED_BYTES_LARGE = Unpooled.unreleasableBuffer(
            Unpooled.wrappedBuffer(BYTES_LARGE)).asReadOnly();

    private static void fillArrayWithCompressibleData(byte[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i % 4 != 0 ? 0 : (byte) RANDOM.nextInt();
        }
    }

    private static byte[] compress(byte[] data) throws IOException {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        BrotliOutputStream brotliOs = new BrotliOutputStream(os);
        brotliOs.write(data);
        brotliOs.close();
        return os.toByteArray();
    }

    private EmbeddedChannel channel;

    @BeforeEach
    public void initChannel() {
        channel = new EmbeddedChannel(new BrotliDecoder());
    }

    @AfterEach
    public void destroyChannel() {
        if (channel != null) {
            channel.finishAndReleaseAll();
            channel = null;
        }
    }

    public static ByteBuf[] smallData() {
        ByteBuf heap = Unpooled.wrappedBuffer(COMPRESSED_BYTES_SMALL);
        ByteBuf direct = Unpooled.directBuffer(COMPRESSED_BYTES_SMALL.length);
        direct.writeBytes(COMPRESSED_BYTES_SMALL);
        return new ByteBuf[]{heap, direct};
    }

    public static ByteBuf[] largeData() {
        ByteBuf heap = Unpooled.wrappedBuffer(COMPRESSED_BYTES_LARGE);
        ByteBuf direct = Unpooled.directBuffer(COMPRESSED_BYTES_LARGE.length);
        direct.writeBytes(COMPRESSED_BYTES_LARGE);
        return new ByteBuf[]{heap, direct};
    }

    @ParameterizedTest
    @MethodSource("smallData")
    public void testDecompressionOfSmallChunkOfData(ByteBuf data) {
        testDecompression(WRAPPED_BYTES_SMALL.duplicate(), data);
    }

    @ParameterizedTest
    @MethodSource("largeData")
    public void testDecompressionOfLargeChunkOfData(ByteBuf data) {
        testDecompression(WRAPPED_BYTES_LARGE.duplicate(), data);

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free