Home / Class/ AbstractDecoderTest Class — netty Architecture

AbstractDecoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  25e203a2_01b9_37bc_50d7_94995af16578["AbstractDecoderTest"]
  cea1c6fa_8c6c_5b61_3a92_ea6b94e7c175["AbstractDecoderTest.java"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|defined in| cea1c6fa_8c6c_5b61_3a92_ea6b94e7c175
  7b7aa727_3ed2_c7c5_6701_7c7aa66f573f["AbstractDecoderTest()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 7b7aa727_3ed2_c7c5_6701_7c7aa66f573f
  c95260f1_6420_c131_6cc0_39e8fbc090f9["compress()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| c95260f1_6420_c131_6cc0_39e8fbc090f9
  d77d77c7_258d_9a4c_fc1a_31c1838db3d5["initChannel()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| d77d77c7_258d_9a4c_fc1a_31c1838db3d5
  0dac9b7b_5c29_dfdd_6e10_1ae414879f68["EmbeddedChannel()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 0dac9b7b_5c29_dfdd_6e10_1ae414879f68
  124b515f_7300_4f2c_d9a3_a8bd06b50d6f["destroyChannel()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 124b515f_7300_4f2c_d9a3_a8bd06b50d6f
  b8ba4a04_d7c9_db83_1cf6_6a061f853629["smallData()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| b8ba4a04_d7c9_db83_1cf6_6a061f853629
  de38535d_e860_18b5_9d37_8ef489ef8f53["largeData()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| de38535d_e860_18b5_9d37_8ef489ef8f53
  0681e59b_dc21_17bf_0f58_2e140e0f5693["testDecompressionOfSmallChunkOfData()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 0681e59b_dc21_17bf_0f58_2e140e0f5693
  0ee28aff_3d0d_990e_5746_11fb87c5ca4b["testDecompressionOfLargeChunkOfData()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 0ee28aff_3d0d_990e_5746_11fb87c5ca4b
  44560637_672b_b3de_28bb_1dda4766bb4d["testDecompressionOfBatchedFlowOfData()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 44560637_672b_b3de_28bb_1dda4766bb4d
  2f5e8b12_4d9b_76ae_7db3_82922b79cd9f["testDecompression()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 2f5e8b12_4d9b_76ae_7db3_82922b79cd9f
  9a307e55_9d85_9611_81bd_aef9251f6f57["testDecompressionOfBatchedFlow()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 9a307e55_9d85_9611_81bd_aef9251f6f57
  140f82a2_f128_cffc_9bd1_e5c6be608ffe["ByteBuf()"]
  25e203a2_01b9_37bc_50d7_94995af16578 -->|method| 140f82a2_f128_cffc_9bd1_e5c6be608ffe

Relationship Graph

Source Code

codec-compression/src/test/java/io/netty/handler/codec/compression/AbstractDecoderTest.java lines 31–152

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractDecoderTest extends AbstractCompressionTest {

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

    protected EmbeddedChannel channel;

    protected byte[] compressedBytesSmall;
    protected byte[] compressedBytesLarge;

    protected AbstractDecoderTest() throws Exception {
        compressedBytesSmall = compress(BYTES_SMALL);
        compressedBytesLarge = compress(BYTES_LARGE);
    }

    /**
     * Compresses data with some external library.
     */
    protected abstract byte[] compress(byte[] data) throws Exception;

    @BeforeEach
    public final void initChannel() {
        channel = createChannel();
    }

    protected abstract EmbeddedChannel createChannel();

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

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

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

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

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

    @ParameterizedTest
    @MethodSource("largeData")
    public void testDecompressionOfBatchedFlowOfData(ByteBuf data) throws Exception {
        testDecompressionOfBatchedFlow(WRAPPED_BYTES_LARGE.duplicate(), data);
    }

    protected void testDecompression(final ByteBuf expected, final ByteBuf data) throws Exception {
        assertTrue(channel.writeInbound(data));

        ByteBuf decompressed = readDecompressed(channel);
        assertEquals(expected, decompressed);

        decompressed.release();
    }

    protected void testDecompressionOfBatchedFlow(final ByteBuf expected, final ByteBuf data) throws Exception {
        final int compressedLength = data.readableBytes();

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free