@Test public void testLookupNonExisting() throws Exception { dnsServer.testLookupNonExisting(); DnsClient dns = prepareDns(); dns.lookup("gfegjegjf.sg1", ar -> { DnsException cause = (DnsException)ar.cause(); assertEquals(DnsResponseCode.NXDOMAIN, cause.code()); testComplete(); }); await(); }
@Test public void testIllegalArguments() throws Exception { dnsServer.testResolveAAAA("::1"); DnsClient dns = prepareDns(); assertNullPointerException(() -> dns.lookup(null, ar -> {})); assertNullPointerException(() -> dns.lookup4(null, ar -> {})); assertNullPointerException(() -> dns.lookup6(null, ar -> {})); assertNullPointerException(() -> dns.resolveA(null, ar -> {})); assertNullPointerException(() -> dns.resolveAAAA(null, ar -> {})); assertNullPointerException(() -> dns.resolveCNAME(null, ar -> {})); assertNullPointerException(() -> dns.resolveMX(null, ar -> {})); assertNullPointerException(() -> dns.resolveTXT(null, ar -> {})); assertNullPointerException(() -> dns.resolvePTR(null, ar -> {})); assertNullPointerException(() -> dns.resolveNS(null, ar -> {})); assertNullPointerException(() -> dns.resolveSRV(null, ar -> {})); }
@Test public void testIllegalArguments() throws Exception { dnsServer.testResolveAAAA("::1"); DnsClient dns = prepareDns(); assertNullPointerException(() -> dns.lookup(null, ar -> {})); assertNullPointerException(() -> dns.lookup4(null, ar -> {})); assertNullPointerException(() -> dns.lookup6(null, ar -> {})); assertNullPointerException(() -> dns.resolveA(null, ar -> {})); assertNullPointerException(() -> dns.resolveAAAA(null, ar -> {})); assertNullPointerException(() -> dns.resolveCNAME(null, ar -> {})); assertNullPointerException(() -> dns.resolveMX(null, ar -> {})); assertNullPointerException(() -> dns.resolveTXT(null, ar -> {})); assertNullPointerException(() -> dns.resolvePTR(null, ar -> {})); assertNullPointerException(() -> dns.resolveNS(null, ar -> {})); assertNullPointerException(() -> dns.resolveSRV(null, ar -> {})); }
@Test public void testLookup() throws Exception { String ip = "10.0.0.1"; dnsServer.testLookup(ip); DnsClient dns = prepareDns(); dns.lookup("vertx.io", onSuccess(result -> { assertEquals(ip, result); testComplete(); })); await(); }
@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(); }
/** * Try to lookup the A (ipv4) or AAAA (ipv6) record for the given name. The first found will be used. * @param name the name to resolve * @param handler the {@link io.vertx.core.Handler} to notify with the {@link io.vertx.core.AsyncResult}. The handler will get notified with the resolved address if a record was found. If non was found it will get notifed with <code>null</code>. If an error accours it will get failed. * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.dns.DnsClient lookup(String name, Handler<AsyncResult<String>> handler) { delegate.lookup(name, handler); return this; }
/** * Try to lookup the A (ipv4) or AAAA (ipv6) record for the given name. The first found will be used. * @param name the name to resolve * @param handler the {@link io.vertx.core.Handler} to notify with the {@link io.vertx.core.AsyncResult}. The handler will get notified with the resolved address if a record was found. If non was found it will get notifed with <code>null</code>. If an error accours it will get failed. * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.dns.DnsClient lookup(String name, Handler<AsyncResult<String>> handler) { delegate.lookup(name, handler); return this; }
@Test public void testLookupNonExisting() throws Exception { dnsServer.testLookupNonExisting(); DnsClient dns = prepareDns(); dns.lookup("gfegjegjf.sg1", ar -> { DnsException cause = (DnsException)ar.cause(); assertEquals(DnsResponseCode.NXDOMAIN, cause.code()); testComplete(); }); await(); }
@Test public void testLookup() throws Exception { String ip = "10.0.0.1"; dnsServer.testLookup(ip); DnsClient dns = prepareDns(); dns.lookup("vertx.io", onSuccess(result -> { assertEquals(ip, result); testComplete(); })); await(); }
@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(); }
readinessHandler.register("authentication-service-availability", status -> { log.trace("checking availability of Authentication service"); dnsClient.lookup(getConfig().getHost(), lookupAttempt -> { if (lookupAttempt.succeeded()) { status.tryComplete(Status.OK());
readinessHandler.register("authentication-service-availability", status -> { log.trace("checking availability of Authentication service"); dnsClient.lookup(getConfig().getHost(), lookupAttempt -> { if (lookupAttempt.succeeded()) { status.tryComplete(Status.OK());