Home / Class/ SslHandlerCoalescingBufferQueueTest Class — netty Architecture

SslHandlerCoalescingBufferQueueTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  cbda5f3b_9544_c17d_ad05_932a55411e49["SslHandlerCoalescingBufferQueueTest"]
  91f6ae8f_2bae_f77c_970c_844118679dc6["SslHandlerCoalescingBufferQueueTest.java"]
  cbda5f3b_9544_c17d_ad05_932a55411e49 -->|defined in| 91f6ae8f_2bae_f77c_970c_844118679dc6
  f6b266ba_b7d1_5781_d3e9_d62b6ee0f753["ByteBuffer()"]
  cbda5f3b_9544_c17d_ad05_932a55411e49 -->|method| f6b266ba_b7d1_5781_d3e9_d62b6ee0f753
  b8c02a7b_e945_ad08_c4fa_749b8952dcd9["testCumulation()"]
  cbda5f3b_9544_c17d_ad05_932a55411e49 -->|method| b8c02a7b_e945_ad08_c4fa_749b8952dcd9

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueueTest.java lines 34–134

public class SslHandlerCoalescingBufferQueueTest {
    static final Supplier<ByteBuf> BYTEBUF_SUPPLIER = new Supplier<ByteBuf>() {
        @Override
        public ByteBuf get() {
            ByteBuf buf = Unpooled.directBuffer(128);
            buf.writeLong(1);
            buf.writeLong(2);
            return buf;
        }
    };
    static final Function<ByteBuf, ByteBuf> NO_WRAPPER = new Function<ByteBuf, ByteBuf>() {
        @Override
        public ByteBuf apply(ByteBuf byteBuf) {
            return byteBuf;
        }
    };
    static final Function<ByteBuf, ByteBuf> DUPLICATE_WRAPPER = new Function<ByteBuf, ByteBuf>() {
        @Override
        public ByteBuf apply(ByteBuf byteBuf) {
            return byteBuf.duplicate();
        }
    };
    static final Function<ByteBuf, ByteBuf> SLICE_WRAPPER = new Function<ByteBuf, ByteBuf>() {
        @Override
        public ByteBuf apply(ByteBuf byteBuf) {
            return byteBuf.slice();
        }
    };
    static ByteBuffer createNioBuffer() {
        ByteBuffer nioBuffer = ByteBuffer.allocateDirect(128);
        nioBuffer.putLong(1);
        nioBuffer.putLong(2);
        nioBuffer.position(nioBuffer.limit());
        nioBuffer.flip();
        return nioBuffer;
    }

    enum CumulationTestScenario {
        BASIC_NIO_BUFFER(new Supplier() {
            @Override
            public ByteBuf get() {
                return Unpooled.wrappedBuffer(createNioBuffer());
            }
        }, NO_WRAPPER),
        READ_ONLY_AND_DUPLICATE_NIO_BUFFER(new Supplier() {
            @Override
            public ByteBuf get() {
                return Unpooled.wrappedBuffer(createNioBuffer().asReadOnlyBuffer());
            }
        }, DUPLICATE_WRAPPER),
        BASIC_DIRECT_BUFFER(BYTEBUF_SUPPLIER, NO_WRAPPER),
        DUPLICATE_DIRECT_BUFFER(BYTEBUF_SUPPLIER, DUPLICATE_WRAPPER),
        SLICED_DIRECT_BUFFER(BYTEBUF_SUPPLIER, SLICE_WRAPPER);

        final Supplier<ByteBuf> bufferSupplier;
        final Function<ByteBuf, ByteBuf> bufferWrapper;

        CumulationTestScenario(Supplier<ByteBuf> bufferSupplier, Function<ByteBuf, ByteBuf> bufferWrapper) {
            this.bufferSupplier = bufferSupplier;
            this.bufferWrapper = bufferWrapper;
        }
    }

    @ParameterizedTest
    @EnumSource(CumulationTestScenario.class)
    public void testCumulation(CumulationTestScenario testScenario) {
        EmbeddedChannel channel = new EmbeddedChannel();
        SslHandlerCoalescingBufferQueue queue = new SslHandlerCoalescingBufferQueue(channel, 16, false) {
            @Override
            protected int wrapDataSize() {
                return 128;
            }
        };

        ByteBuf original = testScenario.bufferSupplier.get();
        original.writerIndex(8);
        ByteBuf first = testScenario.bufferWrapper.apply(original);
        first.retain();
        queue.add(first);
        ByteBuf second = Unpooled.copyLong(3);
        queue.add(second);

Frequently Asked Questions

What is the SslHandlerCoalescingBufferQueueTest class?
SslHandlerCoalescingBufferQueueTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueueTest.java.
Where is SslHandlerCoalescingBufferQueueTest defined?
SslHandlerCoalescingBufferQueueTest is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueueTest.java at line 34.

Analyze Your Own Codebase

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

Try Supermodel Free