summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryProdHostTest.java14
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java3
2 files changed, 12 insertions, 5 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 85fa6129..73a14c45 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
@@ -6,15 +6,18 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
+import java.security.Security;
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.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -46,9 +49,11 @@ public class HttpClientFactoryProdHostTest {
*/
@BeforeClass
public static void classInitializer() {
- final Logger logger = (Logger) LoggerFactory.getLogger("org.bouncycastle.jsse");
- logger.setLevel(Level.TRACE);
-
+ final Logger logger = (Logger) LoggerFactory.getLogger("org.bouncycastle.jsse");
+ // do not set log-level to trace, because otherwise you get a NullPointerException from BCJSSE Provider
+ logger.setLevel(Level.INFO);
+
+ Security.removeProvider(BouncyCastleJsseProvider.PROVIDER_NAME);
System.setProperty("org.bouncycastle.jsse.client.acceptRenegotiation", "true");
}
@@ -69,7 +74,8 @@ public class HttpClientFactoryProdHostTest {
CertificateEncodingException {
System.setProperty("javax.net.debug", "ssl:handshake");
- final HttpClientConfiguration clientConfig = new HttpClientConfiguration("jUnit-client");
+ final HttpClientConfiguration clientConfig = new HttpClientConfiguration(
+ "jUnit-client-" + RandomStringUtils.randomAlphabetic(5));
clientConfig.setAuthMode("ssl");
clientConfig.buildKeyStoreConfig("hsmfacade", null, null, "authhandler");
clientConfig.setSslKeyAlias("authhandler-mis");
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 c71d8352..62de99c0 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
@@ -34,6 +34,7 @@ import org.junit.runner.RunWith;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.annotation.DirtiesContext.MethodMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -60,7 +61,7 @@ import okhttp3.tls.HeldCertificate;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/spring/test_eaaf_pvp_not_lazy.beans.xml")
-@DirtiesContext
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class HttpClientFactoryTest {
@Autowired private EaafKeyStoreFactory keyStoreFactory;