Search in sources :

Example 1 with DnsClient

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

the class DNSTest method testResolveA.

@Test
public void testResolveA() throws Exception {
    final String ip = "10.0.0.1";
    DnsClient dns = prepareDns(FakeDNSServer.testResolveA(ip));
    dns.resolveA("vertx.io", ar -> {
        List<String> result = ar.result();
        assertNotNull(result);
        assertFalse(result.isEmpty());
        assertEquals(1, result.size());
        assertEquals(ip, result.get(0));
        testComplete();
    });
    await();
    dnsServer.stop();
}
Also used : DnsClient(io.vertx.core.dns.DnsClient) Test(org.junit.Test)

Example 2 with DnsClient

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

the class DNSTest method testReverseLookupIpv6.

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

Example 3 with DnsClient

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

the class DNSTest method testLookup4CNAME.

@Test
public void testLookup4CNAME() throws Exception {
    final String cname = "cname.vertx.io";
    final String ip = "10.0.0.1";
    DnsClient dns = prepareDns(FakeDNSServer.testLookup4CNAME(cname, ip));
    dns.lookup4("vertx.io", ar -> {
        String result = ar.result();
        assertEquals(ip, result);
        testComplete();
    });
    await();
    dnsServer.stop();
}
Also used : DnsClient(io.vertx.core.dns.DnsClient) Test(org.junit.Test)

Example 4 with DnsClient

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

the class DNSTest method testLookup4.

@Test
public void testLookup4() throws Exception {
    final String ip = "10.0.0.1";
    DnsClient dns = prepareDns(FakeDNSServer.testLookup4(ip));
    dns.lookup4("vertx.io", ar -> {
        String result = ar.result();
        assertNotNull(result);
        assertEquals(ip, result);
        testComplete();
    });
    await();
    dnsServer.stop();
}
Also used : DnsClient(io.vertx.core.dns.DnsClient) Test(org.junit.Test)

Example 5 with DnsClient

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

the class DNSTest method testLookup.

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