Home / Function/ testConnectedAlready() — netty Function Reference

testConnectedAlready() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  80ec3aa3_fb3b_65e9_0b13_f4903b9e42a4["testConnectedAlready()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65["LocalChannelTest"]
  80ec3aa3_fb3b_65e9_0b13_f4903b9e42a4 -->|defined in| d7e5442a_9b99_814d_2bd6_0be57237db65
  682f5263_0b7f_955e_78f4_bc584d494eaa["exceptionCaught()"]
  80ec3aa3_fb3b_65e9_0b13_f4903b9e42a4 -->|calls| 682f5263_0b7f_955e_78f4_bc584d494eaa
  d3c8aa54_ac5d_6944_e789_c2c22ce16089["closeChannel()"]
  80ec3aa3_fb3b_65e9_0b13_f4903b9e42a4 -->|calls| d3c8aa54_ac5d_6944_e789_c2c22ce16089
  style 80ec3aa3_fb3b_65e9_0b13_f4903b9e42a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/local/LocalChannelTest.java lines 866–906

    @Test
    public void testConnectedAlready() throws Exception {
        Bootstrap cb = new Bootstrap();
        ServerBootstrap sb = new ServerBootstrap();
        final AtomicReference<Throwable> causeRef = new AtomicReference<>();
        cb.group(group1)
                .channel(LocalChannel.class)
                .handler(new ChannelInboundHandlerAdapter() {
                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
                        causeRef.set(cause);
                    }
                });

        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();

            // Connect to the server
            cc = cb.connect(sc.localAddress()).sync().channel();

            ChannelFuture f = cc.connect(sc.localAddress()).awaitUninterruptibly();
            assertInstanceOf(AlreadyConnectedException.class, f.cause());
            cc.close().syncUninterruptibly();
            assertNull(causeRef.get());
        } finally {
            closeChannel(cc);
            closeChannel(sc);
        }
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free