@Test public void testResolveMX() throws Exception { final String mxRecord = "mail.vertx.io"; final int prio = 10; dnsServer.testResolveMX(prio, mxRecord); DnsClient dns = prepareDns(); dns.resolveMX("vertx.io", onSuccess(result -> { assertFalse(result.isEmpty()); assertEquals(1, result.size()); MxRecord record = result.get(0); assertEquals(prio, record.priority()); assertEquals(record.name(), mxRecord); 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 resolve the MX records for the given name. * @param name the name for which the MX records should be resolved * @param handler the {@link io.vertx.core.Handler} to notify with the {@link io.vertx.core.AsyncResult}. The handler will get notified with a List that contains all resolved {@link io.vertx.rxjava.core.dns.MxRecord}s, sorted by their {@link io.vertx.rxjava.core.dns.MxRecord#priority}. If non was found it will get notified with an empty {@link java.util.List}. 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 resolveMX(String name, Handler<AsyncResult<List<io.vertx.rxjava.core.dns.MxRecord>>> handler) { delegate.resolveMX(name, new Handler<AsyncResult<java.util.List<io.vertx.core.dns.MxRecord>>>() { public void handle(AsyncResult<java.util.List<io.vertx.core.dns.MxRecord>> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(ar.result().stream().map(elt -> io.vertx.rxjava.core.dns.MxRecord.newInstance(elt)).collect(java.util.stream.Collectors.toList()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Try to resolve the MX records for the given name. * @param name the name for which the MX records should be resolved * @param handler the {@link io.vertx.core.Handler} to notify with the {@link io.vertx.core.AsyncResult}. The handler will get notified with a List that contains all resolved {@link io.vertx.rxjava.core.dns.MxRecord}s, sorted by their {@link io.vertx.rxjava.core.dns.MxRecord#priority}. If non was found it will get notified with an empty {@link java.util.List}. 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 resolveMX(String name, Handler<AsyncResult<List<io.vertx.rxjava.core.dns.MxRecord>>> handler) { delegate.resolveMX(name, new Handler<AsyncResult<java.util.List<io.vertx.core.dns.MxRecord>>>() { public void handle(AsyncResult<java.util.List<io.vertx.core.dns.MxRecord>> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(ar.result().stream().map(elt -> io.vertx.rxjava.core.dns.MxRecord.newInstance(elt)).collect(java.util.stream.Collectors.toList()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
@Test public void testResolveMX() throws Exception { final String mxRecord = "mail.vertx.io"; final int prio = 10; dnsServer.testResolveMX(prio, mxRecord); DnsClient dns = prepareDns(); dns.resolveMX("vertx.io", onSuccess(result -> { assertFalse(result.isEmpty()); assertEquals(1, result.size()); MxRecord record = result.get(0); assertEquals(prio, record.priority()); assertEquals(record.name(), mxRecord); 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 -> {})); }