http async client cleanup
This commit is contained in:
parent
bbe2806eb4
commit
6e96338fb5
|
@ -1,5 +1,4 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
@ -36,11 +35,11 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>${httpcore.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.apache.httpcomponents</groupId> -->
|
||||
<!-- <artifactId>httpcore</artifactId> -->
|
||||
<!-- <version>${httpcore.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
|
@ -63,7 +62,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpasyncclient</artifactId>
|
||||
<version>4.1-beta1</version>
|
||||
<version>4.1-beta1</version> <!-- 4.0.2 --> <!-- 4.1-beta1 -->
|
||||
</dependency>
|
||||
|
||||
<!-- logging -->
|
||||
|
@ -179,7 +178,7 @@
|
|||
<mockito.version>1.10.8</mockito.version>
|
||||
|
||||
<httpcore.version>4.3.3</httpcore.version>
|
||||
<httpclient.version>4.3.6</httpclient.version>
|
||||
<httpclient.version>4.4-beta1</httpclient.version> <!-- 4.3.6 --> <!-- 4.4-beta1 -->
|
||||
|
||||
<rest-assured.version>2.4.0</rest-assured.version>
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.baeldung.httpclient;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
@ -44,14 +46,17 @@ public class HttpAsyncClientTest {
|
|||
private static final String COOKIE_DOMAIN = ".yuilibrary.com"; // ".github.com";
|
||||
private static final String COOKIE_NAME = "example"; // "JSESSIONID";
|
||||
|
||||
// tests
|
||||
|
||||
@Test
|
||||
public void whenUseHttpAsyncClient_thenCorrect() throws Exception {
|
||||
public void whenUseHttpAsyncClient_thenCorrect() throws InterruptedException, ExecutionException, IOException {
|
||||
final CloseableHttpAsyncClient client = HttpAsyncClients.createDefault();
|
||||
client.start();
|
||||
// client.start();
|
||||
final HttpGet request = new HttpGet(HOST);
|
||||
|
||||
final Future<HttpResponse> future = client.execute(request, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
client.close();
|
||||
}
|
||||
|
@ -114,7 +119,6 @@ public class HttpAsyncClientTest {
|
|||
client.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenUseCookiesWithHttpAsyncClient_thenCorrect() throws Exception {
|
||||
final BasicCookieStore cookieStore = new BasicCookieStore();
|
||||
|
@ -138,8 +142,8 @@ public class HttpAsyncClientTest {
|
|||
@Test
|
||||
public void whenUseAuthenticationWithHttpAsyncClient_thenCorrect() throws Exception {
|
||||
final CredentialsProvider provider = new BasicCredentialsProvider();
|
||||
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(DEFAULT_USER, DEFAULT_PASS);
|
||||
provider.setCredentials(AuthScope.ANY, credentials);
|
||||
final UsernamePasswordCredentials creds = new UsernamePasswordCredentials(DEFAULT_USER, DEFAULT_PASS);
|
||||
provider.setCredentials(AuthScope.ANY, creds);
|
||||
final CloseableHttpAsyncClient client = HttpAsyncClients.custom().setDefaultCredentialsProvider(provider).build();
|
||||
|
||||
final HttpGet request = new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION);
|
||||
|
@ -175,4 +179,3 @@ public class HttpAsyncClientTest {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue