Search in sources :

Example 6 with DnsClientOptions

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

the class DNSTest method testTimeout.

@Test
public void testTimeout() throws Exception {
    DnsClient dns = vertx.createDnsClient(new DnsClientOptions().setHost("localhost").setPort(10000).setQueryTimeout(5000));
    dns.lookup("vertx.io", onFailure(result -> {
        assertEquals(VertxException.class, result.getClass());
        assertEquals("DNS query timeout for vertx.io.", result.getMessage());
        ((DnsClientImpl) dns).inProgressQueries(num -> {
            assertEquals(0, (int) num);
            testComplete();
        });
    }));
    await();
}
Also used : DnsClientOptions(io.vertx.core.dns.DnsClientOptions) VertxException(io.vertx.core.VertxException) DnsException(io.vertx.core.dns.DnsException) DnsMessage(org.apache.directory.server.dns.messages.DnsMessage) DnsClientImpl(io.vertx.core.dns.impl.DnsClientImpl) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) Vertx(io.vertx.core.Vertx) DnsClientOptions(io.vertx.core.dns.DnsClientOptions) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) TestUtils.assertNullPointerException(io.vertx.test.core.TestUtils.assertNullPointerException) InetSocketAddress(java.net.InetSocketAddress) Function(java.util.function.Function) VertxTestBase(io.vertx.test.core.VertxTestBase) SrvRecord(io.vertx.core.dns.SrvRecord) DnsClient(io.vertx.core.dns.DnsClient) List(java.util.List) TestUtils(io.vertx.test.core.TestUtils) DeploymentOptions(io.vertx.core.DeploymentOptions) AbstractVerticle(io.vertx.core.AbstractVerticle) DnsResponseCode(io.vertx.core.dns.DnsResponseCode) MxRecord(io.vertx.core.dns.MxRecord) FakeDNSServer(io.vertx.test.fakedns.FakeDNSServer) TestUtils.assertIllegalStateException(io.vertx.test.core.TestUtils.assertIllegalStateException) VertxException(io.vertx.core.VertxException) DnsClient(io.vertx.core.dns.DnsClient) Test(org.junit.Test)

Example 7 with DnsClientOptions

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

the class DNSTest method testRecursionDesired.

@Test
public void testRecursionDesired() throws Exception {
    final String ip = "10.0.0.1";
    dnsServer.testResolveA(ip);
    DnsClient dns = prepareDns(new DnsClientOptions().setRecursionDesired(true));
    dns.resolveA("vertx.io", onSuccess(result -> {
        assertFalse(result.isEmpty());
        assertEquals(1, result.size());
        assertEquals(ip, result.get(0));
        DnsMessage msg = dnsServer.pollMessage();
        assertTrue(msg.isRecursionDesired());
        ((DnsClientImpl) dns).inProgressQueries(num -> {
            assertEquals(0, (int) num);
            testComplete();
        });
    }));
    await();
}
Also used : DnsClientOptions(io.vertx.core.dns.DnsClientOptions) VertxException(io.vertx.core.VertxException) DnsException(io.vertx.core.dns.DnsException) DnsMessage(org.apache.directory.server.dns.messages.DnsMessage) DnsClientImpl(io.vertx.core.dns.impl.DnsClientImpl) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) Vertx(io.vertx.core.Vertx) DnsClientOptions(io.vertx.core.dns.DnsClientOptions) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) TestUtils.assertNullPointerException(io.vertx.test.core.TestUtils.assertNullPointerException) InetSocketAddress(java.net.InetSocketAddress) Function(java.util.function.Function) VertxTestBase(io.vertx.test.core.VertxTestBase) SrvRecord(io.vertx.core.dns.SrvRecord) DnsClient(io.vertx.core.dns.DnsClient) List(java.util.List) TestUtils(io.vertx.test.core.TestUtils) DeploymentOptions(io.vertx.core.DeploymentOptions) AbstractVerticle(io.vertx.core.AbstractVerticle) DnsResponseCode(io.vertx.core.dns.DnsResponseCode) MxRecord(io.vertx.core.dns.MxRecord) FakeDNSServer(io.vertx.test.fakedns.FakeDNSServer) TestUtils.assertIllegalStateException(io.vertx.test.core.TestUtils.assertIllegalStateException) DnsClient(io.vertx.core.dns.DnsClient) DnsMessage(org.apache.directory.server.dns.messages.DnsMessage) Test(org.junit.Test)

Example 8 with DnsClientOptions

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

the class DNSExamples method example1__.

public void example1__(Vertx vertx) {
    DnsClient client1 = vertx.createDnsClient();
    // Just the same but with a different query timeout
    DnsClient client2 = vertx.createDnsClient(new DnsClientOptions().setQueryTimeout(10000));
}
Also used : DnsClientOptions(io.vertx.core.dns.DnsClientOptions) DnsClient(io.vertx.core.dns.DnsClient)

Aggregations

DnsClientOptions (io.vertx.core.dns.DnsClientOptions)8 Test (org.junit.Test)6 DnsClient (io.vertx.core.dns.DnsClient)5 TestLoggerFactory (io.vertx.test.netty.TestLoggerFactory)5 VertxException (io.vertx.core.VertxException)4 DnsException (io.vertx.core.dns.DnsException)4 DnsClientImpl (io.vertx.core.dns.impl.DnsClientImpl)4 TestUtils.assertIllegalStateException (io.vertx.test.core.TestUtils.assertIllegalStateException)4 TestUtils.assertNullPointerException (io.vertx.test.core.TestUtils.assertNullPointerException)4 InetSocketAddress (java.net.InetSocketAddress)4 AbstractVerticle (io.vertx.core.AbstractVerticle)3 DeploymentOptions (io.vertx.core.DeploymentOptions)3 Vertx (io.vertx.core.Vertx)3 VertxOptions (io.vertx.core.VertxOptions)3 DnsResponseCode (io.vertx.core.dns.DnsResponseCode)3 MxRecord (io.vertx.core.dns.MxRecord)3 SrvRecord (io.vertx.core.dns.SrvRecord)3 TestUtils (io.vertx.test.core.TestUtils)3 VertxTestBase (io.vertx.test.core.VertxTestBase)3 FakeDNSServer (io.vertx.test.fakedns.FakeDNSServer)3