DnsNameResolver extends InetNameResolver { @Override public void close() { ch.close(); } DnsNameResolver(
            EventLoop eventLoop,
            ChannelFactory<? extends DatagramChannel> channelFactory,
            InetSocketAddress localAddress,
            DnsServerAddresses nameServerAddresses,
            DnsCache resolveCache,
            long queryTimeoutMillis,
            InternetProtocolFamily[] resolvedAddressTypes,
            boolean recursionDesired,
            int maxQueriesPerResolve,
            boolean traceEnabled,
            int maxPayloadSize,
            boolean optResourceEnabled,
            HostsFileEntriesResolver hostsFileEntriesResolver); DnsCache resolveCache(); long queryTimeoutMillis(); List<InternetProtocolFamily> resolvedAddressTypes(); boolean isRecursionDesired(); int maxQueriesPerResolve(); boolean isTraceEnabled(); int maxPayloadSize(); boolean isOptResourceEnabled(); HostsFileEntriesResolver hostsFileEntriesResolver(); @Override void close(); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(DnsQuestion question); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question); Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> query(
            InetSocketAddress nameServerAddr, DnsQuestion question,
            Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise);  }
@Test public void testResolveAorAAAA() throws Exception { DnsNameResolver resolver = newResolver(InternetProtocolFamily.IPv4, InternetProtocolFamily.IPv6).build(); try { testResolve0(resolver, EXCLUSIONS_RESOLVE_A); } finally { resolver.close(); } }
@Test public void testResolveAAAAorA() throws Exception { DnsNameResolver resolver = newResolver(InternetProtocolFamily.IPv6, InternetProtocolFamily.IPv4).build(); try { testResolve0(resolver, EXCLUSIONS_RESOLVE_A); } finally { resolver.close(); } }
@Test public void testResolveA() throws Exception { DnsNameResolver resolver = newResolver(InternetProtocolFamily.IPv4) .ttl(Integer.MAX_VALUE, Integer.MAX_VALUE) .build(); try { final Map<String, InetAddress> resultA = testResolve0(resolver, EXCLUSIONS_RESOLVE_A); final Map<String, InetAddress> resultB = testResolve0(resolver, EXCLUSIONS_RESOLVE_A); assertThat(resultB.size(), is(resultA.size())); for (Entry<String, InetAddress> e: resultA.entrySet()) { InetAddress expected = e.getValue(); InetAddress actual = resultB.get(e.getKey()); if (!actual.equals(expected)) { System.err.println("Cache for " + e.getKey() + ": " + resolver.resolveAll(e.getKey()).getNow()); } assertThat(actual, is(expected)); } } finally { resolver.close(); } }
@Test public void testResolveAAAA() throws Exception { DnsNameResolver resolver = newResolver(InternetProtocolFamily.IPv6).build(); try { testResolve0(resolver, EXCLUSIONS_RESOLVE_AAAA); } finally { resolver.close(); } }
@Test public void testNegativeTtl() throws Exception { final DnsNameResolver resolver = newResolver().negativeTtl(10).build(); try { resolveNonExistentDomain(resolver); final int size = 10000; final List<UnknownHostException> exceptions = new ArrayList<UnknownHostException>(); final Thread negativeLookupThread = new Thread() { @Override public void run() { for (int i = 0; i < size; i++) { exceptions.add(resolveNonExistentDomain(resolver)); if (isInterrupted()) { break; } } } }; negativeLookupThread.start(); negativeLookupThread.join(5000); if (negativeLookupThread.isAlive()) { negativeLookupThread.interrupt(); fail("Cached negative lookups did not finish quickly."); } assertThat(exceptions, hasSize(size)); } finally { resolver.close(); } }
@Test public void testResolveIp() { DnsNameResolver resolver = newResolver().build(); try { InetAddress address = resolver.resolve("10.0.0.1").syncUninterruptibly().getNow(); assertEquals("10.0.0.1", address.getHostAddress()); } finally { resolver.close(); } }