Home / Function/ testSimpleSendWithConnect0() — netty Function Reference

testSimpleSendWithConnect0() — netty Function Reference

Architecture documentation for the testSimpleSendWithConnect0() function in DatagramUnicastTest.java from the netty codebase.

Function java Buffer Search calls 4 called by 1

Entity Profile

Dependency Diagram

graph TD
  2802b3c5_22da_5cb7_ef38_e095fc126972["testSimpleSendWithConnect0()"]
  fe4d45b3_9e9e_2ee9_7d60_26b49241d521["DatagramUnicastTest"]
  2802b3c5_22da_5cb7_ef38_e095fc126972 -->|defined in| fe4d45b3_9e9e_2ee9_7d60_26b49241d521
  91adde55_18a9_ce71_735d_5273e446363a["testSimpleSendWithConnect()"]
  91adde55_18a9_ce71_735d_5273e446363a -->|calls| 2802b3c5_22da_5cb7_ef38_e095fc126972
  5f4d9002_9840_0bb7_b5c2_b42eac154106["isConnected()"]
  2802b3c5_22da_5cb7_ef38_e095fc126972 -->|calls| 5f4d9002_9840_0bb7_b5c2_b42eac154106
  c9d3875f_d7be_5b71_8f87_cf3f38623a43["supportDisconnect()"]
  2802b3c5_22da_5cb7_ef38_e095fc126972 -->|calls| c9d3875f_d7be_5b71_8f87_cf3f38623a43
  6998ad09_3c3a_0d5d_7e6a_bfcbfb3a0f0a["disconnectMightFail()"]
  2802b3c5_22da_5cb7_ef38_e095fc126972 -->|calls| 6998ad09_3c3a_0d5d_7e6a_bfcbfb3a0f0a
  2d23de82_a483_8ed0_72eb_e0bb5301cb96["closeChannel()"]
  2802b3c5_22da_5cb7_ef38_e095fc126972 -->|calls| 2d23de82_a483_8ed0_72eb_e0bb5301cb96
  style 2802b3c5_22da_5cb7_ef38_e095fc126972 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastTest.java lines 374–448

    private void testSimpleSendWithConnect0(Bootstrap sb, Bootstrap cb, ByteBuf buf, final byte[] bytes, int count,
                                            WrapType wrapType) throws Throwable {
        Channel sc = null;
        Channel cc = null;
        try {
            final CountDownLatch latch = new CountDownLatch(count);
            final AtomicReference<Throwable> errorRef = new AtomicReference<Throwable>();
            final CountDownLatch clientLatch = new CountDownLatch(count);
            final AtomicReference<Throwable> clientErrorRef = new AtomicReference<Throwable>();
            cc = setupClientChannel(cb, bytes, clientLatch, clientErrorRef);
            sc = setupServerChannel(sb, bytes, cc.localAddress(), latch, errorRef, true);

            SocketAddress localAddr = sc.localAddress();
            SocketAddress addr = localAddr instanceof InetSocketAddress ?
                    sendToAddress((InetSocketAddress) sc.localAddress()) : localAddr;
            cc.connect(addr).syncUninterruptibly();

            List<ChannelFuture> futures = new ArrayList<ChannelFuture>();
            for (int i = 0; i < count; i++) {
                futures.add(write(cc, buf, wrapType));
            }
            cc.flush();

            for (ChannelFuture future: futures) {
                future.sync();
            }

            if (!latch.await(10, TimeUnit.SECONDS)) {
                Throwable cause = errorRef.get();
                if (cause != null) {
                    throw cause;
                }
                fail();
            }
            if (!clientLatch.await(10, TimeUnit.SECONDS)) {
                Throwable cause = clientErrorRef.get();
                if (cause != null) {
                    throw cause;
                }
                fail();
            }
            assertTrue(isConnected(cc));

            assertNotNull(cc.localAddress());
            assertNotNull(cc.remoteAddress());

            if (supportDisconnect()) {
                try {
                    // Test what happens when we call disconnect()
                    cc.disconnect().syncUninterruptibly();
                } catch (Throwable e) {
                    if (e instanceof SocketException) {
                        if (disconnectMightFail((DatagramChannel) cc)) {
                            return;
                        }
                    }
                    throw e;
                }
                assertFalse(isConnected(cc));
                assertNotNull(cc.localAddress());
                assertNull(cc.remoteAddress());

                ChannelFuture future = cc.writeAndFlush(
                        buf.retain().duplicate()).awaitUninterruptibly();
                assertTrue(future.cause() instanceof NotYetConnectedException,
                        "NotYetConnectedException expected, got: " + future.cause());
            }
        } finally {
            // release as we used buf.retain() before
            buf.release();

            closeChannel(cc);
            closeChannel(sc);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSimpleSendWithConnect0() do?
testSimpleSendWithConnect0() is a function in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastTest.java.
Where is testSimpleSendWithConnect0() defined?
testSimpleSendWithConnect0() is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastTest.java at line 374.
What does testSimpleSendWithConnect0() call?
testSimpleSendWithConnect0() calls 4 function(s): closeChannel, disconnectMightFail, isConnected, supportDisconnect.
What calls testSimpleSendWithConnect0()?
testSimpleSendWithConnect0() is called by 1 function(s): testSimpleSendWithConnect.

Analyze Your Own Codebase

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

Try Supermodel Free