Search in sources :

Example 1 with ResolutionResult

use of io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.ResolutionResult in project servicetalk by apple.

the class DnsServiceDiscovererObserverTest method aQueryResolutionResult.

private void aQueryResolutionResult(ResultsVerifier<BlockingQueue<ResolutionResult>> verifier) throws Exception {
    BlockingQueue<ResolutionResult> results = new LinkedBlockingDeque<>();
    DnsClient client = dnsClient(__ -> name -> new NoopDnsResolutionObserver() {

        @Override
        public void resolutionCompleted(final ResolutionResult result) {
            results.add(result);
        }
    });
    assertThat("Unexpected calls to resolutionCompleted", results, hasSize(0));
    Cancellable discovery = client.dnsQuery(HOST_NAME).forEach(__ -> {
    });
    try {
        verifier.verify(results);
    } finally {
        discovery.cancel();
    }
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) Cancellable(io.servicetalk.concurrent.Cancellable) ResolutionResult(io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.ResolutionResult)

Aggregations

Cancellable (io.servicetalk.concurrent.Cancellable)1 ResolutionResult (io.servicetalk.dns.discovery.netty.DnsServiceDiscovererObserver.ResolutionResult)1 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)1