Home / File/ HostsFileEntriesProviderTest.java — netty Source File

HostsFileEntriesProviderTest.java — netty Source File

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

File java Buffer Search 1 classes

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2021 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.resolver;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.net.InetAddress;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;

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

class HostsFileEntriesProviderTest {

    @Test
    void testParse() throws IOException {
        String hostsString = new StringBuilder()
                .append("127.0.0.1 host1").append("\n") // single hostname, separated with blanks
                .append("::1 host1").append("\n") // same as above, but IPv6
                .append("\n") // empty line
                .append("192.168.0.1\thost2").append("\n") // single hostname, separated with tabs
                .append("#comment").append("\n") // comment at the beginning of the line
                .append(" #comment  ").append("\n") // comment in the middle of the line
                .append("192.168.0.2  host3  #comment").append("\n") // comment after hostname
                .append("192.168.0.3  host4  host5 host6").append("\n") // multiple aliases
                .append("192.168.0.4  host4").append("\n") // host mapped to a second address, must be considered
                .append("192.168.0.5  HOST7").append("\n") // uppercase host, should match lowercase host
                .append("192.168.0.6  host7").append("\n") // must be considered
                .toString();

        HostsFileEntriesProvider entries = HostsFileEntriesProvider.parser()
                .parse(new BufferedReader(new StringReader(hostsString)));
        Map<String, List<InetAddress>> inet4Entries = entries.ipv4Entries();
        Map<String, List<InetAddress>> inet6Entries = entries.ipv6Entries();

        assertEquals(7, inet4Entries.size(), "Expected 7 IPv4 entries");
        assertEquals(1, inet6Entries.size(), "Expected 1 IPv6 entries");

// ... (87 more lines)

Domain

Subdomains

Frequently Asked Questions

What does HostsFileEntriesProviderTest.java do?
HostsFileEntriesProviderTest.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Search subdomain.
Where is HostsFileEntriesProviderTest.java in the architecture?
HostsFileEntriesProviderTest.java is located at resolver/src/test/java/io/netty/resolver/HostsFileEntriesProviderTest.java (domain: Buffer, subdomain: Search, directory: resolver/src/test/java/io/netty/resolver).

Analyze Your Own Codebase

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

Try Supermodel Free