PcapWriteHandlerTest Class — netty Architecture
Architecture documentation for the PcapWriteHandlerTest class in PcapWriteHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e9f4993c_4935_9405_4fab_0bbc9030a673["PcapWriteHandlerTest"] 993bdeb0_5d47_ce1b_c810_8cb22b3c3900["PcapWriteHandlerTest.java"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|defined in| 993bdeb0_5d47_ce1b_c810_8cb22b3c3900 04cb4359_ee0e_2eba_fe0f_fdd5884262e0["udpV4SharedOutputStreamTest()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 04cb4359_ee0e_2eba_fe0f_fdd5884262e0 1ceaa157_983b_01fb_7e76_423befb794eb["udpV4NonOutputStream()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 1ceaa157_983b_01fb_7e76_423befb794eb 7294656e_de76_eb6d_2716_ab3c6280f6c4["udpV4NoGlobalHeaderOutputStream()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 7294656e_de76_eb6d_2716_ab3c6280f6c4 09664c21_072d_80b4_a75e_e5bf4f97af22["udpV4()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 09664c21_072d_80b4_a75e_e5bf4f97af22 ddfde28c_4e8f_f8cd_23bf_3a4fb181fa91["embeddedUdp()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| ddfde28c_4e8f_f8cd_23bf_3a4fb181fa91 8d1bfd2f_28e4_d994_01ee_6a6b380155f9["udpMixedAddress()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 8d1bfd2f_28e4_d994_01ee_6a6b380155f9 7e04f034_78f5_ced7_e48e_d7cd24d5196f["udpLargeByteBufPayload()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 7e04f034_78f5_ced7_e48e_d7cd24d5196f f38f22f5_906f_d7bc_8c66_9fc39df3446d["udpLargeDatagramPayload()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| f38f22f5_906f_d7bc_8c66_9fc39df3446d 568c9eeb_3e86_a619_596b_e2249c5fae2f["udpZeroLengthByteBufCaptured()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| 568c9eeb_3e86_a619_596b_e2249c5fae2f a15a4135_9de1_dbb2_ff35_ca42c77c69f5["udpZeroLengthByteBufDiscarded()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| a15a4135_9de1_dbb2_ff35_ca42c77c69f5 e94a2daf_6334_d8a0_7364_bdcc90c0b5af["udpZeroLengthDatagramCaptured()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| e94a2daf_6334_d8a0_7364_bdcc90c0b5af e48dd0a4_d1f2_4480_060c_0d21440a7cc5["udpZeroLengthDatagramDiscarded()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| e48dd0a4_d1f2_4480_060c_0d21440a7cc5 b8414409_f89e_9b3b_823d_1bca832e5e0c["udpExceptionCaught()"] e9f4993c_4935_9405_4fab_0bbc9030a673 -->|method| b8414409_f89e_9b3b_823d_1bca832e5e0c
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java lines 72–1519
public class PcapWriteHandlerTest {
@Test
public void udpV4SharedOutputStreamTest() throws InterruptedException {
udpV4(true, true);
}
@Test
public void udpV4NonOutputStream() throws InterruptedException {
udpV4(false, true);
}
@Test
public void udpV4NoGlobalHeaderOutputStream() throws InterruptedException {
udpV4(false, false);
}
private static void udpV4(boolean sharedOutputStream, boolean writeGlobalHeaders)
throws InterruptedException {
ByteBuf byteBuf = Unpooled.buffer();
ByteBuf payload = Unpooled.wrappedBuffer("Meow".getBytes());
try {
InetSocketAddress serverAddr = new InetSocketAddress("127.0.0.1", 0);
InetSocketAddress clientAddr = new InetSocketAddress("127.0.0.1", 0);
EventLoopGroup eventLoopGroup = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
// We'll bootstrap a UDP Server to avoid "Network Unreachable errors" when sending UDP Packet.
Bootstrap server = new Bootstrap()
.group(eventLoopGroup)
.channel(NioDatagramChannel.class)
.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) {
// Discard
}
});
ChannelFuture channelFutureServer = server.bind(serverAddr).sync();
assertTrue(channelFutureServer.isSuccess());
CloseDetectingByteBufOutputStream outputStream = new CloseDetectingByteBufOutputStream(byteBuf);
// We'll bootstrap a UDP Client for sending UDP Packets to UDP Server.
Bootstrap client = new Bootstrap()
.group(eventLoopGroup)
.channel(NioDatagramChannel.class)
.handler(PcapWriteHandler.builder()
.sharedOutputStream(sharedOutputStream)
.writePcapGlobalHeader(writeGlobalHeaders)
.build(outputStream));
ChannelFuture channelFutureClient =
client.bind(clientAddr).sync();
assertTrue(channelFutureClient.isSuccess());
Channel clientChannel = channelFutureClient.channel();
DatagramPacket datagram = new DatagramPacket(payload.copy(),
(InetSocketAddress) channelFutureServer.channel().localAddress());
assertTrue(clientChannel.writeAndFlush(datagram).sync().isSuccess());
assertTrue(eventLoopGroup.shutdownGracefully().sync().isSuccess());
// if sharedOutputStream is true or writeGlobalHeaders is false, we don't verify the global headers.
verifyUdpCapture(!sharedOutputStream && writeGlobalHeaders,
byteBuf, payload,
(InetSocketAddress) channelFutureServer.channel().localAddress(),
(InetSocketAddress) clientChannel.localAddress()
);
// If sharedOutputStream is true, we don't close the outputStream.
// If sharedOutputStream is false, we close the outputStream.
assertEquals(!sharedOutputStream, outputStream.closeCalled());
} finally {
byteBuf.release();
payload.release();
}
}
@Test
public void embeddedUdp() {
Source
Frequently Asked Questions
What is the PcapWriteHandlerTest class?
PcapWriteHandlerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java.
Where is PcapWriteHandlerTest defined?
PcapWriteHandlerTest is defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java at line 72.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free