Home / Function/ testLocalAddressReuse() — netty Function Reference

testLocalAddressReuse() — netty Function Reference

Architecture documentation for the testLocalAddressReuse() function in LocalChannelTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d4cd6bb2_3f7e_ef0c_a840_2ef44e8034d6["testLocalAddressReuse()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65["LocalChannelTest"]
  d4cd6bb2_3f7e_ef0c_a840_2ef44e8034d6 -->|defined in| d7e5442a_9b99_814d_2bd6_0be57237db65
  d3c8aa54_ac5d_6944_e789_c2c22ce16089["closeChannel()"]
  d4cd6bb2_3f7e_ef0c_a840_2ef44e8034d6 -->|calls| d3c8aa54_ac5d_6944_e789_c2c22ce16089
  style d4cd6bb2_3f7e_ef0c_a840_2ef44e8034d6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/local/LocalChannelTest.java lines 94–146

    @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);
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testLocalAddressReuse() do?
testLocalAddressReuse() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java.
Where is testLocalAddressReuse() defined?
testLocalAddressReuse() is defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java at line 94.
What does testLocalAddressReuse() call?
testLocalAddressReuse() calls 1 function(s): closeChannel.

Analyze Your Own Codebase

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

Try Supermodel Free