use of org.apache.http.conn.DnsResolver in project helios by spotify.
the class EndpointsTest method testInvalidUri_NoScheme.
@Test
public void testInvalidUri_NoScheme() throws Exception {
final DnsResolver resolver = mock(DnsResolver.class);
when(resolver.resolve("example.com")).thenReturn(IPS_1);
exception.expect(IllegalArgumentException.class);
Endpoints.of(ImmutableList.of(new URI(null, "example.com", null, null)), resolver);
}
use of org.apache.http.conn.DnsResolver in project helios by spotify.
the class EndpointsTest method testFactory.
@Test
public void testFactory() throws Exception {
final DnsResolver resolver = mock(DnsResolver.class);
when(resolver.resolve("example.com")).thenReturn(IPS_1);
when(resolver.resolve("example.net")).thenReturn(IPS_2);
final List<Endpoint> endpoints = Endpoints.of(uris, resolver);
assertThat(endpoints.size(), equalTo(4));
assertThat(endpoints.get(0).getUri(), equalTo(uri1));
assertThat(endpoints.get(0).getIp(), equalTo(IP_A));
assertThat(endpoints.get(1).getUri(), equalTo(uri1));
assertThat(endpoints.get(1).getIp(), equalTo(IP_B));
assertThat(endpoints.get(2).getUri(), equalTo(uri2));
assertThat(endpoints.get(2).getIp(), equalTo(IP_C));
assertThat(endpoints.get(3).getUri(), equalTo(uri2));
assertThat(endpoints.get(3).getIp(), equalTo(IP_D));
}
use of org.apache.http.conn.DnsResolver in project helios by spotify.
the class EndpointsTest method testSupplierFactory.
@Test
public void testSupplierFactory() throws Exception {
final DnsResolver resolver = mock(DnsResolver.class);
when(resolver.resolve("example.com")).thenReturn(IPS_1);
when(resolver.resolve("example.net")).thenReturn(IPS_2);
final Supplier<List<URI>> uriSupplier = Suppliers.ofInstance(uris);
final Supplier<List<Endpoint>> endpointSupplier = Endpoints.of(uriSupplier, resolver);
final List<Endpoint> endpoints = endpointSupplier.get();
assertThat(endpoints.size(), equalTo(4));
assertThat(endpoints.get(0).getUri(), equalTo(uri1));
assertThat(endpoints.get(0).getIp(), equalTo(IP_A));
assertThat(endpoints.get(1).getUri(), equalTo(uri1));
assertThat(endpoints.get(1).getIp(), equalTo(IP_B));
assertThat(endpoints.get(2).getUri(), equalTo(uri2));
assertThat(endpoints.get(2).getIp(), equalTo(IP_C));
assertThat(endpoints.get(3).getUri(), equalTo(uri2));
assertThat(endpoints.get(3).getIp(), equalTo(IP_D));
}
Aggregations