public class TestDefaultClientConnectOperator {
@Test
public void testCustomDnsResolver() throws Exception {
DnsResolver dnsResolver = mock(DnsResolver.class);
InetAddress[] firstAddress = translateIp("192.168.1.1");
when(dnsResolver.resolve("somehost.example.com")).thenReturn(firstAddress);
InetAddress[] secondAddress = translateIp("192.168.12.16");
when(dnsResolver.resolve("otherhost.example.com")).thenReturn(secondAddress);
DefaultClientConnectionOperator operator = new DefaultClientConnectionOperator(
SchemeRegistryFactory.createDefault(), dnsResolver);
Assert.assertArrayEquals(firstAddress, operator.resolveHostname("somehost.example.com"));