EmbeddedChannelTest Class — netty Architecture
Architecture documentation for the EmbeddedChannelTest class in EmbeddedChannelTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 300cabef_b042_697f_5623_37ce249f504d["EmbeddedChannelTest"] e148d706_0313_c998_93c5_83ac65559c84["EmbeddedChannelTest.java"] 300cabef_b042_697f_5623_37ce249f504d -->|defined in| e148d706_0313_c998_93c5_83ac65559c84 54e379d9_ab08_64e6_d913_996d843b0a8a["testParent()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 54e379d9_ab08_64e6_d913_996d843b0a8a ffc92aef_a1a4_e3e6_65bb_81fc5f36f5b7["testNotRegistered()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| ffc92aef_a1a4_e3e6_65bb_81fc5f36f5b7 952dee93_484c_6e00_3fc0_f3002685feb8["testRegistered()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 952dee93_484c_6e00_3fc0_f3002685feb8 7a648fa9_f8c6_55b8_32d4_93dc9bfe482d["promiseDoesNotInfiniteLoop()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 7a648fa9_f8c6_55b8_32d4_93dc9bfe482d 193f4ebc_c392_1e6c_58a2_ac138725441a["testConstructWithChannelInitializer()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 193f4ebc_c392_1e6c_58a2_ac138725441a 5a2fd672_be56_8c2e_a115_7458ac6b827f["testScheduling()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 5a2fd672_be56_8c2e_a115_7458ac6b827f 741b6e01_470c_b717_2a0f_699fbd49873b["testScheduledCancelled()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 741b6e01_470c_b717_2a0f_699fbd49873b 7bbf4d9e_77ed_eec0_a4a5_3a044085a658["testHandlerAddedExecutedInEventLoop()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 7bbf4d9e_77ed_eec0_a4a5_3a044085a658 932ecf6f_558e_69e4_77c5_536cfc920487["testConstructWithOutHandler()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 932ecf6f_558e_69e4_77c5_536cfc920487 6a7e0344_977f_3da1_72e8_a787fadad3e5["testConstructWithChannelId()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 6a7e0344_977f_3da1_72e8_a787fadad3e5 2410f4e9_6ad6_3dc0_c60f_b6fc5e031bfd["testFireChannelInactiveAndUnregisteredOnClose()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 2410f4e9_6ad6_3dc0_c60f_b6fc5e031bfd 8d720b1f_a1b5_904e_9468_1c6dc17471e6["testFireChannelInactiveAndUnregisteredOnDisconnect()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| 8d720b1f_a1b5_904e_9468_1c6dc17471e6 d5bebaa8_e534_c95d_6301_fbb84e35aace["testFireChannelInactiveAndUnregistered()"] 300cabef_b042_697f_5623_37ce249f504d -->|method| d5bebaa8_e534_c95d_6301_fbb84e35aace
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java lines 58–852
public class EmbeddedChannelTest {
@Test
public void testParent() {
EmbeddedChannel parent = new EmbeddedChannel();
EmbeddedChannel channel = new EmbeddedChannel(parent, EmbeddedChannelId.INSTANCE, true, false);
assertSame(parent, channel.parent());
assertNull(parent.parent());
assertFalse(channel.finish());
assertFalse(parent.finish());
}
@Test
public void testNotRegistered() throws Exception {
EmbeddedChannel channel = new EmbeddedChannel(false, false);
assertFalse(channel.isRegistered());
channel.register();
assertTrue(channel.isRegistered());
assertFalse(channel.finish());
}
@Test
public void testRegistered() throws Exception {
EmbeddedChannel channel = new EmbeddedChannel(true, false);
assertTrue(channel.isRegistered());
try {
channel.register();
fail();
} catch (IllegalStateException expected) {
// This is expected the channel is registered already on an EventLoop.
}
assertFalse(channel.finish());
}
@Test
@Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void promiseDoesNotInfiniteLoop() throws InterruptedException {
EmbeddedChannel channel = new EmbeddedChannel();
channel.closeFuture().addListener((ChannelFutureListener) future -> future.channel().close());
channel.close().syncUninterruptibly();
}
@Test
public void testConstructWithChannelInitializer() {
final Integer first = 1;
final Integer second = 2;
final ChannelHandler handler = new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ctx.fireChannelRead(first);
ctx.fireChannelRead(second);
}
};
EmbeddedChannel channel = new EmbeddedChannel(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(handler);
}
});
ChannelPipeline pipeline = channel.pipeline();
assertSame(handler, pipeline.firstContext().handler());
assertTrue(channel.writeInbound(3));
assertTrue(channel.finish());
assertSame(first, channel.readInbound());
assertSame(second, channel.readInbound());
assertNull(channel.readInbound());
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testScheduling() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter());
final CountDownLatch latch = new CountDownLatch(2);
Future future = ch.eventLoop().schedule(new Runnable() {
@Override
public void run() {
latch.countDown();
}
}, 1, TimeUnit.SECONDS);
Source
Frequently Asked Questions
What is the EmbeddedChannelTest class?
EmbeddedChannelTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java.
Where is EmbeddedChannelTest defined?
EmbeddedChannelTest is defined in transport/src/test/java/io/netty/channel/embedded/EmbeddedChannelTest.java at line 58.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free