diff --git a/httpclient/pom.xml b/httpclient/pom.xml index be8440f126..bb9bda23ba 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -1,5 +1,4 @@ - + 4.0.0 org.baeldung httpclient @@ -36,11 +35,11 @@ - - org.apache.httpcomponents - httpcore - ${httpcore.version} - + + + + + org.apache.httpcomponents @@ -61,9 +60,9 @@ - org.apache.httpcomponents - httpasyncclient - 4.1-beta1 + org.apache.httpcomponents + httpasyncclient + 4.1-beta1 @@ -179,7 +178,7 @@ 1.10.8 4.3.3 - 4.3.6 + 4.4-beta1 2.4.0 diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientTest.java index beb826850b..151ed10f37 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientTest.java @@ -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 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 { } } -