use of okhttp3.internal.http.RecordingProxySelector in project okhttp by square.
the class CallTest method connectTimeoutsAttemptsAlternateRoute.
/**
* Make a request with two routes. The first route will time out because it's connecting to a
* special address that never connects. The automatic retry will succeed.
*/
@Test
public void connectTimeoutsAttemptsAlternateRoute() throws Exception {
InetSocketAddress unreachableAddress = new InetSocketAddress("10.255.255.1", 8080);
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, unreachableAddress));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse().setBody("success!"));
client = client.newBuilder().proxySelector(proxySelector).readTimeout(100, TimeUnit.MILLISECONDS).connectTimeout(100, TimeUnit.MILLISECONDS).build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request).assertCode(200).assertBody("success!");
}
use of okhttp3.internal.http.RecordingProxySelector in project okhttp by square.
the class CallTest method readTimeoutFails.
/**
* Make a request with two routes. The first route will fail because the null server connects but
* never responds. The manual retry will succeed.
*/
@Test
public void readTimeoutFails() throws Exception {
InetSocketAddress nullServerAddress = startNullServer();
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, nullServerAddress));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse().setBody("success!"));
client = client.newBuilder().proxySelector(proxySelector).readTimeout(100, TimeUnit.MILLISECONDS).build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request).assertFailure(SocketTimeoutException.class);
executeSynchronously(request).assertCode(200).assertBody("success!");
}
use of okhttp3.internal.http.RecordingProxySelector in project okhttp by square.
the class AddressTest method differentProxySelectorsAreDifferent.
@Test
public void differentProxySelectorsAreDifferent() throws Exception {
Address a = new Address("square.com", 80, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, new RecordingProxySelector());
Address b = new Address("square.com", 80, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, new RecordingProxySelector());
assertFalse(a.equals(b));
}
Aggregations