Home / Function/ testSetContentFromFile() — netty Function Reference

testSetContentFromFile() — netty Function Reference

Architecture documentation for the testSetContentFromFile() function in AbstractMemoryHttpDataTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  437d1625_b451_a488_7de2_a1cd75813c10["testSetContentFromFile()"]
  3b2d0623_5311_2698_e2c8_4ff0f0e583b8["AbstractMemoryHttpDataTest"]
  437d1625_b451_a488_7de2_a1cd75813c10 -->|defined in| 3b2d0623_5311_2698_e2c8_4ff0f0e583b8
  54414378_073c_cece_2b86_2b81f7995c83["TestHttpData()"]
  437d1625_b451_a488_7de2_a1cd75813c10 -->|calls| 54414378_073c_cece_2b86_2b81f7995c83
  style 437d1625_b451_a488_7de2_a1cd75813c10 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpDataTest.java lines 46–71

    @Test
    public void testSetContentFromFile() throws Exception {
        TestHttpData test = new TestHttpData("test", UTF_8, 0);
        try {
            File tmpFile = PlatformDependent.createTempFile(UUID.randomUUID().toString(), ".tmp", null);
            tmpFile.deleteOnExit();
            FileOutputStream fos = new FileOutputStream(tmpFile);
            byte[] bytes = new byte[4096];
            ThreadLocalRandom.current().nextBytes(bytes);
            try {
                fos.write(bytes);
                fos.flush();
            } finally {
                fos.close();
            }
            test.setContent(tmpFile);
            ByteBuf buf = test.getByteBuf();
            assertEquals(buf.readerIndex(), 0);
            assertEquals(buf.writerIndex(), bytes.length);
            assertArrayEquals(bytes, test.get());
            assertArrayEquals(bytes, ByteBufUtil.getBytes(buf));
        } finally {
            //release the ByteBuf
            test.delete();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSetContentFromFile() do?
testSetContentFromFile() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpDataTest.java.
Where is testSetContentFromFile() defined?
testSetContentFromFile() is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpDataTest.java at line 46.
What does testSetContentFromFile() call?
testSetContentFromFile() calls 1 function(s): TestHttpData.

Analyze Your Own Codebase

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

Try Supermodel Free