Home / Class/ AbstractByteBufTest Class — netty Architecture

AbstractByteBufTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  6540f2d1_cdad_6705_dd1d_9a24e2e53242["AbstractByteBufTest"]
  53d91bbd_e169_0486_4b8f_b7350f1cb9da["AbstractByteBufTest.java"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|defined in| 53d91bbd_e169_0486_4b8f_b7350f1cb9da
  13b63584_2de2_70b8_a729_8a0082aa6ebb["ByteBuf()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 13b63584_2de2_70b8_a729_8a0082aa6ebb
  2b6460c6_430a_5883_133d_f9b926ce9ad4["discardReadBytesDoesNotMoveWritableBytes()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 2b6460c6_430a_5883_133d_f9b926ce9ad4
  29e879b0_66ee_f3ba_593f_65e5f95634ad["init()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 29e879b0_66ee_f3ba_593f_65e5f95634ad
  ea34e4a6_2aaf_0ac1_b7eb_255ba8c97b09["dispose()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| ea34e4a6_2aaf_0ac1_b7eb_255ba8c97b09
  47237f09_8b5a_0893_f468_9864b80cf2c8["comparableInterfaceNotViolated()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 47237f09_8b5a_0893_f468_9864b80cf2c8
  1d5307a0_c87f_c99f_c59b_65f1053ac403["initialState()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 1d5307a0_c87f_c99f_c59b_65f1053ac403
  af265b6a_4ac8_a19b_7060_34fa9600add7["readerIndexBoundaryCheck1()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| af265b6a_4ac8_a19b_7060_34fa9600add7
  1d3787fe_bdaf_ffd5_e7dd_eab2beff7475["readerIndexBoundaryCheck2()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 1d3787fe_bdaf_ffd5_e7dd_eab2beff7475
  6a299a45_eded_720c_9c6a_0e77c9352f69["readerIndexBoundaryCheck3()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 6a299a45_eded_720c_9c6a_0e77c9352f69
  b069ee4c_4044_e062_e24f_f33d17224f18["readerIndexBoundaryCheck4()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| b069ee4c_4044_e062_e24f_f33d17224f18
  4e00ba7f_647b_cd30_eed0_f8e5c038fc1c["writerIndexBoundaryCheck1()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 4e00ba7f_647b_cd30_eed0_f8e5c038fc1c
  9147feef_1e49_06d9_ae92_086e722c0e7a["writerIndexBoundaryCheck2()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| 9147feef_1e49_06d9_ae92_086e722c0e7a
  dd5b322c_3057_90eb_1bca_44c3e4cd276f["writerIndexBoundaryCheck3()"]
  6540f2d1_cdad_6705_dd1d_9a24e2e53242 -->|method| dd5b322c_3057_90eb_1bca_44c3e4cd276f

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java lines 90–6451

public abstract class AbstractByteBufTest {

    private static final int CAPACITY = 4096; // Must be even
    private static final int BLOCK_SIZE = 128;
    private static final int JAVA_BYTEBUFFER_CONSISTENCY_ITERATIONS = 100;

    private long seed;
    private Random random;
    private ByteBuf buffer;

    protected final ByteBuf newBuffer(int capacity) {
        return newBuffer(capacity, Integer.MAX_VALUE);
    }

    protected abstract ByteBuf newBuffer(int capacity, int maxCapacity);

    protected boolean discardReadBytesDoesNotMoveWritableBytes() {
        return true;
    }

    @BeforeEach
    public void init() {
        buffer = newBuffer(CAPACITY);
        seed = System.currentTimeMillis();
        random = new Random(seed);
    }

    @AfterEach
    public void dispose() {
        if (buffer != null) {
            assertTrue(buffer.release());
            assertEquals(0, buffer.refCnt());

            try {
                buffer.release();
            } catch (Exception e) {
                // Ignore.
            }
            buffer = null;
        }
    }

    @Test
    public void comparableInterfaceNotViolated() {
        assumeFalse(buffer.isReadOnly());
        buffer.writerIndex(buffer.readerIndex());
        assumeTrue(buffer.writableBytes() >= 4);

        buffer.writeLong(0);
        ByteBuf buffer2 = newBuffer(CAPACITY);
        assumeFalse(buffer2.isReadOnly());
        buffer2.writerIndex(buffer2.readerIndex());
        // Write an unsigned integer that will cause buffer.getUnsignedInt() - buffer2.getUnsignedInt() to underflow the
        // int type and wrap around on the negative side.
        buffer2.writeLong(0xF0000000L);
        assertTrue(buffer.compareTo(buffer2) < 0);
        assertTrue(buffer2.compareTo(buffer) > 0);
        buffer2.release();
    }

    @Test
    public void initialState() {
        assertEquals(CAPACITY, buffer.capacity());
        assertEquals(0, buffer.readerIndex());
    }

    @Test
    public void readerIndexBoundaryCheck1() {
        try {
            buffer.writerIndex(0);
        } catch (IndexOutOfBoundsException e) {
            fail();
        }
        assertThrows(IndexOutOfBoundsException.class, new Executable() {
            @Override
            public void execute() {
                buffer.readerIndex(-1);
            }
        });
    }

Frequently Asked Questions

What is the AbstractByteBufTest class?
AbstractByteBufTest is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java.
Where is AbstractByteBufTest defined?
AbstractByteBufTest is defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java at line 90.

Analyze Your Own Codebase

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

Try Supermodel Free