Home / File/ DefaultDnsRecordEncoderTest.java — netty Source File

DefaultDnsRecordEncoderTest.java — netty Source File

Architecture documentation for DefaultDnsRecordEncoderTest.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2016 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.handler.codec.dns;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.internal.SocketUtils;
import io.netty.util.internal.StringUtil;
import org.junit.jupiter.api.Test;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.concurrent.ThreadLocalRandom;

import static org.junit.jupiter.api.Assertions.assertEquals;

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);
// ... (128 more lines)

Domain

Subdomains

Frequently Asked Questions

What does DefaultDnsRecordEncoderTest.java do?
DefaultDnsRecordEncoderTest.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is DefaultDnsRecordEncoderTest.java in the architecture?
DefaultDnsRecordEncoderTest.java is located at codec-dns/src/test/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoderTest.java (domain: Buffer, subdomain: Allocators, directory: codec-dns/src/test/java/io/netty/handler/codec/dns).

Analyze Your Own Codebase

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

Try Supermodel Free