writerStateTest() — netty Function Reference
Architecture documentation for the writerStateTest() function in PcapWriteHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 7cd28704_a94a_925e_6f94_0ba5dd6fe9a5["writerStateTest()"] e9f4993c_4935_9405_4fab_0bbc9030a673["PcapWriteHandlerTest"] 7cd28704_a94a_925e_6f94_0ba5dd6fe9a5 -->|defined in| e9f4993c_4935_9405_4fab_0bbc9030a673 201e7e9e_c23c_b328_ecb1_117026fc1c03["InetSocketAddress()"] 7cd28704_a94a_925e_6f94_0ba5dd6fe9a5 -->|calls| 201e7e9e_c23c_b328_ecb1_117026fc1c03 22ba8e46_dc77_3860_b834_c8c13b6f8820["write()"] 7cd28704_a94a_925e_6f94_0ba5dd6fe9a5 -->|calls| 22ba8e46_dc77_3860_b834_c8c13b6f8820 style 7cd28704_a94a_925e_6f94_0ba5dd6fe9a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java lines 980–1035
@Test
public void writerStateTest() throws Exception {
final ByteBuf payload = Unpooled.wrappedBuffer("Meow".getBytes());
try {
final InetSocketAddress serverAddr = new InetSocketAddress("1.1.1.1", 1234);
final InetSocketAddress clientAddr = new InetSocketAddress("2.2.2.2", 3456);
PcapWriteHandler pcapWriteHandler = PcapWriteHandler.builder()
.forceTcpChannel(serverAddr, clientAddr, true)
.build(new OutputStream() {
@Override
public void write(int b) {
// Discard everything
}
});
// State is INIT because we haven't written anything yet
// and 'channelActive' is not called yet as this Handler
// is yet to be attached to `EmbeddedChannel`.
assertEquals(State.INIT, pcapWriteHandler.state());
// Create a new 'EmbeddedChannel' and add the 'PcapWriteHandler'
EmbeddedChannel embeddedChannel = new EmbeddedChannel(pcapWriteHandler);
// Write and read some data and verify it.
assertTrue(embeddedChannel.writeInbound(payload.retainedDuplicate()));
ByteBuf read = embeddedChannel.readInbound();
assertEquals(payload, read);
read.release();
assertTrue(embeddedChannel.writeOutbound(payload.retainedDuplicate()));
read = embeddedChannel.readOutbound();
assertEquals(payload, read);
read.release();
// State is now WRITING because we attached Handler to 'EmbeddedChannel'.
assertEquals(State.WRITING, pcapWriteHandler.state());
// Close the PcapWriter. This should trigger closure of PcapWriteHandler too.
pcapWriteHandler.pCapWriter().close();
// State should be changed to closed by now
assertEquals(State.CLOSED, pcapWriteHandler.state());
// Close PcapWriteHandler again. This should be a no-op.
pcapWriteHandler.close();
// State should still be CLOSED. No change.
assertEquals(State.CLOSED, pcapWriteHandler.state());
// Close the 'EmbeddedChannel'.
assertFalse(embeddedChannel.finishAndReleaseAll());
} finally {
payload.release();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does writerStateTest() do?
writerStateTest() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java.
Where is writerStateTest() defined?
writerStateTest() is defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java at line 980.
What does writerStateTest() call?
writerStateTest() calls 2 function(s): InetSocketAddress, write.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free