Home / Class/ SocketConnectTest Class — netty Architecture

SocketConnectTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80["SocketConnectTest"]
  f5662e12_3954_d0e1_076b_b00f29a7cc66["SocketConnectTest.java"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|defined in| f5662e12_3954_d0e1_076b_b00f29a7cc66
  4e76d2c3_ecc3_665a_f49f_eabf29102c47["testCloseTwice()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| 4e76d2c3_ecc3_665a_f49f_eabf29102c47
  14c05ea3_4ef2_7eac_4fe5_042adbc517fa["testLocalAddressAfterConnect()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| 14c05ea3_4ef2_7eac_4fe5_042adbc517fa
  0cfe536e_566a_eaf3_c7ad_675146a207ba["testChannelEventsFiredWhenClosedDirectly()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| 0cfe536e_566a_eaf3_c7ad_675146a207ba
  9ef744f2_9157_d6f5_7d0e_ab5deb691d30["testWriteWithFastOpenBeforeConnect()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| 9ef744f2_9157_d6f5_7d0e_ab5deb691d30
  6af87ce9_c383_c1b3_61aa_d414901f08bc["connectAndVerifyDataTransfer()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| 6af87ce9_c383_c1b3_61aa_d414901f08bc
  301bb0f2_9914_538c_aca5_5e1f9bce6a43["enableTcpFastOpen()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| 301bb0f2_9914_538c_aca5_5e1f9bce6a43
  f3ee4487_1bce_5f67_b94e_95cc2871a2da["assertLocalAddress()"]
  e7b8537c_10d8_f4e2_ea46_c5dd83a51b80 -->|method| f3ee4487_1bce_5f67_b94e_95cc2871a2da

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java lines 52–281

public class SocketConnectTest extends AbstractSocketTest {

    @Test
    @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
    public void testCloseTwice(TestInfo testInfo) throws Throwable {
        run(testInfo, new Runner<ServerBootstrap, Bootstrap>() {
            @Override
            public void run(ServerBootstrap serverBootstrap, Bootstrap bootstrap) throws Throwable {
                testCloseTwice(serverBootstrap, bootstrap);
            }
        });
    }

    public void testCloseTwice(ServerBootstrap sb, Bootstrap cb) throws Throwable {
        Channel serverChannel = null;
        Channel clientChannel = null;
        try {
            serverChannel = sb.childHandler(new ChannelInboundHandlerAdapter()).bind().syncUninterruptibly().channel();
            final BlockingQueue<ChannelFuture> futures = new LinkedBlockingQueue<>();
            clientChannel = cb.handler(new ChannelInboundHandlerAdapter() {
                        @Override
                        public void userEventTriggered(ChannelHandlerContext ctx, Object evt)  {
                            futures.add(ctx.close());
                        }
                    })
                    .connect(serverChannel.localAddress()).syncUninterruptibly().channel();
            clientChannel.pipeline().fireUserEventTriggered("test");
            clientChannel.close().syncUninterruptibly();
            futures.take().sync();
            clientChannel = null;

            serverChannel.close().syncUninterruptibly();
            serverChannel.close().syncUninterruptibly();
            serverChannel = null;
        } finally {
            if (clientChannel != null) {
                clientChannel.close().syncUninterruptibly();
            }
            if (serverChannel != null) {
                serverChannel.close().syncUninterruptibly();
            }
        }
    }

    @Test
    @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
    public void testLocalAddressAfterConnect(TestInfo testInfo) throws Throwable {
        run(testInfo, new Runner<ServerBootstrap, Bootstrap>() {
            @Override
            public void run(ServerBootstrap serverBootstrap, Bootstrap bootstrap) throws Throwable {
                testLocalAddressAfterConnect(serverBootstrap, bootstrap);
            }
        });
    }

    public void testLocalAddressAfterConnect(ServerBootstrap sb, Bootstrap cb) throws Throwable {
        Channel serverChannel = null;
        Channel clientChannel = null;
        try {
            final Promise<InetSocketAddress> localAddressPromise = ImmediateEventExecutor.INSTANCE.newPromise();
            serverChannel = sb.childHandler(new ChannelInboundHandlerAdapter() {
                        @Override
                        public void channelActive(ChannelHandlerContext ctx) throws Exception {
                            localAddressPromise.setSuccess((InetSocketAddress) ctx.channel().localAddress());
                        }
                    }).bind().syncUninterruptibly().channel();

            clientChannel = cb.handler(new ChannelInboundHandlerAdapter()).register().syncUninterruptibly().channel();

            assertNull(clientChannel.localAddress());
            assertNull(clientChannel.remoteAddress());

            clientChannel.connect(serverChannel.localAddress()).syncUninterruptibly().channel();
            assertLocalAddress((InetSocketAddress) clientChannel.localAddress());
            assertNotNull(clientChannel.remoteAddress());

            assertLocalAddress(localAddressPromise.get());
        } finally {
            if (clientChannel != null) {
                clientChannel.close().syncUninterruptibly();
            }

Frequently Asked Questions

What is the SocketConnectTest class?
SocketConnectTest is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java.
Where is SocketConnectTest defined?
SocketConnectTest is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketConnectTest.java at line 52.

Analyze Your Own Codebase

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

Try Supermodel Free