Search in sources :

Example 1 with DnsSrvRecordAddressResolver

use of com.rabbitmq.client.DnsSrvRecordAddressResolver in project rabbitmq-java-client by rabbitmq.

the class DnsSrvRecordAddressResolverTest method recordsParsedAndSorted.

@Test
public void recordsParsedAndSorted() throws IOException {
    DnsSrvRecordAddressResolver resolver = new DnsSrvRecordAddressResolver("rabbitmq") {

        @Override
        protected List<SrvRecord> lookupSrvRecords(String service, String dnsUrls) throws IOException {
            return Arrays.asList(DnsSrvRecordAddressResolver.SrvRecord.fromSrvQueryResult("20 0 5269 alt2.xmpp-server.l.google.com."), DnsSrvRecordAddressResolver.SrvRecord.fromSrvQueryResult("30 0 5269 alt3.xmpp-server.l.google.com."), DnsSrvRecordAddressResolver.SrvRecord.fromSrvQueryResult("10 0 5269 alt1.xmpp-server.l.google.com."), DnsSrvRecordAddressResolver.SrvRecord.fromSrvQueryResult("50 0 5269 alt5.xmpp-server.l.google.com."), DnsSrvRecordAddressResolver.SrvRecord.fromSrvQueryResult("40 0 5269 alt4.xmpp-server.l.google.com."));
        }
    };
    List<Address> addresses = resolver.getAddresses();
    assertThat(addresses.size()).isEqualTo(5);
    assertThat(addresses.get(0).getHost()).isEqualTo("alt1.xmpp-server.l.google.com");
    assertThat(addresses.get(1).getHost()).isEqualTo("alt2.xmpp-server.l.google.com");
    assertThat(addresses.get(2).getHost()).isEqualTo("alt3.xmpp-server.l.google.com");
    assertThat(addresses.get(3).getHost()).isEqualTo("alt4.xmpp-server.l.google.com");
    assertThat(addresses.get(4).getHost()).isEqualTo("alt5.xmpp-server.l.google.com");
}
Also used : Address(com.rabbitmq.client.Address) DnsSrvRecordAddressResolver(com.rabbitmq.client.DnsSrvRecordAddressResolver) Test(org.junit.Test)

Aggregations

Address (com.rabbitmq.client.Address)1 DnsSrvRecordAddressResolver (com.rabbitmq.client.DnsSrvRecordAddressResolver)1 Test (org.junit.Test)1