File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
httpclient/src/test/java/org/baeldung/httpclient Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -92,4 +92,20 @@ public final void givenUsingNewApi_whenSettingTimeoutViaHighLevelApi_thenCorrect
9292 assertThat (response .getStatusLine ().getStatusCode (), equalTo (200 ));
9393 }
9494
95+ /**
96+ * This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP)
97+ */
98+ @ Test
99+ public final void givenTimeoutIsConfigured_whenTimingOut_thenCorrect () throws ClientProtocolException , IOException {
100+ final int timeout = 3 ;
101+
102+ final RequestConfig config = RequestConfig .custom ().setConnectTimeout (timeout * 1000 ).setConnectionRequestTimeout (timeout * 1000 ).setSocketTimeout (timeout * 1000 ).build ();
103+ final CloseableHttpClient client = HttpClientBuilder .create ().setDefaultRequestConfig (config ).build ();
104+
105+ final HttpGet request = new HttpGet ("http://www.google.com:81" );
106+ response = client .execute (request );
107+
108+ assertThat (response .getStatusLine ().getStatusCode (), equalTo (200 ));
109+ }
110+
95111}
You can’t perform that action at this time.
0 commit comments