Search in sources :

Example 6 with DnsClient

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

the class DNSTest method testResolveMX.

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

Example 7 with DnsClient

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

the class DNSTest method testResolveTXT.

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

Example 8 with DnsClient

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

the class DNSTest method testResolveCNAME.

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

Example 9 with DnsClient

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

the class DNSTest method testResolvePTR.

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

Example 10 with DnsClient

use of io.vertx.core.dns.DnsClient 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)

Aggregations

DnsClient (io.vertx.core.dns.DnsClient)30 Test (org.junit.Test)16 DnsException (io.vertx.core.dns.DnsException)4 MxRecord (io.vertx.core.dns.MxRecord)4 SrvRecord (io.vertx.core.dns.SrvRecord)4 DnsResponseCode (io.vertx.core.dns.DnsResponseCode)3 NioDatagramChannel (io.netty.channel.socket.nio.NioDatagramChannel)2 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 List (java.util.List)2 Bootstrap (io.netty.bootstrap.Bootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 ChannelOption (io.netty.channel.ChannelOption)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 SimpleChannelInboundHandler (io.netty.channel.SimpleChannelInboundHandler)1 DatagramChannel (io.netty.channel.socket.DatagramChannel)1 DatagramDnsQuery (io.netty.handler.codec.dns.DatagramDnsQuery)1