Search in sources :

Example 1 with MxRecord

use of io.vertx.core.dns.MxRecord 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 2 with MxRecord

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

the class DNSExamples method example8.

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

Example 3 with MxRecord

use of io.vertx.core.dns.MxRecord 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;
    dnsServer.testResolveMX(prio, mxRecord);
    DnsClient dns = prepareDns();
    dns.resolveMX("vertx.io", onSuccess(result -> {
        assertFalse(result.isEmpty());
        assertEquals(1, result.size());
        MxRecord record = result.get(0);
        assertEquals(prio, record.priority());
        assertEquals(record.name(), mxRecord);
        testComplete();
    }));
    await();
}
Also used : 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) MxRecord(io.vertx.core.dns.MxRecord) Test(org.junit.Test)

Aggregations

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