private void testDefaultDnsClient(Function<Vertx, DnsClient> clientProvider) throws Exception { final String ip = "10.0.0.1"; dnsServer.testLookup4(ip); VertxOptions vertxOptions = new VertxOptions(); InetSocketAddress fakeServerAddress = dnsServer.localAddress(); vertxOptions.getAddressResolverOptions().addServer(fakeServerAddress.getHostString() + ":" + fakeServerAddress.getPort()); Vertx vertxWithFakeDns = Vertx.vertx(vertxOptions); DnsClient dnsClient = clientProvider.apply(vertxWithFakeDns); dnsClient.lookup4("vertx.io", onSuccess(result -> { assertEquals(ip, result); testComplete(); })); await(); vertxWithFakeDns.close(); }
@Test public void testLookup4CNAME() throws Exception { final String cname = "cname.vertx.io"; final String ip = "10.0.0.1"; dnsServer.testLookup4CNAME(cname, ip); DnsClient dns = prepareDns(); dns.lookup4("vertx.io", onSuccess(result -> { assertEquals(ip, result); testComplete(); })); await(); }
@Test public void testLookup4() throws Exception { final String ip = "10.0.0.1"; dnsServer.testLookup4(ip); DnsClient dns = prepareDns(); dns.lookup4("vertx.io", onSuccess(result -> { assertEquals(ip, result); DnsMessage msg = dnsServer.pollMessage(); assertTrue(msg.isRecursionDesired()); 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 -> {})); }
/** * Try to lookup the A (ipv4) record for the given name. The first found will be used. * @param name the name to resolve * @param handler the to notify with the {@link io.vertx.core.AsyncResult}. The handler will get notified with the resolved {@link java.net.Inet4Address} 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 lookup4(String name, Handler<AsyncResult<String>> handler) { delegate.lookup4(name, handler); return this; }
/** * Try to lookup the A (ipv4) record for the given name. The first found will be used. * @param name the name to resolve * @param handler the to notify with the {@link io.vertx.core.AsyncResult}. The handler will get notified with the resolved {@link java.net.Inet4Address} 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 lookup4(String name, Handler<AsyncResult<String>> handler) { delegate.lookup4(name, handler); return this; }
private void testDefaultDnsClient(Function<Vertx, DnsClient> clientProvider) throws Exception { final String ip = "10.0.0.1"; dnsServer.testLookup4(ip); VertxOptions vertxOptions = new VertxOptions(); InetSocketAddress fakeServerAddress = dnsServer.localAddress(); vertxOptions.getAddressResolverOptions().addServer(fakeServerAddress.getHostString() + ":" + fakeServerAddress.getPort()); Vertx vertxWithFakeDns = Vertx.vertx(vertxOptions); DnsClient dnsClient = clientProvider.apply(vertxWithFakeDns); dnsClient.lookup4("vertx.io", onSuccess(result -> { assertEquals(ip, result); testComplete(); })); await(); vertxWithFakeDns.close(); }
@Test public void testLookup4CNAME() throws Exception { final String cname = "cname.vertx.io"; final String ip = "10.0.0.1"; dnsServer.testLookup4CNAME(cname, ip); DnsClient dns = prepareDns(); dns.lookup4("vertx.io", onSuccess(result -> { assertEquals(ip, result); testComplete(); })); await(); }
@Test public void testLookup4() throws Exception { final String ip = "10.0.0.1"; dnsServer.testLookup4(ip); DnsClient dns = prepareDns(); dns.lookup4("vertx.io", onSuccess(result -> { assertEquals(ip, result); DnsMessage msg = dnsServer.pollMessage(); assertTrue(msg.isRecursionDesired()); 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 -> {})); }