Beispiel #1
0
  @Test
  public void testResolveSRV() throws Exception {
    final int priority = 10;
    final int weight = 1;
    final int port = 80;
    final String target = "vertx.io";

    DnsClient dns = prepareDns(FakeDNSServer.testResolveSRV(priority, weight, port, target));

    dns.resolveSRV(
        "vertx.io",
        ar -> {
          List<SrvRecord> result = ar.result();
          assertNotNull(result);
          assertFalse(result.isEmpty());
          assertEquals(1, result.size());

          SrvRecord record = result.get(0);

          assertEquals(priority, record.priority());
          assertEquals(weight, record.weight());
          assertEquals(port, record.port());
          assertEquals(target, record.target());

          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #2
0
 @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();
 }
Beispiel #3
0
  @Test
  public void testLookup6() throws Exception {
    DnsClient dns = prepareDns(FakeDNSServer.testLookup6());

    dns.lookup6(
        "vertx.io",
        ar -> {
          String result = ar.result();
          assertNotNull(result);
          assertEquals("0:0:0:0:0:0:0:1", result);
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #4
0
  @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();
  }
Beispiel #5
0
  @Test
  public void testResolvePTR() throws Exception {
    final String ptr = "ptr.vertx.io";
    DnsClient dns = prepareDns(FakeDNSServer.testResolvePTR(ptr));

    dns.resolvePTR(
        "10.0.0.1.in-addr.arpa",
        ar -> {
          String result = ar.result();
          assertNotNull(result);
          assertEquals(ptr, result);
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #6
0
  @Test
  public void testResolveAAAA() throws Exception {
    DnsClient dns = prepareDns(FakeDNSServer.testResolveAAAA("::1"));

    dns.resolveAAAA(
        "vertx.io",
        ar -> {
          List<String> result = ar.result();
          assertNotNull(result);
          assertFalse(result.isEmpty());
          assertEquals(1, result.size());
          assertEquals("0:0:0:0:0:0:0:1", result.get(0));
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #7
0
  @Test
  public void testReverseLookupIpv6() throws Exception {
    final String ptr = "ptr.vertx.io";

    DnsClient dns = prepareDns(FakeDNSServer.testReverseLookup(ptr));

    dns.reverseLookup(
        "::1",
        ar -> {
          String result = ar.result();
          assertNotNull(result);
          assertEquals(ptr, result);
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #8
0
  @Test
  public void testResolveTXT() throws Exception {
    final String txt = "vertx is awesome";
    DnsClient dns = prepareDns(FakeDNSServer.testResolveTXT(txt));

    dns.resolveTXT(
        "vertx.io",
        ar -> {
          List<String> result = ar.result();
          assertNotNull(result);
          assertFalse(result.isEmpty());
          assertEquals(1, result.size());
          assertEquals(txt, result.get(0));
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #9
0
  @Test
  public void testResolveCNAME() throws Exception {
    final String cname = "cname.vertx.io";
    DnsClient dns = prepareDns(FakeDNSServer.testResolveCNAME(cname));

    dns.resolveCNAME(
        "vertx.io",
        ar -> {
          List<String> result = ar.result();
          assertNotNull(result);
          assertFalse(result.isEmpty());
          assertEquals(1, result.size());
          String record = result.get(0);
          assertFalse(record.isEmpty());
          assertEquals(cname, record);
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #10
0
  @Test
  public void testResolveMX() throws Exception {
    final String mxRecord = "mail.vertx.io";
    final int prio = 10;
    DnsClient dns = prepareDns(FakeDNSServer.testResolveMX(prio, mxRecord));

    dns.resolveMX(
        "vertx.io",
        ar -> {
          List<MxRecord> result = ar.result();
          assertNotNull(result);
          assertFalse(result.isEmpty());
          assertEquals(1, result.size());
          MxRecord record = result.get(0);
          assertEquals(prio, record.priority());
          assertEquals(record.name(), mxRecord);
          testComplete();
        });
    await();
    dnsServer.stop();
  }
Beispiel #11
0
  @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();
  }