CodecHttp3Test Class — netty Architecture
Architecture documentation for the CodecHttp3Test class in CodecHttp3Test.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 6c8fb13b_b80f_3665_36aa_58857fdc6fd3["CodecHttp3Test"] 12c44a74_c8be_462c_20cd_073036032d84["CodecHttp3Test.java"] 6c8fb13b_b80f_3665_36aa_58857fdc6fd3 -->|defined in| 12c44a74_c8be_462c_20cd_073036032d84 b90b60f1_89bf_213e_bf97_5dd0f3118f5a["smokeTest()"] 6c8fb13b_b80f_3665_36aa_58857fdc6fd3 -->|method| b90b60f1_89bf_213e_bf97_5dd0f3118f5a 0ab38458_0c2c_d279_6635_52895d2e6ba2["runClient()"] 6c8fb13b_b80f_3665_36aa_58857fdc6fd3 -->|method| 0ab38458_0c2c_d279_6635_52895d2e6ba2 9ec75400_63dc_777d_5183_46f05f0ffe14["Channel()"] 6c8fb13b_b80f_3665_36aa_58857fdc6fd3 -->|method| 9ec75400_63dc_777d_5183_46f05f0ffe14
Relationship Graph
Source Code
testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/CodecHttp3Test.java lines 56–198
public class CodecHttp3Test {
private static final byte[] CONTENT = "Hello World!\r\n".getBytes(CharsetUtil.US_ASCII);
static final int PORT = 9999;
@Test
public void smokeTest() throws Exception {
int port = PORT;
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
try {
Channel serverChannel = startServer(group, port);
runClient(group, port);
serverChannel.close().sync();
} finally {
group.shutdownGracefully();
}
}
private void runClient(EventLoopGroup group, int port) throws InterruptedException, ExecutionException {
QuicSslContext context = QuicSslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.applicationProtocols(Http3.supportedApplicationProtocols()).build();
ChannelHandler codec = Http3.newQuicClientCodecBuilder()
.sslContext(context)
.maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
.initialMaxData(10000000)
.initialMaxStreamDataBidirectionalLocal(1000000)
.build();
Bootstrap bs = new Bootstrap();
Channel channel = bs.group(group)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(0).sync().channel();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
.handler(new Http3ClientConnectionHandler())
.remoteAddress(new InetSocketAddress(NetUtil.LOCALHOST4, port))
.connect()
.get();
CompletableFuture<String> response = new CompletableFuture<>();
QuicStreamChannel streamChannel = Http3.newRequestStream(quicChannel,
new Http3RequestStreamInboundHandler() {
@Override
protected void channelRead(ChannelHandlerContext ctx, Http3HeadersFrame frame) {
ReferenceCountUtil.release(frame);
}
@Override
protected void channelRead(ChannelHandlerContext ctx, Http3DataFrame frame) {
response.complete(frame.content().toString(CharsetUtil.US_ASCII));
ReferenceCountUtil.release(frame);
}
@Override
protected void channelInputClosed(ChannelHandlerContext ctx) {
ctx.close();
}
}).sync().getNow();
// Write the Header frame and send the FIN to mark the end of the request.
// After this its not possible anymore to write any more data.
Http3HeadersFrame frame = new DefaultHttp3HeadersFrame();
frame.headers().method("GET").path("/")
.authority(NetUtil.LOCALHOST4.getHostAddress() + ":" + port)
.scheme("https");
streamChannel.writeAndFlush(frame)
.addListener(QuicStreamChannel.SHUTDOWN_OUTPUT).sync();
// Wait for the stream channel and quic channel to be closed (this will happen after we received the FIN).
// After this is done we will close the underlying datagram channel.
streamChannel.closeFuture().sync();
assertEquals("Hello World!\r\n", response.get());
// After we received the response lets also close the underlying QUIC channel and datagram channel.
quicChannel.close().sync();
Source
Frequently Asked Questions
What is the CodecHttp3Test class?
CodecHttp3Test is a class in the netty codebase, defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/CodecHttp3Test.java.
Where is CodecHttp3Test defined?
CodecHttp3Test is defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/CodecHttp3Test.java at line 56.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free