Home / Function/ testAddContents() — netty Function Reference

testAddContents() — netty Function Reference

Architecture documentation for the testAddContents() function in DiskFileUploadTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a6c823d8_7f4a_d564_e19e_09524aefd6b8["testAddContents()"]
  453c587b_ec9f_a761_a22b_ccf63aa13d1f["DiskFileUploadTest"]
  a6c823d8_7f4a_d564_e19e_09524aefd6b8 -->|defined in| 453c587b_ec9f_a761_a22b_ccf63aa13d1f
  style a6c823d8_7f4a_d564_e19e_09524aefd6b8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/multipart/DiskFileUploadTest.java lines 113–144

    @Test
    public void testAddContents() throws Exception {
        DiskFileUpload f1 = new DiskFileUpload("file1", "file1", "application/json", null, null, 0);
        try {
            byte[] jsonBytes = new byte[4096];
            ThreadLocalRandom.current().nextBytes(jsonBytes);

            f1.addContent(Unpooled.wrappedBuffer(jsonBytes, 0, 1024), false);
            f1.addContent(Unpooled.wrappedBuffer(jsonBytes, 1024, jsonBytes.length - 1024), true);
            assertArrayEquals(jsonBytes, f1.get());

            File file = f1.getFile();
            assertEquals(jsonBytes.length, file.length());

            try (FileInputStream fis = new FileInputStream(file)) {
                byte[] buf = new byte[jsonBytes.length];
                int offset = 0;
                int read = 0;
                int len = buf.length;
                while ((read = fis.read(buf, offset, len)) > 0) {
                    len -= read;
                    offset += read;
                    if (len <= 0 || offset >= buf.length) {
                        break;
                    }
                }
                assertArrayEquals(jsonBytes, buf);
            }
        } finally {
            f1.delete();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testAddContents() do?
testAddContents() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/DiskFileUploadTest.java.
Where is testAddContents() defined?
testAddContents() is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/DiskFileUploadTest.java at line 113.

Analyze Your Own Codebase

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

Try Supermodel Free