Home / Class/ LocalChannelTest Class — netty Architecture

LocalChannelTest Class — netty Architecture

Architecture documentation for the LocalChannelTest class in LocalChannelTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d7e5442a_9b99_814d_2bd6_0be57237db65["LocalChannelTest"]
  08ebe769_61fc_27b6_2445_25670081be74["LocalChannelTest.java"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|defined in| 08ebe769_61fc_27b6_2445_25670081be74
  e06d63a2_ae61_705a_6fa9_872ac5b623db["beforeClass()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| e06d63a2_ae61_705a_6fa9_872ac5b623db
  4eda3b46_d4d1_a26a_d97f_683a283a7f58["afterClass()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 4eda3b46_d4d1_a26a_d97f_683a283a7f58
  d4cd6bb2_3f7e_ef0c_a840_2ef44e8034d6["testLocalAddressReuse()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| d4cd6bb2_3f7e_ef0c_a840_2ef44e8034d6
  84ff2132_6330_c4ab_ad3e_946db904a74c["testWriteFailsFastOnClosedChannel()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 84ff2132_6330_c4ab_ad3e_946db904a74c
  30a21170_6dc0_5378_0750_a03c460fb9fb["testServerCloseChannelSameEventLoop()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 30a21170_6dc0_5378_0750_a03c460fb9fb
  d99f4d40_0bb0_129b_0021_59cfede6999e["localChannelRaceCondition()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| d99f4d40_0bb0_129b_0021_59cfede6999e
  f00a2d99_aed9_4c52_766b_855bbf284603["testReRegister()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| f00a2d99_aed9_4c52_766b_855bbf284603
  316e8485_bea4_4814_7c9e_95f0c3153153["testCloseInWritePromiseCompletePreservesOrder()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 316e8485_bea4_4814_7c9e_95f0c3153153
  6e2d3f4c_54ff_316e_9a87_fea5d4c4792f["testCloseAfterWriteInSameEventLoopPreservesOrder()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 6e2d3f4c_54ff_316e_9a87_fea5d4c4792f
  2253f4d1_60c4_c68f_5e74_52790064aace["testWriteInWritePromiseCompletePreservesOrder()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 2253f4d1_60c4_c68f_5e74_52790064aace
  f70d21b4_e883_e7ee_3417_bee90cfecb36["testPeerWriteInWritePromiseCompleteDifferentEventLoopPreservesOrder()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| f70d21b4_e883_e7ee_3417_bee90cfecb36
  da8d733a_4f9a_da6c_a90d_d621cf553c25["testPeerWriteInWritePromiseCompleteSameEventLoopPreservesOrder()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| da8d733a_4f9a_da6c_a90d_d621cf553c25
  18485282_3d01_ac4c_986e_a6de8a7bb348["testWriteWhilePeerIsClosedReleaseObjectAndFailPromise()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65 -->|method| 18485282_3d01_ac4c_986e_a6de8a7bb348

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/local/LocalChannelTest.java lines 67–1324

public class LocalChannelTest {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(LocalChannelTest.class);

    private static final LocalAddress TEST_ADDRESS = new LocalAddress("test.id");

    private static EventLoopGroup group1;
    private static EventLoopGroup group2;
    private static EventLoopGroup sharedGroup;

    @BeforeAll
    public static void beforeClass() {
        group1 = new MultiThreadIoEventLoopGroup(2, LocalIoHandler.newFactory());
        group2 = new MultiThreadIoEventLoopGroup(2, LocalIoHandler.newFactory());
        sharedGroup = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
    }

    @AfterAll
    public static void afterClass() throws InterruptedException {
        Future<?> group1Future = group1.shutdownGracefully(0, 0, SECONDS);
        Future<?> group2Future = group2.shutdownGracefully(0, 0, SECONDS);
        Future<?> sharedGroupFuture = sharedGroup.shutdownGracefully(0, 0, SECONDS);
        group1Future.await();
        group2Future.await();
        sharedGroupFuture.await();
    }

    @Test
    public void testLocalAddressReuse() throws Exception {
        for (int i = 0; i < 2; i ++) {
            Bootstrap cb = new Bootstrap();
            ServerBootstrap sb = new ServerBootstrap();

            cb.group(group1)
              .channel(LocalChannel.class)
              .handler(new TestHandler());

            sb.group(group2)
              .channel(LocalServerChannel.class)
              .childHandler(new ChannelInitializer<LocalChannel>() {
                  @Override
                  public void initChannel(LocalChannel ch) throws Exception {
                      ch.pipeline().addLast(new TestHandler());
                  }
              });

            Channel sc = null;
            Channel cc = null;
            try {
                // Start server
                sc = sb.bind(TEST_ADDRESS).sync().channel();

                final CountDownLatch latch = new CountDownLatch(1);
                // Connect to the server
                cc = cb.connect(sc.localAddress()).sync().channel();
                final Channel ccCpy = cc;
                cc.eventLoop().execute(new Runnable() {
                    @Override
                    public void run() {
                        // Send a message event up the pipeline.
                        ccCpy.pipeline().fireChannelRead("Hello, World");
                        latch.countDown();
                    }
                });
                assertTrue(latch.await(5, SECONDS));

                // Close the channel
                closeChannel(cc);
                closeChannel(sc);
                sc.closeFuture().sync();

                assertNull(LocalChannelRegistry.get(TEST_ADDRESS), String.format(
                        "Expected null, got channel '%s' for local address '%s'",
                        LocalChannelRegistry.get(TEST_ADDRESS), TEST_ADDRESS));
            } finally {
                closeChannel(cc);
                closeChannel(sc);
            }
        }
    }

Frequently Asked Questions

What is the LocalChannelTest class?
LocalChannelTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java.
Where is LocalChannelTest defined?
LocalChannelTest is defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java at line 67.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free