testStatsAreCollected() — netty Function Reference
Architecture documentation for the testStatsAreCollected() function in QuicConnectionStatsTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b156fca5_0a46_0a8f_7ef9_f638a61f7e25["testStatsAreCollected()"] 0860b84f_d0cb_aba0_8368_9cc08dfb6cdc["QuicConnectionStatsTest"] b156fca5_0a46_0a8f_7ef9_f638a61f7e25 -->|defined in| 0860b84f_d0cb_aba0_8368_9cc08dfb6cdc 0c3f61b1_f916_78b8_26f0_b8f4ecb31910["assertStats()"] b156fca5_0a46_0a8f_7ef9_f638a61f7e25 -->|calls| 0c3f61b1_f916_78b8_26f0_b8f4ecb31910 style b156fca5_0a46_0a8f_7ef9_f638a61f7e25 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionStatsTest.java lines 38–131
@ParameterizedTest
@MethodSource("newSslTaskExecutors")
public void testStatsAreCollected(Executor executor) throws Throwable {
Channel server = null;
Channel channel = null;
AtomicInteger counter = new AtomicInteger();
Promise<QuicConnectionStats> serverActiveStats = ImmediateEventExecutor.INSTANCE.newPromise();
Promise<QuicConnectionStats> serverInactiveStats = ImmediateEventExecutor.INSTANCE.newPromise();
QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
super.channelActive(ctx);
collectStats(ctx, serverActiveStats);
}
@Override
public void channelInactive(ChannelHandlerContext ctx) {
collectStats(ctx, serverInactiveStats);
ctx.fireChannelInactive();
}
private void collectStats(ChannelHandlerContext ctx, Promise<QuicConnectionStats> promise) {
QuicheQuicChannel channel = (QuicheQuicChannel) ctx.channel();
channel.collectStats(promise);
}
};
QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
try {
server = QuicTestUtils.newServer(executor, serverHandler, new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
counter.incrementAndGet();
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
// Let's just echo back the message.
ctx.writeAndFlush(msg);
}
@Override
public boolean isSharable() {
return true;
}
});
channel = QuicTestUtils.newClient(executor);
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
.connect().get();
assertNotNull(quicChannel.collectStats().sync().getNow());
quicChannel.createStream(QuicStreamType.BIDIRECTIONAL, new ChannelInboundHandlerAdapter() {
private final int bufferSize = 8;
private int received;
@Override
public void channelActive(ChannelHandlerContext ctx) {
ctx.writeAndFlush(Unpooled.buffer().writeZero(bufferSize));
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ByteBuf buffer = (ByteBuf) msg;
received += buffer.readableBytes();
buffer.release();
if (received == bufferSize) {
ctx.close().addListener((ChannelFuture future) -> {
// Close the underlying QuicChannel as well.
future.channel().parent().close();
});
}
}
}).sync();
// Wait until closure
quicChannel.closeFuture().sync();
assertStats(quicChannel.collectStats().sync().getNow());
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testStatsAreCollected() do?
testStatsAreCollected() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionStatsTest.java.
Where is testStatsAreCollected() defined?
testStatsAreCollected() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionStatsTest.java at line 38.
What does testStatsAreCollected() call?
testStatsAreCollected() calls 1 function(s): assertStats.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free