AbstractCoalescingBufferQueueTest Class — netty Architecture
Architecture documentation for the AbstractCoalescingBufferQueueTest class in AbstractCoalescingBufferQueueTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 04c5cf5a_e41c_5ef0_e696_3df84d28c281["AbstractCoalescingBufferQueueTest"] d0617f65_88fd_4294_4ec2_827348fa91e0["AbstractCoalescingBufferQueueTest.java"] 04c5cf5a_e41c_5ef0_e696_3df84d28c281 -->|defined in| d0617f65_88fd_4294_4ec2_827348fa91e0 78ff0ed8_02d0_884e_e9c4_964df406255c["testDecrementAllWhenWriteAndRemoveAll()"] 04c5cf5a_e41c_5ef0_e696_3df84d28c281 -->|method| 78ff0ed8_02d0_884e_e9c4_964df406255c 4ed2dac9_51df_9755_cfc8_964a9f46f877["testDecrementAllWhenReleaseAndFailAll()"] 04c5cf5a_e41c_5ef0_e696_3df84d28c281 -->|method| 4ed2dac9_51df_9755_cfc8_964a9f46f877 be0c57a7_d648_f65b_e025_0b3541757811["testDecrementAll()"] 04c5cf5a_e41c_5ef0_e696_3df84d28c281 -->|method| be0c57a7_d648_f65b_e025_0b3541757811 e8f78f2e_4b4a_c73b_413e_84c55f93213f["testKeepStateConsistentOnError()"] 04c5cf5a_e41c_5ef0_e696_3df84d28c281 -->|method| e8f78f2e_4b4a_c73b_413e_84c55f93213f
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/AbstractCoalescingBufferQueueTest.java lines 35–154
public class AbstractCoalescingBufferQueueTest {
// See https://github.com/netty/netty/issues/10286
@Test
public void testDecrementAllWhenWriteAndRemoveAll() {
testDecrementAll(true);
}
// See https://github.com/netty/netty/issues/10286
@Test
public void testDecrementAllWhenReleaseAndFailAll() {
testDecrementAll(false);
}
private static void testDecrementAll(boolean write) {
EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
ReferenceCountUtil.release(msg);
promise.setSuccess();
}
}, new ChannelHandlerAdapter() { });
final AbstractCoalescingBufferQueue queue = new AbstractCoalescingBufferQueue(channel, 128) {
@Override
protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) {
return composeIntoComposite(alloc, cumulation, next);
}
@Override
protected ByteBuf removeEmptyValue() {
return Unpooled.EMPTY_BUFFER;
}
};
final byte[] bytes = new byte[128];
queue.add(Unpooled.wrappedBuffer(bytes), future -> {
queue.add(Unpooled.wrappedBuffer(bytes));
assertEquals(bytes.length, queue.readableBytes());
});
assertEquals(bytes.length, queue.readableBytes());
ChannelHandlerContext ctx = channel.pipeline().lastContext();
if (write) {
queue.writeAndRemoveAll(ctx);
} else {
queue.releaseAndFailAll(ctx, new ClosedChannelException());
}
ByteBuf buffer = queue.remove(channel.alloc(), 128, channel.newPromise());
assertFalse(buffer.isReadable());
buffer.release();
assertTrue(queue.isEmpty());
assertEquals(0, queue.readableBytes());
assertFalse(channel.finish());
}
@Test
public void testKeepStateConsistentOnError() {
final IllegalReferenceCountException exception = new IllegalReferenceCountException();
final EmbeddedChannel channel = new EmbeddedChannel();
final AbstractCoalescingBufferQueue queue = new AbstractCoalescingBufferQueue(channel, 128) {
@Override
protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next) {
// Simulate throwing an IllegalReferenceCountException.
throw exception;
}
@Override
protected ByteBuf composeFirst(ByteBufAllocator allocator, ByteBuf first, int bufferSize) {
// Simulate throwing an IllegalReferenceCountException.
throw exception;
}
@Override
protected ByteBuf removeEmptyValue() {
return Unpooled.EMPTY_BUFFER;
}
};
Source
Frequently Asked Questions
What is the AbstractCoalescingBufferQueueTest class?
AbstractCoalescingBufferQueueTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/AbstractCoalescingBufferQueueTest.java.
Where is AbstractCoalescingBufferQueueTest defined?
AbstractCoalescingBufferQueueTest is defined in transport/src/test/java/io/netty/channel/AbstractCoalescingBufferQueueTest.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free