PendingWriteQueueTest Class — netty Architecture
Architecture documentation for the PendingWriteQueueTest class in PendingWriteQueueTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b4bff24e_be13_7693_4ece_a0ed5ee1a982["PendingWriteQueueTest"] 1a93edc6_89bc_2006_5947_2054d06c6714["PendingWriteQueueTest.java"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|defined in| 1a93edc6_89bc_2006_5947_2054d06c6714 670dbce5_6028_a7d3_d6ca_f69e7325a1c6["testRemoveAndWrite()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 670dbce5_6028_a7d3_d6ca_f69e7325a1c6 79293561_9c85_fea7_f192_1bb0ea764534["testRemoveAndWriteAll()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 79293561_9c85_fea7_f192_1bb0ea764534 da6d76e6_7544_937d_2e9e_ee10dfd26fc8["testRemoveAndFail()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| da6d76e6_7544_937d_2e9e_ee10dfd26fc8 72fc6ad4_24b4_e4a8_af5e_0dafe04e828a["testRemoveAndFailAll()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 72fc6ad4_24b4_e4a8_af5e_0dafe04e828a 534b3014_fb43_b7da_6519_934d27b7ca9d["shouldFireChannelWritabilityChangedAfterRemoval()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 534b3014_fb43_b7da_6519_934d27b7ca9d 03c20eb8_620c_93ca_7117_43063817f243["assertWrite()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 03c20eb8_620c_93ca_7117_43063817f243 d81e3b1b_3185_0adf_e076_0dc60aa05678["assertBuffer()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| d81e3b1b_3185_0adf_e076_0dc60aa05678 ae83f057_ec09_c91a_1fe2_4c222d04aff0["assertQueueEmpty()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| ae83f057_ec09_c91a_1fe2_4c222d04aff0 a15cb8aa_da0e_04bd_0ac5_a8d7aa185f5d["assertWriteFails()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| a15cb8aa_da0e_04bd_0ac5_a8d7aa185f5d 21f29e3d_6bf2_8663_b27c_0cf9f480f48f["EmbeddedChannel()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 21f29e3d_6bf2_8663_b27c_0cf9f480f48f fe9b4976_fdd0_845c_b783_f3f9e7c11856["testRemoveAndFailAllReentrantFailAll()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| fe9b4976_fdd0_845c_b783_f3f9e7c11856 72b4c857_fb50_5de1_b53e_25cdc844e21a["testRemoveAndWriteAllReentrantWrite()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| 72b4c857_fb50_5de1_b53e_25cdc844e21a f36830e1_bcb2_871a_c18b_a197da46a0bf["testRemoveAndWriteAllWithVoidPromise()"] b4bff24e_be13_7693_4ece_a0ed5ee1a982 -->|method| f36830e1_bcb2_871a_c18b_a197da46a0bf
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java lines 39–375
public class PendingWriteQueueTest {
@Test
public void testRemoveAndWrite() {
assertWrite(new TestHandler() {
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
assertFalse(ctx.channel().isWritable(), "Should not be writable anymore");
ChannelFuture future = queue.removeAndWrite();
future.addListener(f -> assertQueueEmpty(queue));
super.flush(ctx);
}
}, 1);
}
@Test
public void testRemoveAndWriteAll() {
assertWrite(new TestHandler() {
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
assertFalse(ctx.channel().isWritable(), "Should not be writable anymore");
ChannelFuture future = queue.removeAndWriteAll();
future.addListener(f -> assertQueueEmpty(queue));
super.flush(ctx);
}
}, 3);
}
@Test
public void testRemoveAndFail() {
assertWriteFails(new TestHandler() {
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
queue.removeAndFail(new TestException());
super.flush(ctx);
}
}, 1);
}
@Test
public void testRemoveAndFailAll() {
assertWriteFails(new TestHandler() {
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
queue.removeAndFailAll(new TestException());
super.flush(ctx);
}
}, 3);
}
@Test
public void shouldFireChannelWritabilityChangedAfterRemoval() {
final AtomicReference<ChannelHandlerContext> ctxRef = new AtomicReference<ChannelHandlerContext>();
final AtomicReference<PendingWriteQueue> queueRef = new AtomicReference<PendingWriteQueue>();
final ByteBuf msg = Unpooled.copiedBuffer("test", CharsetUtil.US_ASCII);
final EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() {
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
ctxRef.set(ctx);
queueRef.set(new PendingWriteQueue(ctx));
}
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) {
final PendingWriteQueue queue = queueRef.get();
final ByteBuf msg = (ByteBuf) queue.current();
if (msg == null) {
return;
}
assertEquals(1, msg.refCnt());
// This call will trigger another channelWritabilityChanged() event because the number of
// pending bytes will go below the low watermark.
//
// If PendingWriteQueue.remove() did not remove the current entry before triggering
Source
Frequently Asked Questions
What is the PendingWriteQueueTest class?
PendingWriteQueueTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java.
Where is PendingWriteQueueTest defined?
PendingWriteQueueTest is defined in transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java at line 39.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free