### Question:
UnixResolverDnsServerAddressStreamProvider implements DnsServerAddressStreamProvider { static List<String> parseEtcResolverSearchDomains() throws IOException { return parseEtcResolverSearchDomains(new File(ETC_RESOLV_CONF_FILE)); } UnixResolverDnsServerAddressStreamProvider(File etcResolvConf, File... etcResolverFiles);  UnixResolverDnsServerAddressStreamProvider(String etcResolvConf, String etcResolverDir); @Override DnsServerAddressStream nameServerAddressStream(String hostname);  }### Answer:
@Test public void searchDomainsWithOnlyDomain() throws IOException { File f = buildFile("domain linecorp.local\n" + "nameserver 127.0.0.2\n"); List<String> domains = UnixResolverDnsServerAddressStreamProvider.parseEtcResolverSearchDomains(f); assertEquals(Collections.singletonList("linecorp.local"), domains); }
@Test public void searchDomainsWithOnlySearch() throws IOException { File f = buildFile("search linecorp.local\n" + "nameserver 127.0.0.2\n"); List<String> domains = UnixResolverDnsServerAddressStreamProvider.parseEtcResolverSearchDomains(f); assertEquals(Collections.singletonList("linecorp.local"), domains); }
@Test public void searchDomainsWithMultipleSearch() throws IOException { File f = buildFile("search linecorp.local\n" + "search squarecorp.local\n" + "nameserver 127.0.0.2\n"); List<String> domains = UnixResolverDnsServerAddressStreamProvider.parseEtcResolverSearchDomains(f); assertEquals(Arrays.asList("linecorp.local", "squarecorp.local"), domains); }
@Test public void searchDomainsWithMultipleSearchSeperatedByWhitespace() throws IOException { File f = buildFile("search linecorp.local squarecorp.local\n" + "nameserver 127.0.0.2\n"); List<String> domains = UnixResolverDnsServerAddressStreamProvider.parseEtcResolverSearchDomains(f); assertEquals(Arrays.asList("linecorp.local", "squarecorp.local"), domains); }
@Test public void searchDomainsWithMultipleSearchSeperatedByTab() throws IOException { File f = buildFile("search linecorp.local\tsquarecorp.local\n" + "nameserver 127.0.0.2\n"); List<String> domains = UnixResolverDnsServerAddressStreamProvider.parseEtcResolverSearchDomains(f); assertEquals(Arrays.asList("linecorp.local", "squarecorp.local"), domains); }
@Test public void searchDomainsPrecedence() throws IOException { File f = buildFile("domain linecorp.local\n" + "search squarecorp.local\n" + "nameserver 127.0.0.2\n"); List<String> domains = UnixResolverDnsServerAddressStreamProvider.parseEtcResolverSearchDomains(f); assertEquals(Collections.singletonList("squarecorp.local"), domains); }