@Test public void testDefaultDnsClient() throws Exception { testDefaultDnsClient(vertx -> vertx.createDnsClient()); }
private DnsClient prepareDns(DnsClientOptions options) throws Exception { InetSocketAddress addr = dnsServer.localAddress(); return vertx.createDnsClient(new DnsClientOptions(options).setPort(addr.getPort()).setHost(addr.getAddress().getHostAddress())); } }
@Test public void testDefaultDnsClientWithOptions() throws Exception { testDefaultDnsClient(vertx -> vertx.createDnsClient(new DnsClientOptions())); }
@Test public void testUnresolvedDnsServer() throws Exception { final String ip = "10.0.0.1"; 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()); } }
@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(); }
/** * Supply an instance of DnsClient. * * @return DnsClient. */ @Override public DnsClient get() { if (debug) logger.debug("DnsSingleClientSupplier.get()::host = {}, port = {}", host, port); return vertx.createDnsClient(port, host); } }
@Override public DnsClient getIfErrors() { nextAddress(); final URI uri = addressList.get(index); if (debug) logger.debug("DnsClient.get FAIL OVER port {} host {}", uri.getPort(), uri.getHost()); return vertx.createDnsClient(uri.getPort(), uri.getHost()); } }
/** * Get a DNS client. * * @return dns client. */ @Override public DnsClient get() { final URI uri = addressList.get(index); try { if (debug) logger.debug("DnsClient.get port {} host {}", uri.getPort(), uri.getHost()); return vertx.createDnsClient(uri.getPort(), uri.getHost()); } catch (Exception ex) { logger.error("DnsClient.get EXCEPTION ", ex); logger.error("DnsClient.get EXCEPTION port {} host {}", uri.getPort(), uri.getHost()); return getIfErrors(); } }
@Test public void testDefaultDnsClient() throws Exception { testDefaultDnsClient(vertx -> vertx.createDnsClient()); }
private DnsClient prepareDns(DnsClientOptions options) throws Exception { InetSocketAddress addr = dnsServer.localAddress(); return vertx.createDnsClient(new DnsClientOptions(options).setPort(addr.getPort()).setHost(addr.getAddress().getHostAddress())); } }
@Test public void testDefaultDnsClientWithOptions() throws Exception { testDefaultDnsClient(vertx -> vertx.createDnsClient(new DnsClientOptions())); }
@Test public void testUnresolvedDnsServer() throws Exception { final String ip = "10.0.0.1"; 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()); } }
/** * Supply an instance of DnsClient. * @return DnsClient. */ @Override public DnsClient get() { if (debug) logger.debug("DnsSingleClientSupplier.get()::host = {}, port = {}", host, port); return vertx.createDnsClient(port, host); } }
@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(); }
/** * Create a DNS client to connect to the DNS server configured by {@link io.vertx.core.VertxOptions} * <p> * DNS client takes the first configured resolver address provided by } * @return the DNS client */ public io.vertx.rxjava.core.dns.DnsClient createDnsClient() { io.vertx.rxjava.core.dns.DnsClient ret = io.vertx.rxjava.core.dns.DnsClient.newInstance(delegate.createDnsClient()); return ret; }
/** * Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds) * <p/> * @param port the port * @param host the host * @return the DNS client */ public io.vertx.rxjava.core.dns.DnsClient createDnsClient(int port, String host) { io.vertx.rxjava.core.dns.DnsClient ret = io.vertx.rxjava.core.dns.DnsClient.newInstance(delegate.createDnsClient(port, host)); return ret; }
/** * Create a DNS client to connect to a DNS server * @param options the client options * @return the DNS client */ public io.vertx.rxjava.core.dns.DnsClient createDnsClient(DnsClientOptions options) { io.vertx.rxjava.core.dns.DnsClient ret = io.vertx.rxjava.core.dns.DnsClient.newInstance(delegate.createDnsClient(options)); return ret; }
@Override public DnsClient getIfErrors() { nextAddress(); final URI uri = addressList.get(index); if (debug) logger.debug("DnsClient.get FAIL OVER port {} host {}", uri.getPort(), uri.getHost()); return vertx.createDnsClient(uri.getPort(), uri.getHost()); } }
/** * Create a DNS client to connect to a DNS server at the specified host and port, with the default query timeout (5 seconds) * <p/> * @param port the port * @param host the host * @return the DNS client */ public io.vertx.rxjava.core.dns.DnsClient createDnsClient(int port, String host) { io.vertx.rxjava.core.dns.DnsClient ret = io.vertx.rxjava.core.dns.DnsClient.newInstance(delegate.createDnsClient(port, host)); return ret; }
/** * Create a DNS client to connect to a DNS server * @param options the client options * @return the DNS client */ public io.vertx.rxjava.core.dns.DnsClient createDnsClient(DnsClientOptions options) { io.vertx.rxjava.core.dns.DnsClient ret = io.vertx.rxjava.core.dns.DnsClient.newInstance(delegate.createDnsClient(options)); return ret; }