aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java')
-rw-r--r--sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java b/sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java
index 4594fb9..347b7f5 100644
--- a/sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java
+++ b/sdc-distribution-client/src/test/java/org/onap/sdc/http/HttpClientFactoryTest.java
@@ -19,68 +19,68 @@
*/
package org.onap.sdc.http;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.utils.Pair;
import org.onap.sdc.utils.TestConfiguration;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-
-public class HttpClientFactoryTest {
+class HttpClientFactoryTest {
@Test
- public void shouldReturnSSLConnection(){
+ void shouldReturnSSLConnection() {
TestConfiguration config = spy(new TestConfiguration());
HttpClientFactory httpClientFactory = new HttpClientFactory(config);
when(config.activateServerTLSAuth()).thenReturn(true);
when(config.getKeyStorePath()).thenReturn("src/test/resources/asdc-client.jks");
when(config.getKeyStorePassword()).thenReturn("Aa123456");
- Pair<String, CloseableHttpClient> client = httpClientFactory.createInstance();
+ Pair<String, CloseableHttpClient> client = httpClientFactory.createInstance();
SSLConnectionSocketFactory sslsf = spy(SSLConnectionSocketFactory.getSocketFactory());
CredentialsProvider credsProvider = new BasicCredentialsProvider();
CloseableHttpClient expectedHttpClient = HttpClientBuilder.create().
- setDefaultCredentialsProvider(credsProvider).
- setSSLSocketFactory(sslsf).
- build();
+ setDefaultCredentialsProvider(credsProvider).
+ setSSLSocketFactory(sslsf).
+ build();
Pair<String, CloseableHttpClient> expectedClient = new Pair<>("https://", expectedHttpClient);
assertNotNull(client);
assertEquals(expectedClient.getFirst(), client.getFirst());
}
@Test
- public void shouldReturnSSLConnectionWithHttp(){
+ void shouldReturnSSLConnectionWithHttp() {
TestConfiguration config = spy(new TestConfiguration());
HttpClientFactory httpClientFactory = new HttpClientFactory(config);
when(config.activateServerTLSAuth()).thenReturn(false);
when(config.isUseHttpsWithSDC()).thenReturn(false);
- Pair<String, CloseableHttpClient> client = httpClientFactory.createInstance();
+ Pair<String, CloseableHttpClient> client = httpClientFactory.createInstance();
SSLConnectionSocketFactory sslsf = spy(SSLConnectionSocketFactory.getSocketFactory());
CredentialsProvider credsProvider = new BasicCredentialsProvider();
CloseableHttpClient expectedHttpClient = HttpClientBuilder.create().
- setDefaultCredentialsProvider(credsProvider).
- setSSLSocketFactory(sslsf).
- build();
+ setDefaultCredentialsProvider(credsProvider).
+ setSSLSocketFactory(sslsf).
+ build();
Pair<String, CloseableHttpClient> expectedClient = new Pair<>("http://", expectedHttpClient);
assertNotNull(client);
assertEquals(expectedClient.getFirst(), client.getFirst());
}
- @Test (expected = HttpAsdcClientException.class)
- public void shouldReturnSSLConnectionError() throws HttpAsdcClientException{
+ @Test
+ void shouldReturnSSLConnectionError() throws HttpAsdcClientException {
TestConfiguration config = spy(new TestConfiguration());
HttpClientFactory httpClientFactory = new HttpClientFactory(config);
when(config.activateServerTLSAuth()).thenReturn(true);
when(config.getKeyStorePath()).thenReturn("src/test/resources/dummy.jks");
when(config.getKeyStorePassword()).thenReturn("Aa123456");
- httpClientFactory.createInstance();
+ assertThrows(HttpAsdcClientException.class, () -> httpClientFactory.createInstance());
}
-} \ No newline at end of file
+}