[BAEL-13598] - Updated HttpClient Timeout article. moved code

This commit is contained in:
amit2103 2019-04-21 20:29:58 +05:30
parent e8e485b801
commit 1cdfa2e2d0
3 changed files with 9 additions and 9 deletions

View File

@ -8,4 +8,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
- [HttpClient 4 Get the Status Code](http://www.baeldung.com/httpclient-status-code)
- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl)
- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl)
- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout)

View File

@ -1,20 +1,20 @@
package org.baeldung.httpclient;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.config.SocketConfig;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.After;
import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
public class HttpClientTimeoutLiveTest {
private CloseableHttpResponse response;
@ -71,7 +71,7 @@ public class HttpClientTimeoutLiveTest {
/**
* This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP)
*/
@Test(expected = HttpHostConnectException.class)
@Test(expected = ConnectTimeoutException.class)
public final void givenTimeoutIsConfigured_whenTimingOut_thenTimeoutException() throws IOException {
final int timeout = 3;

View File

@ -7,6 +7,5 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com
### Relevant Articles:
- [Basic Authentication with the RestTemplate](http://www.baeldung.com/how-to-use-resttemplate-with-basic-authentication-in-spring)
- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout)
- [A Custom Filter in the Spring Security Filter Chain](http://www.baeldung.com/spring-security-custom-filter)
- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication)