FlushConsolidationHandlerTest Class — netty Architecture
Architecture documentation for the FlushConsolidationHandlerTest class in FlushConsolidationHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca["FlushConsolidationHandlerTest"] 061d59a3_ae9b_cb1d_e31e_93fbecda93e8["FlushConsolidationHandlerTest.java"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|defined in| 061d59a3_ae9b_cb1d_e31e_93fbecda93e8 fd0495b5_137d_6572_7555_696ba8028310["testFlushViaScheduledTask()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| fd0495b5_137d_6572_7555_696ba8028310 9430bfb5_c2ef_b88c_20b9_d6035fe66a3e["testFlushViaThresholdOutsideOfReadLoop()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| 9430bfb5_c2ef_b88c_20b9_d6035fe66a3e 20c6d826_2e57_3310_6c08_7f00437a6528["testImmediateFlushOutsideOfReadLoop()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| 20c6d826_2e57_3310_6c08_7f00437a6528 e91e336e_4543_0051_f542_1750fb9b48c8["testFlushViaReadComplete()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| e91e336e_4543_0051_f542_1750fb9b48c8 92afe5ef_3a60_afc5_d62c_2ade58312e7e["testFlushViaClose()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| 92afe5ef_3a60_afc5_d62c_2ade58312e7e c49dd2bb_cf5b_d504_5daf_9c35dbd80cf4["testFlushViaDisconnect()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| c49dd2bb_cf5b_d504_5daf_9c35dbd80cf4 efffcf56_bf5b_c584_db01_c76d7f710212["testFlushViaException()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| efffcf56_bf5b_c584_db01_c76d7f710212 34682832_be99_da23_3897_b75d4a04ad3f["testFlushViaRemoval()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| 34682832_be99_da23_3897_b75d4a04ad3f 93e5d667_3958_1a09_367a_c785c592a73f["testResend()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| 93e5d667_3958_1a09_367a_c785c592a73f 62fc1ef5_5ea5_e8d0_1179_f609de9d9d52["EmbeddedChannel()"] 4ef52a0d_d145_a738_5ebe_4e1ee02cb2ca -->|method| 62fc1ef5_5ea5_e8d0_1179_f609de9d9d52
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java lines 32–198
public class FlushConsolidationHandlerTest {
private static final int EXPLICIT_FLUSH_AFTER_FLUSHES = 3;
@Test
public void testFlushViaScheduledTask() {
final AtomicInteger flushCount = new AtomicInteger();
EmbeddedChannel channel = newChannel(flushCount, true);
// Flushes should not go through immediately, as they're scheduled as an async task
// To ensure we not run the async task directly we will call trigger the flush() via the pipeline.
channel.pipeline().flush();
assertEquals(0, flushCount.get());
channel.pipeline().flush();
assertEquals(0, flushCount.get());
// Trigger the execution of the async task
channel.runPendingTasks();
assertEquals(1, flushCount.get());
assertFalse(channel.finish());
}
@Test
public void testFlushViaThresholdOutsideOfReadLoop() {
final AtomicInteger flushCount = new AtomicInteger();
EmbeddedChannel channel = newChannel(flushCount, true);
// After a given threshold, the async task should be bypassed and a flush should be triggered immediately
for (int i = 0; i < EXPLICIT_FLUSH_AFTER_FLUSHES; i++) {
// To ensure we not run the async task directly we will call trigger the flush() via the pipeline.
channel.pipeline().flush();
}
assertEquals(1, flushCount.get());
assertFalse(channel.finish());
}
@Test
public void testImmediateFlushOutsideOfReadLoop() {
final AtomicInteger flushCount = new AtomicInteger();
EmbeddedChannel channel = newChannel(flushCount, false);
channel.flush();
assertEquals(1, flushCount.get());
assertFalse(channel.finish());
}
@Test
public void testFlushViaReadComplete() {
final AtomicInteger flushCount = new AtomicInteger();
EmbeddedChannel channel = newChannel(flushCount, false);
// Flush should go through as there is no read loop in progress.
channel.flush();
channel.runPendingTasks();
assertEquals(1, flushCount.get());
// Simulate read loop;
channel.pipeline().fireChannelRead(1L);
assertEquals(1, flushCount.get());
channel.pipeline().fireChannelRead(2L);
assertEquals(1, flushCount.get());
assertNull(channel.readOutbound());
channel.pipeline().fireChannelReadComplete();
assertEquals(2, flushCount.get());
// Now flush again as the read loop is complete.
channel.flush();
channel.runPendingTasks();
assertEquals(3, flushCount.get());
assertEquals(1L, (Long) channel.readOutbound());
assertEquals(2L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertFalse(channel.finish());
}
@Test
public void testFlushViaClose() {
final AtomicInteger flushCount = new AtomicInteger();
EmbeddedChannel channel = newChannel(flushCount, false);
// Simulate read loop;
channel.pipeline().fireChannelRead(1L);
assertEquals(0, flushCount.get());
assertNull(channel.readOutbound());
channel.close();
assertEquals(1, flushCount.get());
assertEquals(1L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
Source
Frequently Asked Questions
What is the FlushConsolidationHandlerTest class?
FlushConsolidationHandlerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java.
Where is FlushConsolidationHandlerTest defined?
FlushConsolidationHandlerTest is defined in handler/src/test/java/io/netty/handler/flush/FlushConsolidationHandlerTest.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free