use of io.vertx.core.dns.DnsClientOptions in project vert.x by eclipse.
the class DNSTest method testDoNotLogActivity.
@Test
public void testDoNotLogActivity() throws Exception {
TestLoggerFactory factory = testLogging(new DnsClientOptions().setLogActivity(false));
assertFalse(factory.hasName("io.netty.handler.logging.LoggingHandler"));
}
use of io.vertx.core.dns.DnsClientOptions 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.DnsClientOptions in project vert.x by eclipse.
the class DNSTest method testUnresolvedDnsServer.
@Test
public void testUnresolvedDnsServer() throws Exception {
try {
DnsClient dns = vertx.createDnsClient(new DnsClientOptions().setHost("iamanunresolvablednsserver.com").setPort(53));
fail();
} catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException);
assertEquals("Cannot resolve the host to a valid ip address", e.getMessage());
}
}
use of io.vertx.core.dns.DnsClientOptions 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.DnsClientOptions in project vert.x by eclipse.
the class DNSTest method testLogActivity.
@Test
public void testLogActivity() throws Exception {
TestLoggerFactory factory = testLogging(new DnsClientOptions().setLogActivity(true));
assertTrue(factory.hasName("io.netty.handler.logging.LoggingHandler"));
}
Aggregations