httpclient - timeout simulation for a domain
This commit is contained in:
parent
8f7f048ed4
commit
b4c1acebb2
|
@ -92,4 +92,20 @@ public class HttpClientTimeoutLiveTest {
|
|||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
}
|
||||
|
||||
/**
|
||||
* This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP)
|
||||
*/
|
||||
@Test
|
||||
public final void givenTimeoutIsConfigured_whenTimingOut_thenCorrect() throws ClientProtocolException, IOException {
|
||||
final int timeout = 3;
|
||||
|
||||
final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build();
|
||||
final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
||||
|
||||
final HttpGet request = new HttpGet("http://www.google.com:81");
|
||||
response = client.execute(request);
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue