aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/test
diff options
context:
space:
mode:
authorSreeja Gattagouni <SG00744975@techmahindra.com>2024-06-10 13:14:36 +0530
committerSANKET KS <sx00562924@techmahindra.com>2024-07-08 06:04:42 +0000
commit989d7f3d6ae740e30480bfc7d49acfbaf014d393 (patch)
tree0604e03d4e6910f39d66f7240eb6b448e4d05b4c /common/src/test
parent7100db88beb76d9f23accaad9d0ccd91f7633304 (diff)
Upgrade SO to Java_17
-Removal of aff and logging-filter-base dependencies. -CI build java17 branch-jdk17 version:https://gerrit.onap.org/r/c/ci-management/+/138252 Issue-ID: SO-4125 Change-ID: I58f07f888a814b999f92f8d89909b0666d0b9699 Signed-off-by: Sreeja Gattagouni <SG00744975@techmahindra.com>
Diffstat (limited to 'common/src/test')
-rw-r--r--common/src/test/java/org/onap/so/client/HttpClientTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/RestClientTest.java14
-rw-r--r--common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java4
-rw-r--r--common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java10
-rw-r--r--common/src/test/java/org/onap/so/constants/DefaultsTest.java4
-rw-r--r--common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java16
-rw-r--r--common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java9
9 files changed, 37 insertions, 32 deletions
diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java
index 3966d183f7..d58289a857 100644
--- a/common/src/test/java/org/onap/so/client/HttpClientTest.java
+++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java
@@ -70,7 +70,6 @@ public class HttpClientTest {
URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post");
HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN);
- client.addAdditionalHeader("Accept", "application/json");
client.addAdditionalHeader("id", null);
client.post("{}");
@@ -89,7 +88,6 @@ public class HttpClientTest {
HttpClient client = httpClientFactory.newJsonClient(url, ONAPComponents.BPMN);
client.addBasicAuthHeader("", "12345");
- client.addAdditionalHeader("Accept", "application/json");
client.post("{}");
@@ -180,7 +178,6 @@ public class HttpClientTest {
URL url = new URL("http://localhost:" + wireMockRule.port() + "/services/sdnc/post");
HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN);
- client.addAdditionalHeader("Accept", "text/xml");
client.addAdditionalHeader("id", null);
client.post("{}");
@@ -199,7 +196,6 @@ public class HttpClientTest {
HttpClient client = httpClientFactory.newTextXmlClient(url, ONAPComponents.BPMN);
client.addBasicAuthHeader("", "12345");
- client.addAdditionalHeader("Accept", "text/xml");
client.post("{}");
diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java
index b5efa17216..1448efca3c 100644
--- a/common/src/test/java/org/onap/so/client/RestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/RestClientTest.java
@@ -35,13 +35,13 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.util.Optional;
import javax.net.ssl.SSLException;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.client.ResponseProcessingException;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriBuilderException;
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.ProcessingException;
+import jakarta.ws.rs.WebApplicationException;
+import jakarta.ws.rs.client.ResponseProcessingException;
+import jakarta.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.UriBuilderException;
import org.javatuples.Pair;
import org.junit.Rule;
import org.junit.Test;
diff --git a/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
index 964707ab8f..892e2b4a4d 100644
--- a/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
@@ -26,8 +26,8 @@ import static org.mockito.Mockito.when;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.apache.commons.codec.binary.Base64;
import org.javatuples.Pair;
import org.junit.Before;
diff --git a/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java b/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java
index 4f00b9db96..ded67ffb77 100644
--- a/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/dmaap/rest/DMaaPRestClientTest.java
@@ -24,8 +24,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.net.MalformedURLException;
import java.net.URL;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java
index f9547cb3db..46cd42ec54 100644
--- a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java
+++ b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java
@@ -36,8 +36,8 @@ import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import org.javatuples.Pair;
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java b/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java
index 4b054ff7d1..a2b5ede57a 100644
--- a/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java
+++ b/common/src/test/java/org/onap/so/configuration/rest/HttpComponentsClientConfigurationTest.java
@@ -21,8 +21,12 @@
package org.onap.so.configuration.rest;
import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import org.junit.Test;
+import org.mockito.Mock;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import javax.annotation.meta.When;
/**
* @author waqas.ikram@est.tech
@@ -31,10 +35,12 @@ public class HttpComponentsClientConfigurationTest {
@Test
public void test_httpComponentsClientHttpRequestFactory_HttpComponentsClientHttpRequestFactoryNotNull() {
- final HttpClientConnectionConfiguration clientConnectionConfiguration = new HttpClientConnectionConfiguration();
+ final HttpClientConnectionConfiguration clientConnectionConfiguration =
+ mock(HttpClientConnectionConfiguration.class);
final HttpComponentsClientConfiguration objUnderTest =
new HttpComponentsClientConfiguration(clientConnectionConfiguration);
-
+ when(clientConnectionConfiguration.getMaxConnections()).thenReturn(100);
+ when(clientConnectionConfiguration.getMaxConnectionsPerRoute()).thenReturn(20);
final HttpComponentsClientHttpRequestFactory factory = objUnderTest.httpComponentsClientHttpRequestFactory();
assertNotNull(factory);
assertNotNull(factory.getHttpClient());
diff --git a/common/src/test/java/org/onap/so/constants/DefaultsTest.java b/common/src/test/java/org/onap/so/constants/DefaultsTest.java
index 11ecc96c36..e4cc96d1ef 100644
--- a/common/src/test/java/org/onap/so/constants/DefaultsTest.java
+++ b/common/src/test/java/org/onap/so/constants/DefaultsTest.java
@@ -26,13 +26,13 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.onap.so.spring.SpringContextHelper;
import org.onap.so.test.categories.SpringAware;
-import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
+import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
+@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigDataApplicationContextInitializer.class)
@ActiveProfiles("test")
@Category(SpringAware.class)
public class DefaultsTest {
diff --git a/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java b/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java
index 72bacdf2db..d620241395 100644
--- a/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java
+++ b/common/src/test/java/org/onap/so/rest/service/HttpRestServiceProviderImplTest.java
@@ -35,11 +35,9 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.rest.exceptions.InvalidRestRequestException;
import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
import org.onap.so.rest.exceptions.RestProcessingException;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@@ -59,6 +57,9 @@ public class HttpRestServiceProviderImplTest {
@Mock
private ResponseEntity<String> mockEntity;
+ @Mock
+ private HttpStatusCodeException httpStatusCodeException;
+
@Test
public void test_get_returnOptionalPresentIfResponseIsOKAndHasBody() {
@@ -124,10 +125,12 @@ public class HttpRestServiceProviderImplTest {
@Test(expected = RestProcessingException.class)
public void test_get_ThrowsInvalidRestRequestExceptionifHttpClientErrorExceptionOccured() {
+
final HttpRestServiceProvider objUnderTest = new HttpRestServiceProviderImpl(mockRestTemplate);
+ HttpClientErrorException httpClientErrorException = new HttpClientErrorException(HttpStatus.CONFLICT);
when(mockRestTemplate.exchange(eq(DUMMY_URL), eq(HttpMethod.GET), any(HttpEntity.class), eq(String.class)))
- .thenThrow(HttpClientErrorException.class);
+ .thenThrow(httpClientErrorException);
objUnderTest.get(DUMMY_URL, String.class);
}
@@ -249,8 +252,9 @@ public class HttpRestServiceProviderImplTest {
public void test_post_ThrowsInvalidRestRequestExceptionifHttpClientErrorExceptionOccured() {
final HttpRestServiceProvider objUnderTest = new HttpRestServiceProviderImpl(mockRestTemplate);
+ HttpClientErrorException httpClientErrorException = new HttpClientErrorException(HttpStatus.CONFLICT);
when(mockRestTemplate.exchange(eq(DUMMY_URL), eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class)))
- .thenThrow(HttpClientErrorException.class);
+ .thenThrow(httpClientErrorException);
objUnderTest.post(BODY, DUMMY_URL, String.class);
}
diff --git a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
index d1d3f2a5f0..82b2a2a5b6 100644
--- a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
+++ b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java
@@ -26,9 +26,8 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.core.Response;
import org.junit.AfterClass;
import org.junit.Test;
@@ -44,7 +43,7 @@ public class RuntimeExceptionMapperTest {
Response r = mapper.toResponse(new RuntimeException("This is the run time exception message"));
- assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
assertThat(r.getEntity(), instanceOf(ExceptionResponse.class));
assertThat(((ExceptionResponse) r.getEntity()).getMessage(), equalTo("Unexpected Internal Exception"));
@@ -57,7 +56,7 @@ public class RuntimeExceptionMapperTest {
Response r = mapper.toResponse(new NotFoundException("not found"));
- assertEquals(Status.NOT_FOUND.getStatusCode(), r.getStatus());
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), r.getStatus());
assertThat(r.getEntity(), is(nullValue()));
}