DynamicAddressConnectHandlerTest Class — netty Architecture
Architecture documentation for the DynamicAddressConnectHandlerTest class in DynamicAddressConnectHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 716b5126_d5ff_0b34_3256_65b32f859d4e["DynamicAddressConnectHandlerTest"] a606b1ca_c03f_6f07_eb89_cfd97332c461["DynamicAddressConnectHandlerTest.java"] 716b5126_d5ff_0b34_3256_65b32f859d4e -->|defined in| a606b1ca_c03f_6f07_eb89_cfd97332c461 5a797d21_147c_7ed9_afd7_f09be68b1407["testReplaceAddresses()"] 716b5126_d5ff_0b34_3256_65b32f859d4e -->|method| 5a797d21_147c_7ed9_afd7_f09be68b1407 adc80fec_9f3a_7718_5632_9821490bf459["testLocalAddressThrows()"] 716b5126_d5ff_0b34_3256_65b32f859d4e -->|method| adc80fec_9f3a_7718_5632_9821490bf459 5db236e0_b350_aecb_8240_53db54052f27["testRemoteAddressThrows()"] 716b5126_d5ff_0b34_3256_65b32f859d4e -->|method| 5db236e0_b350_aecb_8240_53db54052f27 8b733759_d34b_ef40_fa80_1c83f67f36ad["testThrows0()"] 716b5126_d5ff_0b34_3256_65b32f859d4e -->|method| 8b733759_d34b_ef40_fa80_1c83f67f36ad
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/address/DynamicAddressConnectHandlerTest.java lines 31–107
public class DynamicAddressConnectHandlerTest {
private static final SocketAddress LOCAL = new SocketAddress() { };
private static final SocketAddress LOCAL_NEW = new SocketAddress() { };
private static final SocketAddress REMOTE = new SocketAddress() { };
private static final SocketAddress REMOTE_NEW = new SocketAddress() { };
@Test
public void testReplaceAddresses() {
EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() {
@Override
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress,
SocketAddress localAddress, ChannelPromise promise) {
try {
assertSame(REMOTE_NEW, remoteAddress);
assertSame(LOCAL_NEW, localAddress);
promise.setSuccess();
} catch (Throwable cause) {
promise.setFailure(cause);
}
}
}, new DynamicAddressConnectHandler() {
@Override
protected SocketAddress localAddress(SocketAddress remoteAddress, SocketAddress localAddress) {
assertSame(REMOTE, remoteAddress);
assertSame(LOCAL, localAddress);
return LOCAL_NEW;
}
@Override
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress) {
assertSame(REMOTE, remoteAddress);
assertSame(LOCAL, localAddress);
return REMOTE_NEW;
}
});
channel.connect(REMOTE, LOCAL).syncUninterruptibly();
assertNull(channel.pipeline().get(DynamicAddressConnectHandler.class));
assertFalse(channel.finish());
}
@Test
public void testLocalAddressThrows() {
testThrows0(true);
}
@Test
public void testRemoteAddressThrows() {
testThrows0(false);
}
private static void testThrows0(final boolean localThrows) {
final IllegalStateException exception = new IllegalStateException();
EmbeddedChannel channel = new EmbeddedChannel(new DynamicAddressConnectHandler() {
@Override
protected SocketAddress localAddress(
SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
if (localThrows) {
throw exception;
}
return super.localAddress(remoteAddress, localAddress);
}
@Override
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress)
throws Exception {
if (!localThrows) {
throw exception;
}
return super.remoteAddress(remoteAddress, localAddress);
}
});
assertSame(exception, channel.connect(REMOTE, LOCAL).cause());
assertNotNull(channel.pipeline().get(DynamicAddressConnectHandler.class));
assertFalse(channel.finish());
}
}
Source
Frequently Asked Questions
What is the DynamicAddressConnectHandlerTest class?
DynamicAddressConnectHandlerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/address/DynamicAddressConnectHandlerTest.java.
Where is DynamicAddressConnectHandlerTest defined?
DynamicAddressConnectHandlerTest is defined in handler/src/test/java/io/netty/handler/address/DynamicAddressConnectHandlerTest.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free