[BAEL-13598] - Updated HttpClient Timeout article. moved code
This commit is contained in:
parent
e8e485b801
commit
1cdfa2e2d0
@ -9,3 +9,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||||||
|
|
||||||
- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code)
|
- [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)
|
@ -1,20 +1,20 @@
|
|||||||
package org.baeldung.httpclient;
|
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.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.config.SocketConfig;
|
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.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
public class HttpClientTimeoutLiveTest {
|
public class HttpClientTimeoutLiveTest {
|
||||||
|
|
||||||
private CloseableHttpResponse response;
|
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)
|
* 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 {
|
public final void givenTimeoutIsConfigured_whenTimingOut_thenTimeoutException() throws IOException {
|
||||||
final int timeout = 3;
|
final int timeout = 3;
|
||||||
|
|
@ -7,6 +7,5 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com
|
|||||||
|
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Basic Authentication with the RestTemplate](http://www.baeldung.com/how-to-use-resttemplate-with-basic-authentication-in-spring)
|
- [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)
|
- [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)
|
- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user