Search in sources :

Example 1 with SrvRecord

use of io.vertx.core.dns.SrvRecord in project vert.x by eclipse.

the class DNSTest method testResolveSRV.

@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();
}
Also used : DnsClient(io.vertx.core.dns.DnsClient) SrvRecord(io.vertx.core.dns.SrvRecord) Test(org.junit.Test)

Example 2 with SrvRecord

use of io.vertx.core.dns.SrvRecord in project vert.x by eclipse.

the class DNSExamples method example12.

public void example12(Vertx vertx) {
    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.resolveSRV("vertx.io", ar -> {
        if (ar.succeeded()) {
            List<SrvRecord> records = ar.result();
            for (SrvRecord record : records) {
                System.out.println(record);
            }
        } else {
            System.out.println("Failed to resolve entry" + ar.cause());
        }
    });
}
Also used : DnsClient(io.vertx.core.dns.DnsClient) SrvRecord(io.vertx.core.dns.SrvRecord)

Aggregations

DnsClient (io.vertx.core.dns.DnsClient)2 SrvRecord (io.vertx.core.dns.SrvRecord)2 Test (org.junit.Test)1