Home / Function/ testUdsPathname() — netty Function Reference

testUdsPathname() — netty Function Reference

Architecture documentation for the testUdsPathname() function in SockaddrInTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  eea30fa7_52d5_804c_2fc6_fa89f620bcf3["testUdsPathname()"]
  f542b96b_70a1_3930_b104_0cabb6a71e80["SockaddrInTest"]
  eea30fa7_52d5_804c_2fc6_fa89f620bcf3 -->|defined in| f542b96b_70a1_3930_b104_0cabb6a71e80
  style eea30fa7_52d5_804c_2fc6_fa89f620bcf3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java lines 104–135

    @Test
    public void testUdsPathname() throws Exception {
        CleanableDirectBuffer cleanableDirectBuffer = allocateDirectBufferWithNativeOrder(
                Native.SIZEOF_SOCKADDR_UN);
        ByteBuffer buffer = cleanableDirectBuffer.buffer();
        try {
            String socketPath = "/tmp/test.sock";
            DomainSocketAddress address = new DomainSocketAddress(socketPath);
            byte[] pathBytes = socketPath.getBytes(StandardCharsets.UTF_8);

            int expectedLength = Native.SOCKADDR_UN_OFFSETOF_SUN_PATH + pathBytes.length + 1;
            int actualLength = SockaddrIn.setUds(buffer, address);

            assertEquals(expectedLength, actualLength, "Address length should include null terminator");

            // Verify sun_family is set correctly
            short family = buffer.getShort(buffer.position() + Native.SOCKADDR_UN_OFFSETOF_SUN_FAMILY);
            assertEquals(Native.AF_UNIX, family, "sun_family should be AF_UNIX");

            // Verify path is written correctly
            byte[] writtenPath = new byte[pathBytes.length];
            buffer.position(buffer.position() + Native.SOCKADDR_UN_OFFSETOF_SUN_PATH);
            buffer.get(writtenPath);
            assertArrayEquals(pathBytes, writtenPath, "Path should match");

            // Verify null terminator is present
            byte nullTerminator = buffer.get();
            assertEquals(0, nullTerminator, "Pathname socket should have null terminator");
        } finally {
            cleanableDirectBuffer.clean();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testUdsPathname() do?
testUdsPathname() is a function in the netty codebase, defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java.
Where is testUdsPathname() defined?
testUdsPathname() is defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java at line 104.

Analyze Your Own Codebase

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

Try Supermodel Free