HAProxyIntegrationTest Class — netty Architecture
Architecture documentation for the HAProxyIntegrationTest class in HAProxyIntegrationTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 64cf2b7b_2956_931b_dad5_46385f509301["HAProxyIntegrationTest"] 31ecfc50_2e94_6e31_13fd_6300fd3e55f5["HAProxyIntegrationTest.java"] 64cf2b7b_2956_931b_dad5_46385f509301 -->|defined in| 31ecfc50_2e94_6e31_13fd_6300fd3e55f5 29927711_73b7_4342_762e_102a91a4b188["testBasicCase()"] 64cf2b7b_2956_931b_dad5_46385f509301 -->|method| 29927711_73b7_4342_762e_102a91a4b188
Relationship Graph
Source Code
codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HAProxyIntegrationTest.java lines 40–97
public class HAProxyIntegrationTest {
@Test
public void testBasicCase() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<HAProxyMessage> msgHolder = new AtomicReference<HAProxyMessage>();
LocalAddress localAddress = new LocalAddress("HAProxyIntegrationTest");
EventLoopGroup group = new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory());
ServerBootstrap sb = new ServerBootstrap();
sb.channel(LocalServerChannel.class)
.group(group)
.childHandler(new ChannelInitializer() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(new HAProxyMessageDecoder());
ch.pipeline().addLast(new SimpleChannelInboundHandler<HAProxyMessage>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, HAProxyMessage msg) throws Exception {
msgHolder.set(msg.retain());
latch.countDown();
}
});
}
});
Channel serverChannel = sb.bind(localAddress).sync().channel();
Bootstrap b = new Bootstrap();
Channel clientChannel = b.channel(LocalChannel.class)
.handler(HAProxyMessageEncoder.INSTANCE)
.group(group)
.connect(localAddress).sync().channel();
try {
HAProxyMessage message = new HAProxyMessage(
HAProxyProtocolVersion.V1, HAProxyCommand.PROXY, HAProxyProxiedProtocol.TCP4,
"192.168.0.1", "192.168.0.11", 56324, 443);
clientChannel.writeAndFlush(message).sync();
assertTrue(latch.await(5, TimeUnit.SECONDS));
HAProxyMessage readMessage = msgHolder.get();
assertEquals(message.protocolVersion(), readMessage.protocolVersion());
assertEquals(message.command(), readMessage.command());
assertEquals(message.proxiedProtocol(), readMessage.proxiedProtocol());
assertEquals(message.sourceAddress(), readMessage.sourceAddress());
assertEquals(message.destinationAddress(), readMessage.destinationAddress());
assertEquals(message.sourcePort(), readMessage.sourcePort());
assertEquals(message.destinationPort(), readMessage.destinationPort());
readMessage.release();
} finally {
clientChannel.close().sync();
serverChannel.close().sync();
group.shutdownGracefully().sync();
}
}
}
Source
Frequently Asked Questions
What is the HAProxyIntegrationTest class?
HAProxyIntegrationTest is a class in the netty codebase, defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HAProxyIntegrationTest.java.
Where is HAProxyIntegrationTest defined?
HAProxyIntegrationTest is defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HAProxyIntegrationTest.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free