@Test public void testLookupNonExisting() throws Exception { DnsClient dns = prepareDns(FakeDNSServer.testLookupNonExisting()); dns.lookup( "gfegjegjf.sg1", ar -> { DnsException cause = (DnsException) ar.cause(); assertEquals(DnsResponseCode.NXDOMAIN, cause.code()); testComplete(); }); await(); dnsServer.stop(); }
@Test public void testLookup() throws Exception { final String ip = "10.0.0.1"; DnsClient dns = prepareDns(FakeDNSServer.testLookup(ip)); dns.lookup( "vertx.io", ar -> { String result = ar.result(); assertNotNull(result); assertEquals(ip, result); testComplete(); }); await(); dnsServer.stop(); }
@Test public void testIllegalArguments() throws Exception { DnsClient dns = prepareDns(FakeDNSServer.testResolveAAAA("::1")); 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 -> {})); dnsServer.stop(); }