SimpleUserEventChannelHandlerTest Class — netty Architecture
Architecture documentation for the SimpleUserEventChannelHandlerTest class in SimpleUserEventChannelHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 4f8491d9_0a7a_344d_7b4f_ac4c0a1acd42["SimpleUserEventChannelHandlerTest"] 7ae89884_b504_3b35_01b6_a80b50d10c69["SimpleUserEventChannelHandlerTest.java"] 4f8491d9_0a7a_344d_7b4f_ac4c0a1acd42 -->|defined in| 7ae89884_b504_3b35_01b6_a80b50d10c69 5713a6e2_d757_6b58_9479_f159d476044f["setUp()"] 4f8491d9_0a7a_344d_7b4f_ac4c0a1acd42 -->|method| 5713a6e2_d757_6b58_9479_f159d476044f cdd71857_914b_662d_c437_8c2a910eeda8["testTypeMatch()"] 4f8491d9_0a7a_344d_7b4f_ac4c0a1acd42 -->|method| cdd71857_914b_662d_c437_8c2a910eeda8 fbaf62b3_4dec_55a8_11bf_66543c14098b["testTypeMismatch()"] 4f8491d9_0a7a_344d_7b4f_ac4c0a1acd42 -->|method| fbaf62b3_4dec_55a8_11bf_66543c14098b
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java lines 31–103
public class SimpleUserEventChannelHandlerTest {
private FooEventCatcher fooEventCatcher;
private AllEventCatcher allEventCatcher;
private EmbeddedChannel channel;
@BeforeEach
public void setUp() {
fooEventCatcher = new FooEventCatcher();
allEventCatcher = new AllEventCatcher();
channel = new EmbeddedChannel(fooEventCatcher, allEventCatcher);
}
@Test
public void testTypeMatch() {
FooEvent fooEvent = new FooEvent();
channel.pipeline().fireUserEventTriggered(fooEvent);
assertEquals(1, fooEventCatcher.caughtEvents.size());
assertEquals(0, allEventCatcher.caughtEvents.size());
assertEquals(0, fooEvent.refCnt());
assertFalse(channel.finish());
}
@Test
public void testTypeMismatch() {
BarEvent barEvent = new BarEvent();
channel.pipeline().fireUserEventTriggered(barEvent);
assertEquals(0, fooEventCatcher.caughtEvents.size());
assertEquals(1, allEventCatcher.caughtEvents.size());
assertTrue(barEvent.release());
assertFalse(channel.finish());
}
static final class FooEvent extends DefaultByteBufHolder {
FooEvent() {
super(Unpooled.buffer());
}
}
static final class BarEvent extends DefaultByteBufHolder {
BarEvent() {
super(Unpooled.buffer());
}
}
static final class FooEventCatcher extends SimpleUserEventChannelHandler<FooEvent> {
public List<FooEvent> caughtEvents;
FooEventCatcher() {
caughtEvents = new ArrayList<FooEvent>();
}
@Override
protected void eventReceived(ChannelHandlerContext ctx, FooEvent evt) {
caughtEvents.add(evt);
}
}
static final class AllEventCatcher extends ChannelInboundHandlerAdapter {
public List<Object> caughtEvents;
AllEventCatcher() {
caughtEvents = new ArrayList<Object>();
}
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
caughtEvents.add(evt);
}
}
}
Source
Frequently Asked Questions
What is the SimpleUserEventChannelHandlerTest class?
SimpleUserEventChannelHandlerTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java.
Where is SimpleUserEventChannelHandlerTest defined?
SimpleUserEventChannelHandlerTest is defined in transport/src/test/java/io/netty/channel/SimpleUserEventChannelHandlerTest.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free