Home / Class/ DefaultMaxMessagesRecvByteBufAllocatorTest Class — netty Architecture

DefaultMaxMessagesRecvByteBufAllocatorTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  2cef8f8c_3f49_08b7_f2c9_2f7ca3443d75["DefaultMaxMessagesRecvByteBufAllocatorTest"]
  9fa6f140_241e_d363_441b_8c7583b24a33["DefaultMaxMessagesRecvByteBufAllocatorTest.java"]
  2cef8f8c_3f49_08b7_f2c9_2f7ca3443d75 -->|defined in| 9fa6f140_241e_d363_441b_8c7583b24a33
  86045840_7cea_e856_6bfc_46b93d046c18["DefaultMaxMessagesRecvByteBufAllocator()"]
  2cef8f8c_3f49_08b7_f2c9_2f7ca3443d75 -->|method| 86045840_7cea_e856_6bfc_46b93d046c18
  bb582e4a_2fbc_f878_3c14_bedc972a8b78["testRespectReadBytes()"]
  2cef8f8c_3f49_08b7_f2c9_2f7ca3443d75 -->|method| bb582e4a_2fbc_f878_3c14_bedc972a8b78
  f29342dd_2660_b2c2_8ead_9c418a87aee7["testIgnoreReadBytes()"]
  2cef8f8c_3f49_08b7_f2c9_2f7ca3443d75 -->|method| f29342dd_2660_b2c2_8ead_9c418a87aee7

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/DefaultMaxMessagesRecvByteBufAllocatorTest.java lines 24–76

public class DefaultMaxMessagesRecvByteBufAllocatorTest {

    private DefaultMaxMessagesRecvByteBufAllocator newAllocator(boolean ignoreReadBytes) {
        return new DefaultMaxMessagesRecvByteBufAllocator(2, ignoreReadBytes) {
            @Override
            public Handle newHandle() {
                return new MaxMessageHandle() {
                    @Override
                    public int guess() {
                        return 0;
                    }
                };
            }
        };
    }

    @Test
    public void testRespectReadBytes() {
        DefaultMaxMessagesRecvByteBufAllocator allocator = newAllocator(false);
        RecvByteBufAllocator.Handle handle = allocator.newHandle();

        EmbeddedChannel channel = new EmbeddedChannel();
        handle.reset(channel.config());
        handle.incMessagesRead(1);
        assertFalse(handle.continueReading());

        handle.reset(channel.config());
        handle.incMessagesRead(1);
        handle.attemptedBytesRead(1);
        handle.lastBytesRead(1);
        assertTrue(handle.continueReading());
        channel.finish();
    }

    @Test
    public void testIgnoreReadBytes() {
        DefaultMaxMessagesRecvByteBufAllocator allocator = newAllocator(true);
        RecvByteBufAllocator.Handle handle = allocator.newHandle();

        EmbeddedChannel channel = new EmbeddedChannel();
        handle.reset(channel.config());
        handle.incMessagesRead(1);
        assertTrue(handle.continueReading());
        handle.incMessagesRead(1);
        assertFalse(handle.continueReading());

        handle.reset(channel.config());
        handle.attemptedBytesRead(0);
        handle.lastBytesRead(0);
        assertTrue(handle.continueReading());
        channel.finish();
    }
}

Frequently Asked Questions

What is the DefaultMaxMessagesRecvByteBufAllocatorTest class?
DefaultMaxMessagesRecvByteBufAllocatorTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/DefaultMaxMessagesRecvByteBufAllocatorTest.java.
Where is DefaultMaxMessagesRecvByteBufAllocatorTest defined?
DefaultMaxMessagesRecvByteBufAllocatorTest is defined in transport/src/test/java/io/netty/channel/DefaultMaxMessagesRecvByteBufAllocatorTest.java at line 24.

Analyze Your Own Codebase

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

Try Supermodel Free