Example usage for io.netty.resolver.dns DnsServerAddressStream size

List of usage examples for io.netty.resolver.dns DnsServerAddressStream size

Introduction

In this page you can find the example usage for io.netty.resolver.dns DnsServerAddressStream size.

Prototype

int size();

Source Link

Document

Get the number of times #next() will return a distinct element before repeating or terminating.

Usage

From source file:com.linecorp.armeria.client.endpoint.dns.DnsEndpointGroupBuilderTest.java

License:Apache License

@Test
public void serverAddresses() {
    // Should be set by default.
    assertThat(builder().serverAddressStreamProvider()).isNotNull();

    // Should use the sequential stream when set by a user.
    final DnsServerAddressStreamProvider provider = builder()
            .serverAddresses(new InetSocketAddress("1.1.1.1", 53), new InetSocketAddress("1.0.0.1", 53))
            .serverAddressStreamProvider();

    final DnsServerAddressStream stream = provider.nameServerAddressStream("foo.com");
    assertThat(stream.size()).isEqualTo(2);
    assertThat(stream.next()).isEqualTo(new InetSocketAddress("1.1.1.1", 53));
    assertThat(stream.next()).isEqualTo(new InetSocketAddress("1.0.0.1", 53));
    assertThat(stream.next()).isEqualTo(new InetSocketAddress("1.1.1.1", 53));
    assertThat(stream.next()).isEqualTo(new InetSocketAddress("1.0.0.1", 53));
}