use of okhttp3.Dns in project okhttp by square.
the class EventListenerTest method emptyDnsLookup.
@Test
public void emptyDnsLookup() {
Dns emptyDns = hostname -> Collections.emptyList();
client = client.newBuilder().dns(emptyDns).build();
Call call = client.newCall(new Request.Builder().url("http://fakeurl/").build());
try {
call.execute();
fail();
} catch (IOException expected) {
}
listener.removeUpToEvent(DnsStart.class);
CallFailed callFailed = listener.removeUpToEvent(CallFailed.class);
assertThat(callFailed.getCall()).isSameAs(call);
assertThat(callFailed.getIoe()).isInstanceOf(UnknownHostException.class);
}
Aggregations