Home / Class/ DefaultDnsRecordEncoderTest Class — netty Architecture

DefaultDnsRecordEncoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  47911929_f87d_8a18_283d_e24d57ce4e70["DefaultDnsRecordEncoderTest"]
  383cd6f4_1d77_0266_4366_928d0a8407b1["DefaultDnsRecordEncoderTest.java"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|defined in| 383cd6f4_1d77_0266_4366_928d0a8407b1
  f7a06fe1_4a51_2b09_1837_b56c33c1f522["testEncodePtr()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| f7a06fe1_4a51_2b09_1837_b56c33c1f522
  eda52850_32b4_fe66_a834_f528a0430f69["testEncodeName()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| eda52850_32b4_fe66_a834_f528a0430f69
  689c2384_fd3a_0e15_f341_c5f3b183632a["testEncodeNameWithoutTerminator()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| 689c2384_fd3a_0e15_f341_c5f3b183632a
  f84fecd5_67e0_c601_b001_20afb5bdfc9c["testEncodeNameWithExtraTerminator()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| f84fecd5_67e0_c601_b001_20afb5bdfc9c
  c5a3db87_af1a_fef5_db17_916cdb992c6d["testEncodeEmptyName()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| c5a3db87_af1a_fef5_db17_916cdb992c6d
  c0897d7a_cf87_c7a3_3d1f_a707bc6c950d["testEncodeRootName()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| c0897d7a_cf87_c7a3_3d1f_a707bc6c950d
  7d8f1a68_139f_56ca_789d_ddf9e66f3ed6["testOptEcsRecordIpv4()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| 7d8f1a68_139f_56ca_789d_ddf9e66f3ed6
  8e28d2d3_6e6f_1edd_adf9_d1cd1ec68045["testOptEcsRecordIpv6()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| 8e28d2d3_6e6f_1edd_adf9_d1cd1ec68045
  57b29952_14f1_2566_a9bf_06fb1601ced8["testOptEcsRecordIp()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| 57b29952_14f1_2566_a9bf_06fb1601ced8
  02af7f69_bb45_8899_b32e_7cb8d83b8efb["testIp()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| 02af7f69_bb45_8899_b32e_7cb8d83b8efb
  40ccd482_9999_adc8_5082_1a9cde4c7db2["nextInt()"]
  47911929_f87d_8a18_283d_e24d57ce4e70 -->|method| 40ccd482_9999_adc8_5082_1a9cde4c7db2

Relationship Graph

Source Code

codec-dns/src/test/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoderTest.java lines 30–187

public class DefaultDnsRecordEncoderTest {

    @Test
    public void testEncodePtr() throws Exception {
        DefaultDnsRecordEncoder encoder = new DefaultDnsRecordEncoder();
        DnsPtrRecord ptrRecord = new DefaultDnsPtrRecord("131.186.250.142.in-addr.arpa.",
                DnsRecord.CLASS_IN, 80, "fra24s07-in-f3.1e100.net.");
        ByteBuf out = Unpooled.buffer();
        ByteBuf expectedBuf = Unpooled.buffer();
        expectedBuf.writeBytes(
                new byte[] {
                        3, '1', '3', '1',
                        3, '1', '8', '6',
                        3, '2', '5', '0',
                        3, '1', '4', '2',
                        7, 'i', 'n', '-', 'a', 'd', 'd', 'r',
                        4, 'a', 'r', 'p', 'a',
                        0
        });
        expectedBuf.writeShort(DnsRecordType.PTR.intValue());
        expectedBuf.writeShort(DnsRecord.CLASS_IN);
        expectedBuf.writeInt(80);
        byte[] hostname = new byte[] {
                14, 'f', 'r', 'a', '2', '4', 's', '0', '7', '-', 'i', 'n', '-', 'f', '3',
                5, '1', 'e', '1', '0', '0', 3, 'n', 'e', 't',
                0
        };
        expectedBuf.writeShort(hostname.length);
        expectedBuf.writeBytes(hostname);
        try {
            encoder.encodeRecord(ptrRecord, out);
            assertEquals(expectedBuf, out);
        } finally {
            out.release();
            expectedBuf.release();
        }
    }

    @Test
    public void testEncodeName() throws Exception {
        testEncodeName(new byte[] { 5, 'n', 'e', 't', 't', 'y', 2, 'i', 'o', 0 }, "netty.io.");
    }

    @Test
    public void testEncodeNameWithoutTerminator() throws Exception {
        testEncodeName(new byte[] { 5, 'n', 'e', 't', 't', 'y', 2, 'i', 'o', 0 }, "netty.io");
    }

    @Test
    public void testEncodeNameWithExtraTerminator() throws Exception {
        testEncodeName(new byte[] { 5, 'n', 'e', 't', 't', 'y', 2, 'i', 'o', 0 }, "netty.io..");
    }

    // Test for https://github.com/netty/netty/issues/5014
    @Test
    public void testEncodeEmptyName() throws Exception {
        testEncodeName(new byte[] { 0 }, StringUtil.EMPTY_STRING);
    }

    @Test
    public void testEncodeRootName() throws Exception {
        testEncodeName(new byte[] { 0 }, ".");
    }

    private static void testEncodeName(byte[] expected, String name) throws Exception {
        DefaultDnsRecordEncoder encoder = new DefaultDnsRecordEncoder();
        ByteBuf out = Unpooled.buffer();
        ByteBuf expectedBuf = Unpooled.wrappedBuffer(expected);
        try {
            encoder.encodeName(name, out);
            assertEquals(expectedBuf, out);
        } finally {
            out.release();
            expectedBuf.release();
        }
    }

    @Test
    public void testOptEcsRecordIpv4() throws Exception {
        testOptEcsRecordIp(SocketUtils.addressByName("1.2.3.4"));
        testOptEcsRecordIp(SocketUtils.addressByName("1.2.3.255"));

Frequently Asked Questions

What is the DefaultDnsRecordEncoderTest class?
DefaultDnsRecordEncoderTest is a class in the netty codebase, defined in codec-dns/src/test/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoderTest.java.
Where is DefaultDnsRecordEncoderTest defined?
DefaultDnsRecordEncoderTest is defined in codec-dns/src/test/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoderTest.java at line 30.

Analyze Your Own Codebase

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

Try Supermodel Free