From cf48fe424376eef4984dd91cf028c806540ce9c0 Mon Sep 17 00:00:00 2001 From: Loredana Date: Mon, 29 Apr 2019 15:06:17 +0300 Subject: [PATCH 1/6] rename package, fix file upload tests --- httpclient-simple/README.md | 6 ++---- .../basic/MyBasicAuthenticationEntryPoint.java | 2 +- ...pComponentsClientHttpRequestFactoryBasicAuth.java | 2 +- .../baeldung/client/RestTemplateFactory.java | 2 +- .../baeldung/client/spring/ClientConfig.java | 4 ++-- .../{org => com}/baeldung/filter/CustomFilter.java | 2 +- .../filter/CustomWebSecurityConfigurerAdapter.java | 4 ++-- ...avedRequestAwareAuthenticationSuccessHandler.java | 2 +- .../security/RestAuthenticationEntryPoint.java | 2 +- .../baeldung/spring/SecSecurityConfig.java | 4 ++-- .../java/{org => com}/baeldung/spring/WebConfig.java | 4 ++-- .../baeldung/web/controller/BarController.java | 4 ++-- .../baeldung/web/controller/FooController.java | 4 ++-- .../main/java/{org => com}/baeldung/web/dto/Bar.java | 2 +- .../main/java/{org => com}/baeldung/web/dto/Foo.java | 2 +- .../src/main/resources/webSecurityConfig.xml | 2 +- httpclient-simple/src/main/webapp/WEB-INF/web.xml | 2 +- .../{org => com}/baeldung/client/ClientLiveTest.java | 6 +++--- .../baeldung/client/RestClientLiveManualTest.java | 10 +++------- .../httpclient/HttpClientHeadersLiveTest.java | 2 +- .../httpclient/HttpClientPostingLiveTest.java | 12 ++++++------ .../httpclient/HttpClientTimeoutLiveTest.java | 4 +++- .../baeldung/httpclient/HttpsClientSslLiveTest.java | 2 +- .../baeldung/httpclient/ProgressEntityWrapper.java | 2 +- .../baeldung/httpclient/ResponseUtil.java | 2 +- .../httpclient/base/HttpClientBasicLiveTest.java | 4 ++-- .../httpclient/sec/HttpClientAuthLiveTest.java | 4 ++-- .../httpclient/sec/HttpClientCookieLiveTest.java | 4 ++-- .../{org => com}/baeldung/test/LiveTestSuite.java | 6 +++--- httpclient-simple/src/test/resources/test.in | 1 + 30 files changed, 53 insertions(+), 56 deletions(-) rename httpclient-simple/src/main/java/{org => com}/baeldung/basic/MyBasicAuthenticationEntryPoint.java (97%) rename httpclient-simple/src/main/java/{org => com}/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java (97%) rename httpclient-simple/src/main/java/{org => com}/baeldung/client/RestTemplateFactory.java (97%) rename httpclient-simple/src/main/java/{org => com}/baeldung/client/spring/ClientConfig.java (76%) rename httpclient-simple/src/main/java/{org => com}/baeldung/filter/CustomFilter.java (94%) rename httpclient-simple/src/main/java/{org => com}/baeldung/filter/CustomWebSecurityConfigurerAdapter.java (95%) rename httpclient-simple/src/main/java/{org => com}/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java (98%) rename httpclient-simple/src/main/java/{org => com}/baeldung/security/RestAuthenticationEntryPoint.java (96%) rename httpclient-simple/src/main/java/{org => com}/baeldung/spring/SecSecurityConfig.java (83%) rename httpclient-simple/src/main/java/{org => com}/baeldung/spring/WebConfig.java (92%) rename httpclient-simple/src/main/java/{org => com}/baeldung/web/controller/BarController.java (92%) rename httpclient-simple/src/main/java/{org => com}/baeldung/web/controller/FooController.java (92%) rename httpclient-simple/src/main/java/{org => com}/baeldung/web/dto/Bar.java (86%) rename httpclient-simple/src/main/java/{org => com}/baeldung/web/dto/Foo.java (86%) rename httpclient-simple/src/test/java/{org => com}/baeldung/client/ClientLiveTest.java (94%) rename httpclient-simple/src/test/java/{org => com}/baeldung/client/RestClientLiveManualTest.java (94%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/HttpClientHeadersLiveTest.java (99%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/HttpClientPostingLiveTest.java (93%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/HttpClientTimeoutLiveTest.java (98%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/HttpsClientSslLiveTest.java (99%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/ProgressEntityWrapper.java (98%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/ResponseUtil.java (94%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/base/HttpClientBasicLiveTest.java (96%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/sec/HttpClientAuthLiveTest.java (98%) rename httpclient-simple/src/test/java/{org => com}/baeldung/httpclient/sec/HttpClientCookieLiveTest.java (97%) rename httpclient-simple/src/test/java/{org => com}/baeldung/test/LiveTestSuite.java (64%) create mode 100644 httpclient-simple/src/test/resources/test.in diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index 492f3bc5b4..18fd94c3a8 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -1,9 +1,7 @@ ========= -## HttpClient 4.x Cookbooks and Examples - -###The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +## Articles that are part of the HTTPClient Ebook +# To run the live tests, use the command: mvn clean install -Plive ### Relevant Articles: diff --git a/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java similarity index 97% rename from httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java rename to httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java index 6e580e7a22..380ff9df6b 100644 --- a/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java +++ b/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package org.baeldung.basic; +package com.baeldung.basic; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; diff --git a/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/httpclient-simple/src/main/java/com/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java similarity index 97% rename from httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java rename to httpclient-simple/src/main/java/com/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java index a2f51d343b..81f82a2c1c 100644 --- a/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java +++ b/httpclient-simple/src/main/java/com/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java @@ -1,4 +1,4 @@ -package org.baeldung.client; +package com.baeldung.client; import java.net.URI; diff --git a/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java b/httpclient-simple/src/main/java/com/baeldung/client/RestTemplateFactory.java similarity index 97% rename from httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java rename to httpclient-simple/src/main/java/com/baeldung/client/RestTemplateFactory.java index 3ed0bc82b7..aac4f8cebd 100644 --- a/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ b/httpclient-simple/src/main/java/com/baeldung/client/RestTemplateFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.client; +package com.baeldung.client; import org.apache.http.HttpHost; import org.springframework.beans.factory.FactoryBean; diff --git a/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java b/httpclient-simple/src/main/java/com/baeldung/client/spring/ClientConfig.java similarity index 76% rename from httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java rename to httpclient-simple/src/main/java/com/baeldung/client/spring/ClientConfig.java index 73e602855c..03994b55a5 100644 --- a/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java +++ b/httpclient-simple/src/main/java/com/baeldung/client/spring/ClientConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.client.spring; +package com.baeldung.client.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.client") +@ComponentScan("com.baeldung.client") public class ClientConfig { public ClientConfig() { diff --git a/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java b/httpclient-simple/src/main/java/com/baeldung/filter/CustomFilter.java similarity index 94% rename from httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java rename to httpclient-simple/src/main/java/com/baeldung/filter/CustomFilter.java index 01e5b0b59d..6bb12610fa 100644 --- a/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java +++ b/httpclient-simple/src/main/java/com/baeldung/filter/CustomFilter.java @@ -1,4 +1,4 @@ -package org.baeldung.filter; +package com.baeldung.filter; import org.springframework.web.filter.GenericFilterBean; diff --git a/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java b/httpclient-simple/src/main/java/com/baeldung/filter/CustomWebSecurityConfigurerAdapter.java similarity index 95% rename from httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java rename to httpclient-simple/src/main/java/com/baeldung/filter/CustomWebSecurityConfigurerAdapter.java index 7ca2a80c52..fb597e46c8 100644 --- a/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java +++ b/httpclient-simple/src/main/java/com/baeldung/filter/CustomWebSecurityConfigurerAdapter.java @@ -1,6 +1,6 @@ -package org.baeldung.filter; +package com.baeldung.filter; -import org.baeldung.security.RestAuthenticationEntryPoint; +import com.baeldung.security.RestAuthenticationEntryPoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/httpclient-simple/src/main/java/com/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java similarity index 98% rename from httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java rename to httpclient-simple/src/main/java/com/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java index 698052fa2b..7dc53e3e1e 100644 --- a/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java +++ b/httpclient-simple/src/main/java/com/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.security; +package com.baeldung.security; import java.io.IOException; diff --git a/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/com/baeldung/security/RestAuthenticationEntryPoint.java similarity index 96% rename from httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java rename to httpclient-simple/src/main/java/com/baeldung/security/RestAuthenticationEntryPoint.java index 77aa32ff97..1ae89adb89 100644 --- a/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java +++ b/httpclient-simple/src/main/java/com/baeldung/security/RestAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package org.baeldung.security; +package com.baeldung.security; import java.io.IOException; diff --git a/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/httpclient-simple/src/main/java/com/baeldung/spring/SecSecurityConfig.java similarity index 83% rename from httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java rename to httpclient-simple/src/main/java/com/baeldung/spring/SecSecurityConfig.java index 4ce80dab9f..4ba9d47f8d 100644 --- a/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/httpclient-simple/src/main/java/com/baeldung/spring/SecSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) -@ComponentScan("org.baeldung.security") +@ComponentScan("com.baeldung.security") public class SecSecurityConfig { public SecSecurityConfig() { diff --git a/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java b/httpclient-simple/src/main/java/com/baeldung/spring/WebConfig.java similarity index 92% rename from httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java rename to httpclient-simple/src/main/java/com/baeldung/spring/WebConfig.java index 5876e1307b..8d5c1dc7f1 100644 --- a/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java +++ b/httpclient-simple/src/main/java/com/baeldung/spring/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import java.util.List; @@ -11,7 +11,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc -@ComponentScan("org.baeldung.web") +@ComponentScan("com.baeldung.web") public class WebConfig implements WebMvcConfigurer { public WebConfig() { diff --git a/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java b/httpclient-simple/src/main/java/com/baeldung/web/controller/BarController.java similarity index 92% rename from httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java rename to httpclient-simple/src/main/java/com/baeldung/web/controller/BarController.java index 2bc314baa2..02e6af03af 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/controller/BarController.java @@ -1,6 +1,6 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; -import org.baeldung.web.dto.Bar; +import com.baeldung.web.dto.Bar; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Controller; diff --git a/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java b/httpclient-simple/src/main/java/com/baeldung/web/controller/FooController.java similarity index 92% rename from httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java rename to httpclient-simple/src/main/java/com/baeldung/web/controller/FooController.java index b50edb2dcf..461a5e351a 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/controller/FooController.java @@ -1,6 +1,6 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; -import org.baeldung.web.dto.Foo; +import com.baeldung.web.dto.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java b/httpclient-simple/src/main/java/com/baeldung/web/dto/Bar.java similarity index 86% rename from httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java rename to httpclient-simple/src/main/java/com/baeldung/web/dto/Bar.java index d33e39a823..eb139b0ec1 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/dto/Bar.java @@ -1,4 +1,4 @@ -package org.baeldung.web.dto; +package com.baeldung.web.dto; import java.io.Serializable; diff --git a/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java b/httpclient-simple/src/main/java/com/baeldung/web/dto/Foo.java similarity index 86% rename from httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java rename to httpclient-simple/src/main/java/com/baeldung/web/dto/Foo.java index 09c1dac933..23cfab132d 100644 --- a/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java +++ b/httpclient-simple/src/main/java/com/baeldung/web/dto/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.web.dto; +package com.baeldung.web.dto; import java.io.Serializable; diff --git a/httpclient-simple/src/main/resources/webSecurityConfig.xml b/httpclient-simple/src/main/resources/webSecurityConfig.xml index a93dc841b6..2ff9a1de15 100644 --- a/httpclient-simple/src/main/resources/webSecurityConfig.xml +++ b/httpclient-simple/src/main/resources/webSecurityConfig.xml @@ -23,6 +23,6 @@ - + \ No newline at end of file diff --git a/httpclient-simple/src/main/webapp/WEB-INF/web.xml b/httpclient-simple/src/main/webapp/WEB-INF/web.xml index 83b4aeb0a7..4b2dd54266 100644 --- a/httpclient-simple/src/main/webapp/WEB-INF/web.xml +++ b/httpclient-simple/src/main/webapp/WEB-INF/web.xml @@ -12,7 +12,7 @@ contextConfigLocation - org.baeldung.spring + com.baeldung.spring diff --git a/httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/client/ClientLiveTest.java similarity index 94% rename from httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/client/ClientLiveTest.java index 286ee3c900..78e9813f06 100644 --- a/httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/client/ClientLiveTest.java @@ -1,11 +1,11 @@ -package org.baeldung.client; +package com.baeldung.client; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import org.baeldung.client.spring.ClientConfig; -import org.baeldung.web.dto.Foo; +import com.baeldung.client.spring.ClientConfig; +import com.baeldung.web.dto.Foo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java b/httpclient-simple/src/test/java/com/baeldung/client/RestClientLiveManualTest.java similarity index 94% rename from httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java rename to httpclient-simple/src/test/java/com/baeldung/client/RestClientLiveManualTest.java index 53f259c21d..102f2cdca0 100644 --- a/httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/client/RestClientLiveManualTest.java @@ -1,4 +1,4 @@ -package org.baeldung.client; +package com.baeldung.client; import static org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; import static org.hamcrest.Matchers.equalTo; @@ -50,12 +50,8 @@ public class RestClientLiveManualTest { final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient(); - final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { - @Override - public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { - return true; - } - }; + TrustStrategy acceptingTrustStrategy = (cert, authType) -> true; + final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER); httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf)); diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java similarity index 99% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java index 51c3817da5..44262851fd 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientHeadersLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import com.google.common.collect.Lists; import org.apache.http.Header; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientPostingLiveTest.java similarity index 93% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientPostingLiveTest.java index 39ed8f09ef..f5dff8d757 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientPostingLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -32,7 +32,7 @@ import static org.junit.Assert.assertThat; * NOTE : Need module spring-rest to be running */ public class HttpClientPostingLiveTest { - private static final String SAMPLE_URL = "http://localhost:8082/spring-rest/users"; + private static final String SAMPLE_URL = "http://www.example.com"; private static final String URL_SECURED_BY_BASIC_AUTHENTICATION = "http://browserspy.dk/password-ok.php"; private static final String DEFAULT_USER = "test"; private static final String DEFAULT_PASS = "test"; @@ -69,7 +69,7 @@ public class HttpClientPostingLiveTest { @Test public void whenPostJsonUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/detail"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final String json = "{\"id\":1,\"name\":\"John\"}"; final StringEntity entity = new StringEntity(json); @@ -92,7 +92,7 @@ public class HttpClientPostingLiveTest { @Test public void whenSendMultipartRequestUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/multipart"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("username", DEFAULT_USER); @@ -110,7 +110,7 @@ public class HttpClientPostingLiveTest { @Test public void whenUploadFileUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/upload"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", new File("src/test/resources/test.in"), ContentType.APPLICATION_OCTET_STREAM, "file.ext"); @@ -126,7 +126,7 @@ public class HttpClientPostingLiveTest { @Test public void whenGetUploadFileProgressUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); - final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/upload"); + final HttpPost httpPost = new HttpPost(SAMPLE_URL); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", new File("src/test/resources/test.in"), ContentType.APPLICATION_OCTET_STREAM, "file.ext"); diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientTimeoutLiveTest.java similarity index 98% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientTimeoutLiveTest.java index 8041080b3d..8bd7042dc6 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientTimeoutLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; @@ -20,6 +20,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.params.CoreConnectionPNames; import org.apache.http.params.HttpParams; import org.junit.After; +import org.junit.Ignore; import org.junit.Test; public class HttpClientTimeoutLiveTest { @@ -91,6 +92,7 @@ public class HttpClientTimeoutLiveTest { * This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP) */ @Test(expected = ConnectTimeoutException.class) + @Ignore public final void givenTimeoutIsConfigured_whenTimingOut_thenTimeoutException() throws IOException { final int timeout = 3; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpsClientSslLiveTest.java similarity index 99% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/HttpsClientSslLiveTest.java index 9e95905c70..24ceab0069 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpsClientSslLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/ProgressEntityWrapper.java similarity index 98% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/ProgressEntityWrapper.java index cd00d8711a..c7adf51b3e 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/ProgressEntityWrapper.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import java.io.FilterOutputStream; import java.io.IOException; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/ResponseUtil.java similarity index 94% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/ResponseUtil.java index fd38b95cbe..e9ea08a723 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/ResponseUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/base/HttpClientBasicLiveTest.java similarity index 96% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/base/HttpClientBasicLiveTest.java index fee9dc4343..d1b093394e 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/base/HttpClientBasicLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.base; +package com.baeldung.httpclient.base; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; @@ -8,7 +8,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; -import org.baeldung.httpclient.ResponseUtil; +import com.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientAuthLiveTest.java similarity index 98% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientAuthLiveTest.java index 96278b481a..0f7018a9ac 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientAuthLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.sec; +package com.baeldung.httpclient.sec; import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpHeaders; @@ -17,7 +17,7 @@ import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.protocol.HttpContext; -import org.baeldung.httpclient.ResponseUtil; +import com.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientCookieLiveTest.java similarity index 97% rename from httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java rename to httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientCookieLiveTest.java index ba27aca08d..287b6e996c 100644 --- a/httpclient-simple/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/sec/HttpClientCookieLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.sec; +package com.baeldung.httpclient.sec; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; @@ -10,7 +10,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; -import org.baeldung.httpclient.ResponseUtil; +import com.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java b/httpclient-simple/src/test/java/com/baeldung/test/LiveTestSuite.java similarity index 64% rename from httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java rename to httpclient-simple/src/test/java/com/baeldung/test/LiveTestSuite.java index 8c9b48d056..c864349e02 100644 --- a/httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java +++ b/httpclient-simple/src/test/java/com/baeldung/test/LiveTestSuite.java @@ -1,7 +1,7 @@ -package org.baeldung.test; +package com.baeldung.test; -import org.baeldung.client.ClientLiveTest; -import org.baeldung.client.RestClientLiveManualTest; +import com.baeldung.client.ClientLiveTest; +import com.baeldung.client.RestClientLiveManualTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/httpclient-simple/src/test/resources/test.in b/httpclient-simple/src/test/resources/test.in new file mode 100644 index 0000000000..95d09f2b10 --- /dev/null +++ b/httpclient-simple/src/test/resources/test.in @@ -0,0 +1 @@ +hello world \ No newline at end of file From 4e4d50fae212c7e6013dced01d2b0398a9b0ca1b Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 30 Apr 2019 13:17:30 +0300 Subject: [PATCH 2/6] Update README.md --- httpclient-simple/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index 18fd94c3a8..fc4a53c91a 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -2,6 +2,7 @@ ## Articles that are part of the HTTPClient Ebook # To run the live tests, use the command: mvn clean install -Plive +# This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, for the live Maven profile ### Relevant Articles: From 8f647bbf5e98fca58cef34095f0f0553ea3b2f06 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 30 Apr 2019 13:18:06 +0300 Subject: [PATCH 3/6] Update README.md --- httpclient-simple/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index fc4a53c91a..5dfa6a8a75 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -2,7 +2,8 @@ ## Articles that are part of the HTTPClient Ebook # To run the live tests, use the command: mvn clean install -Plive -# This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, for the live Maven profile +# This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, for the live +# Maven profile ### Relevant Articles: From 639a4572e496a76e3c6f32121a13320e1e1c57f7 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 30 Apr 2019 13:18:34 +0300 Subject: [PATCH 4/6] Update README.md --- httpclient-simple/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index 5dfa6a8a75..c170dcfbe5 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -2,8 +2,8 @@ ## Articles that are part of the HTTPClient Ebook # To run the live tests, use the command: mvn clean install -Plive -# This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, for the live -# Maven profile +# This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, +# for the live Maven profile ### Relevant Articles: From 480d6683baa78d3101b8b1cbcc40e4abd549b32c Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 30 Apr 2019 13:19:51 +0300 Subject: [PATCH 5/6] Update README.md --- httpclient-simple/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index c170dcfbe5..b9d8c5d877 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -1,9 +1,10 @@ ========= -## Articles that are part of the HTTPClient Ebook +## This module contains articles that are part of the HTTPClient Ebook -# To run the live tests, use the command: mvn clean install -Plive -# This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, -# for the live Maven profile +# Running the Tests +To run the live tests, use the command: mvn clean install -Plive +This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, +for the live Maven profile ### Relevant Articles: From 185d062bdb78e722cfbc3370bc3dac6457cc3a0c Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 30 Apr 2019 13:20:55 +0300 Subject: [PATCH 6/6] Update README.md --- httpclient-simple/README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index b9d8c5d877..e3535a133e 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -1,13 +1,6 @@ ========= ## This module contains articles that are part of the HTTPClient Ebook -# Running the Tests -To run the live tests, use the command: mvn clean install -Plive -This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, -for the live Maven profile - -### 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 Timeout](http://www.baeldung.com/httpclient-timeout) @@ -15,3 +8,9 @@ for the live Maven profile - [Custom HTTP Header with the HttpClient](http://www.baeldung.com/httpclient-custom-http-header) - [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) - [Posting with HttpClient](https://www.baeldung.com/httpclient-post-http-request) + + +### Running the Tests +To run the live tests, use the command: mvn clean install -Plive +This will start an embedded Jetty server on port 8082 using the Cargo plugin configured in the pom.xml file, +for the live Maven profile