summaryrefslogtreecommitdiff
path: root/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test')
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryProdHostTest.java17
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java61
2 files changed, 25 insertions, 53 deletions
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryProdHostTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryProdHostTest.java
index 3d7ede90..170ddff9 100644
--- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryProdHostTest.java
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryProdHostTest.java
@@ -11,12 +11,13 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateEncodingException;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
import org.junit.Assert;
import org.junit.Before;
@@ -73,7 +74,7 @@ public class HttpClientFactoryProdHostTest {
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
public void getCustomClientX509AuthWithHsmFacadeTrustStore() throws EaafException, ClientProtocolException,
IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException,
- CertificateEncodingException {
+ CertificateEncodingException, ParseException {
System.setProperty("javax.net.debug", "ssl:handshake");
final HttpClientConfiguration clientConfig = new HttpClientConfiguration(
@@ -89,7 +90,7 @@ public class HttpClientFactoryProdHostTest {
//perform test request
final HttpUriRequest httpGet3 = new HttpGet("https://vollmachten.egiz.gv.at/mms-eid-test/services/GetMandatesService?wsdl");
final CloseableHttpResponse httpResp3 = client.execute(httpGet3);
- Assert.assertEquals("http statusCode", 200, httpResp3.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp3.getCode());
String body = EntityUtils.toString(httpResp3.getEntity());
assertFalse("no http body", body.isEmpty());
assertTrue("no WSDL", body.contains("name=\"GetMandatesOperation\""));
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java
index 7f3982be..269c516e 100644
--- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java
@@ -18,14 +18,14 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.X509Certificate;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.http.StatusLine;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.entity.ContentType;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.message.StatusLine;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -148,7 +148,7 @@ public class HttpClientFactoryTest {
//request webservice
final HttpUriRequest httpGet1 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp1 = client.execute(httpGet1);
- Assert.assertEquals("http statusCode", 200, httpResp1.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp1.getCode());
}
@@ -202,7 +202,7 @@ public class HttpClientFactoryTest {
//request webservice
final HttpUriRequest httpGet2 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp2 = client.execute(httpGet2);
- Assert.assertEquals("http statusCode", 200, httpResp2.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp2.getCode());
//check request contains basic authentication after authentication was requested
final RecordedRequest httpReq1 = mockWebServer.takeRequest();
@@ -233,7 +233,7 @@ public class HttpClientFactoryTest {
//request webservice
final HttpUriRequest httpGet2 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp2 = client.execute(httpGet2);
- Assert.assertEquals("http statusCode", 200, httpResp2.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp2.getCode());
//check request contains basic authentication after authentication was requested
final RecordedRequest httpReq1 = mockWebServer.takeRequest();
@@ -262,7 +262,6 @@ public class HttpClientFactoryTest {
final HttpClientConfiguration config =
new HttpClientConfiguration("jUnit_retry_" + RandomStringUtils.randomAlphabetic(3));
config.setHttpErrorRetryCount(2);
- config.setHttpErrorRetryPost(false);
final CloseableHttpClient client = httpClientFactory.getHttpClient(config);
Assert.assertNotNull("No httpClient", client);
@@ -290,34 +289,6 @@ public class HttpClientFactoryTest {
}
@Test
- public void httpPostRetryOneTime() throws EaafException, InterruptedException,
- ClientProtocolException, IOException {
- final HttpClientConfiguration config =
- new HttpClientConfiguration("jUnit_retry_" + RandomStringUtils.randomAlphabetic(3));
- config.setHttpErrorRetryCount(2);
- config.setHttpErrorRetryPost(true);
-
- final CloseableHttpClient client = httpClientFactory.getHttpClient(config);
- Assert.assertNotNull("No httpClient", client);
-
-
- mockWebServer = new MockWebServer();
- mockServerUrl = mockWebServer.url("/sp/junit");
- mockWebServer.enqueue(new MockResponse()
- .setSocketPolicy(SocketPolicy.NO_RESPONSE)
- .setResponseCode(HttpURLConnection.HTTP_NO_CONTENT));
- mockWebServer.enqueue(new MockResponse().setResponseCode(200)
- .setBody("GetData"));
-
- //request webservice
- final HttpUriRequest httpGet1 = new HttpPost(mockServerUrl.url().toString());
- final StatusLine httpResp1 = client.execute(httpGet1,
- HttpUtils.simpleStatusCodeResponseHandler());
- Assert.assertEquals("http statusCode", 200, httpResp1.getStatusCode());
-
- }
-
- @Test
public void testHttpClientRetryOneTime() throws EaafException, InterruptedException,
ClientProtocolException, IOException {
final HttpClientConfiguration config =
@@ -373,7 +344,7 @@ public class HttpClientFactoryTest {
//request webservice
final HttpUriRequest httpGet1 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp1 = client.execute(httpGet1);
- Assert.assertEquals("http statusCode", 200, httpResp1.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp1.getCode());
}
@@ -543,7 +514,7 @@ public class HttpClientFactoryTest {
//perform test request
final HttpUriRequest httpGet2 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp2 = client.execute(httpGet2);
- Assert.assertEquals("http statusCode", 200, httpResp2.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp2.getCode());
}
@@ -612,7 +583,7 @@ public class HttpClientFactoryTest {
//perform test request
final HttpUriRequest httpGet2 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp2 = client.execute(httpGet2);
- Assert.assertEquals("http statusCode", 200, httpResp2.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp2.getCode());
}
@@ -658,7 +629,7 @@ public class HttpClientFactoryTest {
//perform test request
final HttpUriRequest httpGet2 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp2 = client.execute(httpGet2);
- Assert.assertEquals("http statusCode", 200, httpResp2.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp2.getCode());
}
@@ -721,7 +692,7 @@ public class HttpClientFactoryTest {
//perform test request
final HttpUriRequest httpGet2 = new HttpGet(mockServerUrl.url().toString());
final CloseableHttpResponse httpResp2 = client.execute(httpGet2);
- Assert.assertEquals("http statusCode", 200, httpResp2.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 200, httpResp2.getCode());
}