FlowControlHandlerTest Class — netty Architecture
Architecture documentation for the FlowControlHandlerTest class in FlowControlHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 403e241f_d76e_484e_d952_7f7a46681916["FlowControlHandlerTest"] 2c2a1f50_bd2c_b8c7_7865_a867706880d1["FlowControlHandlerTest.java"] 403e241f_d76e_484e_d952_7f7a46681916 -->|defined in| 2c2a1f50_bd2c_b8c7_7865_a867706880d1 1565779e_467f_6afa_ff09_ef339194ab79["init()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 1565779e_467f_6afa_ff09_ef339194ab79 b0fddec2_27bc_2595_9ced_221b3d427a00["destroy()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| b0fddec2_27bc_2595_9ced_221b3d427a00 e8d6b4db_4e55_fc99_98b0_42c0ace2cec7["ByteBuf()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| e8d6b4db_4e55_fc99_98b0_42c0ace2cec7 9588d76d_dd46_f9c7_76d2_a24e541f5404["Channel()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 9588d76d_dd46_f9c7_76d2_a24e541f5404 d7863a23_034b_06f5_f7db_9cc2940f46f4["testAutoReadingOn()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| d7863a23_034b_06f5_f7db_9cc2940f46f4 f3ded4f1_1ea7_98f6_e0ca_a2b2889b30f0["testAutoReadingOff()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| f3ded4f1_1ea7_98f6_e0ca_a2b2889b30f0 67efb999_41ee_84e2_9190_da8df9995b0c["testFlowAutoReadOn()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 67efb999_41ee_84e2_9190_da8df9995b0c bf80c7a4_583e_c05f_d976_711f10e17a53["testFlowToggleAutoRead()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| bf80c7a4_583e_c05f_d976_711f10e17a53 2e9ac795_4f0c_756f_5ebc_6967eb807beb["testFlowAutoReadOff()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 2e9ac795_4f0c_756f_5ebc_6967eb807beb 03b48e3d_7d8f_f0b5_3ae1_2291323b2303["testFlowAutoReadOffAndQueueNonEmpty()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 03b48e3d_7d8f_f0b5_3ae1_2291323b2303 451899c7_937e_56fa_b144_0fec1941aaae["testReentranceNotCausesNPE()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 451899c7_937e_56fa_b144_0fec1941aaae 47d3ff98_f2b9_57a7_a1d9_80119e195e65["testSwallowedReadComplete()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 47d3ff98_f2b9_57a7_a1d9_80119e195e65 9b233acd_9531_bef5_56cd_53724366232a["testRemoveFlowControl()"] 403e241f_d76e_484e_d952_7f7a46681916 -->|method| 9b233acd_9531_bef5_56cd_53724366232a
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java lines 61–681
public class FlowControlHandlerTest {
private static EventLoopGroup GROUP;
@BeforeAll
public static void init() {
GROUP = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
}
@AfterAll
public static void destroy() {
GROUP.shutdownGracefully();
}
/**
* The {@link OneByteToThreeStringsDecoder} decodes this {@code byte[]} into three messages.
*/
private static ByteBuf newOneMessage() {
return Unpooled.wrappedBuffer(new byte[]{ 1 });
}
private static Channel newServer(final boolean autoRead, final ChannelHandler... handlers) {
assertTrue(handlers.length >= 1);
ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(GROUP)
.channel(NioServerSocketChannel.class)
.childOption(ChannelOption.AUTO_READ, autoRead)
.childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new OneByteToThreeStringsDecoder());
pipeline.addLast(handlers);
}
});
return serverBootstrap.bind(0)
.syncUninterruptibly()
.channel();
}
private static Channel newClient(SocketAddress server) {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(GROUP)
.channel(NioSocketChannel.class)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000)
.handler(new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
fail("In this test the client is never receiving a message from the server.");
}
});
return bootstrap.connect(server)
.syncUninterruptibly()
.channel();
}
/**
* This test demonstrates the default behavior if auto reading
* is turned on from the get-go and you're trying to turn it off
* once you've received your first message.
*
* NOTE: This test waits for the client to disconnect which is
* interpreted as the signal that all {@code byte}s have been
* transferred to the server.
*/
@Test
public void testAutoReadingOn() throws Exception {
final CountDownLatch latch = new CountDownLatch(3);
ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ReferenceCountUtil.release(msg);
// We're turning off auto reading in the hope that no
// new messages are being sent but that is not true.
ctx.channel().config().setAutoRead(false);
latch.countDown();
Source
Frequently Asked Questions
What is the FlowControlHandlerTest class?
FlowControlHandlerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java.
Where is FlowControlHandlerTest defined?
FlowControlHandlerTest is defined in handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java at line 61.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free