@Test public void preferIpv4ButOnlyAAAARecordIsPresent() throws InterruptedException { final String ipv6 = nextIp6(); recordStore.addResponse("apple.com", AAAA, ipv6); final int expectedActiveCount = 1; final int expectedInactiveCount = 0; CountDownLatch latch = new CountDownLatch(expectedActiveCount + expectedInactiveCount); AtomicReference<Throwable> throwableRef = new AtomicReference<>(); Publisher<ServiceDiscovererEvent<InetAddress>> publisher = client.dnsQuery("apple.com") .flatMapConcatIterable(identity()); final TestSubscriber subscriber = new TestSubscriber(latch); toSource(publisher).subscribe(subscriber); latch.await(); assertNull(throwableRef.get()); assertThat(subscriber.activeEventAddresses.size(), equalTo(1)); assertThat(subscriber.activeEventAddresses, hasItem(ipv6)); assertThat(subscriber.inactiveEventAddresses.size(), equalTo(expectedInactiveCount)); }
@Override public Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address) { requireNonNull(address); return defer(() -> new ARecordPublisher(true, address, newDiscoveryObserver(address))); }
DefaultDnsClient implements DnsClient { @Override public Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address) { requireNonNull(address); return defer(() -> new ARecordPublisher(true, address, newDiscoveryObserver(address))); } }
DefaultDnsClient implements DnsClient { @Override public Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address) { requireNonNull(address); return defer(() -> new ARecordPublisher(true, address, newDiscoveryObserver(address))); } DefaultDnsClient(final IoExecutor ioExecutor, final int minTTL,
                     @Nullable final Integer ndots,
                     @Nullable final Boolean optResourceEnabled, @Nullable final Duration queryTimeout,
                     @Nullable final DnsResolverAddressTypes dnsResolverAddressTypes,
                     @Nullable final DnsServerAddressStreamProvider dnsServerAddressStreamProvider,
                     @Nullable final DnsServiceDiscovererObserver observer); }
DefaultDnsClient implements DnsClient { @Override public Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address) { requireNonNull(address); return defer(() -> new ARecordPublisher(true, address, newDiscoveryObserver(address))); } DefaultDnsClient(final IoExecutor ioExecutor, final int minTTL,
                     @Nullable final Integer ndots,
                     @Nullable final Boolean optResourceEnabled, @Nullable final Duration queryTimeout,
                     @Nullable final DnsResolverAddressTypes dnsResolverAddressTypes,
                     @Nullable final DnsServerAddressStreamProvider dnsServerAddressStreamProvider,
                     @Nullable final DnsServiceDiscovererObserver observer); @Override Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address); @Override Publisher<Collection<ServiceDiscovererEvent<InetSocketAddress>>> dnsSrvQuery(final String serviceName); @Override Completable onClose(); @Override Completable closeAsync(); @Override Completable closeAsyncGracefully(); }
DefaultDnsClient implements DnsClient { @Override public Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address) { requireNonNull(address); return defer(() -> new ARecordPublisher(true, address, newDiscoveryObserver(address))); } DefaultDnsClient(final IoExecutor ioExecutor, final int minTTL,
                     @Nullable final Integer ndots,
                     @Nullable final Boolean optResourceEnabled, @Nullable final Duration queryTimeout,
                     @Nullable final DnsResolverAddressTypes dnsResolverAddressTypes,
                     @Nullable final DnsServerAddressStreamProvider dnsServerAddressStreamProvider,
                     @Nullable final DnsServiceDiscovererObserver observer); @Override Publisher<Collection<ServiceDiscovererEvent<InetAddress>>> dnsQuery(final String address); @Override Publisher<Collection<ServiceDiscovererEvent<InetSocketAddress>>> dnsSrvQuery(final String serviceName); @Override Completable onClose(); @Override Completable closeAsync(); @Override Completable closeAsyncGracefully();  }