testExceptionDuringConnect() — netty Function Reference
Architecture documentation for the testExceptionDuringConnect() function in HttpProxyHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD fc1d1916_d4be_fa46_8b9d_d1fd08525015["testExceptionDuringConnect()"] 4863804c_b04f_6a7f_744b_534e664fa2c9["HttpProxyHandlerTest"] fc1d1916_d4be_fa46_8b9d_d1fd08525015 -->|defined in| 4863804c_b04f_6a7f_744b_534e664fa2c9 style fc1d1916_d4be_fa46_8b9d_d1fd08525015 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java lines 179–236
@Test
public void testExceptionDuringConnect() throws Exception {
EventLoopGroup group = null;
Channel serverChannel = null;
Channel clientChannel = null;
try {
group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
final LocalAddress addr = new LocalAddress("a");
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
ChannelFuture sf =
new ServerBootstrap().channel(LocalServerChannel.class).group(group).childHandler(
new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addFirst(new HttpResponseEncoder());
DefaultFullHttpResponse response = new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1,
HttpResponseStatus.BAD_GATEWAY);
response.headers().add("name", "value");
response.headers().add(HttpHeaderNames.CONTENT_LENGTH, "0");
ch.writeAndFlush(response);
}
}).bind(addr);
serverChannel = sf.sync().channel();
ChannelFuture cf = new Bootstrap().channel(LocalChannel.class).group(group).handler(
new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addFirst(new HttpProxyHandler(addr));
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) {
exception.set(cause);
}
});
}
}).connect(new InetSocketAddress("localhost", 1234));
clientChannel = cf.sync().channel();
clientChannel.close().sync();
assertTrue(exception.get() instanceof HttpProxyConnectException);
HttpProxyConnectException actual = (HttpProxyConnectException) exception.get();
assertNotNull(actual.headers());
assertEquals("value", actual.headers().get("name"));
} finally {
if (clientChannel != null) {
clientChannel.close();
}
if (serverChannel != null) {
serverChannel.close();
}
if (group != null) {
group.shutdownGracefully();
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testExceptionDuringConnect() do?
testExceptionDuringConnect() is a function in the netty codebase, defined in handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java.
Where is testExceptionDuringConnect() defined?
testExceptionDuringConnect() is defined in handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java at line 179.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free