Home / Class/ ByteBufAllocatorTest Class — netty Architecture

ByteBufAllocatorTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  3cc9daee_2715_234c_b001_1844c82c3337["ByteBufAllocatorTest"]
  64714d36_94b9_3662_e2c0_dd73d4bc26ef["ByteBufAllocatorTest.java"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|defined in| 64714d36_94b9_3662_e2c0_dd73d4bc26ef
  4f777ecc_af85_0654_5885_6a706f779e90["defaultMaxCapacity()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 4f777ecc_af85_0654_5885_6a706f779e90
  e46a5c30_f3f3_e0a0_66ff_767bd496e5a6["defaultMaxComponents()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| e46a5c30_f3f3_e0a0_66ff_767bd496e5a6
  8cac70f1_b9f6_0dd8_c8cf_2a05819fce9d["ByteBufAllocator()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 8cac70f1_b9f6_0dd8_c8cf_2a05819fce9d
  8ed027df_2939_7a88_e43b_62f230867e40["testBuffer()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 8ed027df_2939_7a88_e43b_62f230867e40
  7446b9a2_40e9_1297_9843_1630d7880dc5["testBufferWithCapacity()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 7446b9a2_40e9_1297_9843_1630d7880dc5
  dcc288b7_6cba_634f_f1ff_8f87e4d7b700["isDirectExpected()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| dcc288b7_6cba_634f_f1ff_8f87e4d7b700
  33101b9b_bfac_ff0c_756b_050c493c3c7b["testHeapBuffer()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 33101b9b_bfac_ff0c_756b_050c493c3c7b
  3a8ada96_d5ee_61b2_3ae1_b94d9e956155["testHeapBufferMaxCapacity()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 3a8ada96_d5ee_61b2_3ae1_b94d9e956155
  7cc65138_a647_ac75_3bd6_27162e809d2d["testDirectBuffer()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 7cc65138_a647_ac75_3bd6_27162e809d2d
  315f590e_dcf1_dac3_9ec8_d2cbc42ca2db["testDirectBufferMaxCapacity()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 315f590e_dcf1_dac3_9ec8_d2cbc42ca2db
  ce478843_fbd8_60bd_dd27_b3017373f4fa["testCompositeBuffer()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| ce478843_fbd8_60bd_dd27_b3017373f4fa
  108fe524_038a_41b8_008c_7edbf9495917["testCompositeBufferWithCapacity()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 108fe524_038a_41b8_008c_7edbf9495917
  12e53db5_f812_4fb3_5611_e11bf59f9c12["testCompositeHeapBuffer()"]
  3cc9daee_2715_234c_b001_1844c82c3337 -->|method| 12e53db5_f812_4fb3_5611_e11bf59f9c12

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/ByteBufAllocatorTest.java lines 22–227

public abstract class ByteBufAllocatorTest {

    protected abstract int defaultMaxCapacity();

    protected abstract int defaultMaxComponents();

    protected abstract ByteBufAllocator newAllocator(boolean preferDirect);

    @Test
    public void testBuffer() {
        testBuffer(true);
        testBuffer(false);
    }

    private void testBuffer(boolean preferDirect) {
        ByteBufAllocator allocator = newAllocator(preferDirect);
        ByteBuf buffer = allocator.buffer(1);
        try {
            assertBuffer(buffer, isDirectExpected(preferDirect), 1, defaultMaxCapacity());
        } finally {
            buffer.release();
        }
    }

    @Test
    public void testBufferWithCapacity() {
        testBufferWithCapacity(true, 8);
        testBufferWithCapacity(false, 8);
    }

    private void testBufferWithCapacity(boolean preferDirect, int maxCapacity) {
        ByteBufAllocator allocator = newAllocator(preferDirect);
        ByteBuf buffer = allocator.buffer(1, maxCapacity);
        try {
            assertBuffer(buffer, isDirectExpected(preferDirect), 1, maxCapacity);
        } finally {
            buffer.release();
        }
    }

    protected abstract boolean isDirectExpected(boolean preferDirect);

    @Test
    public void testHeapBuffer() {
        testHeapBuffer(true);
        testHeapBuffer(false);
    }

    private void testHeapBuffer(boolean preferDirect) {
        ByteBufAllocator allocator = newAllocator(preferDirect);
        ByteBuf buffer = allocator.heapBuffer(1);
        try {
            assertBuffer(buffer, false, 1, defaultMaxCapacity());
        } finally {
            buffer.release();
        }
    }

    @Test
    public void testHeapBufferMaxCapacity() {
        testHeapBuffer(true, 8);
        testHeapBuffer(false, 8);
    }

    private void testHeapBuffer(boolean preferDirect, int maxCapacity) {
        ByteBufAllocator allocator = newAllocator(preferDirect);
        ByteBuf buffer = allocator.heapBuffer(1, maxCapacity);
        try {
            assertBuffer(buffer, false, 1, maxCapacity);
        } finally {
            buffer.release();
        }
    }

    @Test
    public void testDirectBuffer() {
        testDirectBuffer(true);
        testDirectBuffer(false);
    }

    private void testDirectBuffer(boolean preferDirect) {

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free