testFlowAutoReadOffAndQueueNonEmpty() — netty Function Reference
Architecture documentation for the testFlowAutoReadOffAndQueueNonEmpty() function in FlowControlHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 03b48e3d_7d8f_f0b5_3ae1_2291323b2303["testFlowAutoReadOffAndQueueNonEmpty()"] 403e241f_d76e_484e_d952_7f7a46681916["FlowControlHandlerTest"] 03b48e3d_7d8f_f0b5_3ae1_2291323b2303 -->|defined in| 403e241f_d76e_484e_d952_7f7a46681916 style 03b48e3d_7d8f_f0b5_3ae1_2291323b2303 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java lines 417–482
@Test
public void testFlowAutoReadOffAndQueueNonEmpty() throws Exception {
final Exchanger<Channel> peerRef = new Exchanger<Channel>();
final CountDownLatch msgRcvLatch1 = new CountDownLatch(1);
final CountDownLatch msgRcvLatch2 = new CountDownLatch(2);
final CountDownLatch msgRcvLatch3 = new CountDownLatch(3);
ChannelInboundHandlerAdapter handler = new ChannelDuplexHandler() {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
ctx.fireChannelActive();
peerRef.exchange(ctx.channel(), 1L, SECONDS);
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
msgRcvLatch1.countDown();
msgRcvLatch2.countDown();
msgRcvLatch3.countDown();
}
};
final FlowControlHandler flow = new FlowControlHandler();
Channel server = newServer(false, flow, handler);
Channel client = newClient(server.localAddress());
try {
// The client connection on the server side
Channel peer = peerRef.exchange(null, 1L, SECONDS);
// Write the first message
client.writeAndFlush(newOneMessage())
.syncUninterruptibly();
// channelRead(1)
peer.read();
assertTrue(msgRcvLatch1.await(1L, SECONDS));
assertFalse(peer.eventLoop().submit(new Callable<Boolean>() {
@Override
public Boolean call() {
return flow.isQueueEmpty();
}
}).get());
// Write the second message
client.writeAndFlush(newOneMessage())
.syncUninterruptibly();
// channelRead(2)
peer.read();
assertTrue(msgRcvLatch2.await(1L, SECONDS));
// channelRead(3)
peer.read();
assertTrue(msgRcvLatch3.await(1L, SECONDS));
assertTrue(peer.eventLoop().submit(new Callable<Boolean>() {
@Override
public Boolean call() {
return flow.isQueueEmpty();
}
}).get());
} finally {
client.close();
server.close();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testFlowAutoReadOffAndQueueNonEmpty() do?
testFlowAutoReadOffAndQueueNonEmpty() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java.
Where is testFlowAutoReadOffAndQueueNonEmpty() defined?
testFlowAutoReadOffAndQueueNonEmpty() is defined in handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java at line 417.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free