Home / Class/ LinuxSocketTest Class — netty Architecture

LinuxSocketTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  4a9abc5d_1dba_c643_f76d_b922328fd23f["LinuxSocketTest"]
  5c3fa851_b308_0b70_59d0_54075d93f29d["LinuxSocketTest.java"]
  4a9abc5d_1dba_c643_f76d_b922328fd23f -->|defined in| 5c3fa851_b308_0b70_59d0_54075d93f29d
  70098202_77f5_1dc7_ce2e_4cb6dd32572b["loadJNI()"]
  4a9abc5d_1dba_c643_f76d_b922328fd23f -->|method| 70098202_77f5_1dc7_ce2e_4cb6dd32572b
  fb37a75a_1f97_ea04_0648_44d33729a4a6["testBindNonIpv6SocketToInet6AddressThrows()"]
  4a9abc5d_1dba_c643_f76d_b922328fd23f -->|method| fb37a75a_1f97_ea04_0648_44d33729a4a6
  73808b88_e5a4_1163_5c25_0eb9ac7c2dbb["testConnectNonIpv6SocketToInet6AddressThrows()"]
  4a9abc5d_1dba_c643_f76d_b922328fd23f -->|method| 73808b88_e5a4_1163_5c25_0eb9ac7c2dbb
  10bedd42_de59_5b26_5949_e9ed511586c6["testUnixDomainSocketTooLongPathFails()"]
  4a9abc5d_1dba_c643_f76d_b922328fd23f -->|method| 10bedd42_de59_5b26_5949_e9ed511586c6
  855e2754_d22e_7721_1c05_4b5351469a59["testUnixAbstractDomainSocket()"]
  4a9abc5d_1dba_c643_f76d_b922328fd23f -->|method| 855e2754_d22e_7721_1c05_4b5351469a59

Relationship Graph

Source Code

transport-native-epoll/src/test/java/io/netty/channel/epoll/LinuxSocketTest.java lines 34–115

public class LinuxSocketTest {
    @BeforeAll
    public static void loadJNI() {
        Epoll.ensureAvailability();
    }

    @Test
    public void testBindNonIpv6SocketToInet6AddressThrows() throws Exception {
        final LinuxSocket socket = LinuxSocket.newSocketStream(false);
        try {
            assertThrows(IOException.class, new Executable() {
                @Override
                public void execute() throws Throwable {
                    socket.bind(new InetSocketAddress(InetAddress.getByAddress(
                            new byte[]{'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'}),
                            0));
                }
            });
        } finally {
            socket.close();
        }
    }

    @Test
    public void testConnectNonIpv6SocketToInet6AddressThrows() throws Exception {
        final LinuxSocket socket = LinuxSocket.newSocketStream(false);
        try {
            assertThrows(IOException.class,
                    new Executable() {
                        @Override
                        public void execute() throws Throwable {
                            socket.connect(new InetSocketAddress(InetAddress.getByAddress(new byte[]{
                                    '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'}),
                                    1234));
                        }
                    });
        } finally {
            socket.close();
        }
    }

    @Test
    public void testUnixDomainSocketTooLongPathFails() throws IOException {
        // Most systems has a limit for UDS path of 108, 255 is generally too long.
        StringBuilder socketPath = new StringBuilder("/tmp/");
        while (socketPath.length() < 255) {
            socketPath.append(UUID.randomUUID());
        }

        final DomainSocketAddress domainSocketAddress = new DomainSocketAddress(
            socketPath.toString());
        final Socket socket = Socket.newSocketDomain();
        try {
            Exception exception = Assertions.assertThrows(NativeIoException.class, new Executable() {
                @Override
                public void execute() throws Throwable {
                    socket.bind(domainSocketAddress);
                }
            });
            Assertions.assertTrue(exception.getMessage().contains("too long"));
        } finally {
            socket.close();
        }
    }

    @Test
    public void testUnixAbstractDomainSocket() throws IOException {
        String address  = "\0" + UUID.randomUUID();

        final DomainSocketAddress domainSocketAddress = new DomainSocketAddress(address);
        final Socket socket = Socket.newSocketDomain();
        try {
            socket.bind(domainSocketAddress);
            DomainSocketAddress local = socket.localDomainSocketAddress();
            assertEquals(domainSocketAddress, local);
            assertEquals(address, domainSocketAddress.path());
            assertEquals(address, local.path());
        } finally {
            socket.close();
        }
    }

Frequently Asked Questions

What is the LinuxSocketTest class?
LinuxSocketTest is a class in the netty codebase, defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/LinuxSocketTest.java.
Where is LinuxSocketTest defined?
LinuxSocketTest is defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/LinuxSocketTest.java at line 34.

Analyze Your Own Codebase

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

Try Supermodel Free