use of io.vertx.core.dns.impl.DnsClientImpl in project vert.x by eclipse.
the class DNSTest method testResolveA.
@Test
public void testResolveA() throws Exception {
final String ip = "10.0.0.1";
dnsServer.testResolveA(ip);
DnsClient dns = prepareDns();
dns.resolveA("vertx.io", onSuccess(result -> {
assertFalse(result.isEmpty());
assertEquals(1, result.size());
assertEquals(ip, result.get(0));
((DnsClientImpl) dns).inProgressQueries(num -> {
assertEquals(0, (int) num);
testComplete();
});
}));
await();
}
use of io.vertx.core.dns.impl.DnsClientImpl in project vert.x by eclipse.
the class DNSTest method testRecursionNotDesired.
@Test
public void testRecursionNotDesired() throws Exception {
final String ip = "10.0.0.1";
dnsServer.testResolveA(ip);
DnsClient dns = prepareDns(new DnsClientOptions().setRecursionDesired(false));
dns.resolveA("vertx.io", onSuccess(result -> {
assertFalse(result.isEmpty());
assertEquals(1, result.size());
assertEquals(ip, result.get(0));
DnsMessage msg = dnsServer.pollMessage();
assertFalse(msg.isRecursionDesired());
((DnsClientImpl) dns).inProgressQueries(num -> {
assertEquals(0, (int) num);
testComplete();
});
}));
await();
}
use of io.vertx.core.dns.impl.DnsClientImpl in project vert.x by eclipse.
the class VertxImpl method createDnsClient.
@Override
public DnsClient createDnsClient(DnsClientOptions options) {
String host = options.getHost();
int port = options.getPort();
if (host == null || port < 0) {
DnsResolverProvider provider = new DnsResolverProvider(this, addressResolverOptions);
InetSocketAddress address = provider.nameServerAddresses().get(0);
// provide the host and port
options = new DnsClientOptions(options).setHost(address.getAddress().getHostAddress()).setPort(address.getPort());
}
return new DnsClientImpl(this, options);
}
use of io.vertx.core.dns.impl.DnsClientImpl in project vert.x by eclipse.
the class DNSTest method testResolveAIpV6.
@Test
public void testResolveAIpV6() throws Exception {
final String ip = "10.0.0.1";
dnsServer.testResolveA(ip).ipAddress("::1");
// force the fake dns server to Ipv6
DnsClient dns = prepareDns();
dns.resolveA("vertx.io", onSuccess(result -> {
assertFalse(result.isEmpty());
assertEquals(1, result.size());
assertEquals(ip, result.get(0));
((DnsClientImpl) dns).inProgressQueries(num -> {
assertEquals(0, (int) num);
testComplete();
});
}));
await();
}
use of io.vertx.core.dns.impl.DnsClientImpl in project vert.x by eclipse.
the class DNSTest method testTimeout.
@Test
public void testTimeout() throws Exception {
DnsClient dns = vertx.createDnsClient(new DnsClientOptions().setHost("localhost").setPort(10000).setQueryTimeout(5000));
dns.lookup("vertx.io", onFailure(result -> {
assertEquals(VertxException.class, result.getClass());
assertEquals("DNS query timeout for vertx.io.", result.getMessage());
((DnsClientImpl) dns).inProgressQueries(num -> {
assertEquals(0, (int) num);
testComplete();
});
}));
await();
}
Aggregations