summaryrefslogtreecommitdiffstats
path: root/aai-resources
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-10-19 11:54:55 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-10-19 11:54:55 +0200
commitbe4c967659e73814dc14d9c144b8ad4156af4aca (patch)
treed07134dbd0c024d72595c7cfb17b5079449b160e /aai-resources
parent53208e359d28bebe8dc5116d295b19dba7010d68 (diff)
Upgrade spring-boot to 2.4
- update spring-boot to latest available 2.4.X release - Content-Type's on GET requests now result in 415 (instead of being ignored) which necessitates changes to the ConfigurationTest Issue-ID: AAI-3667 Change-Id: If6cbce8185b443a79b5e3b32fa3ffede5cabee60 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-resources')
-rw-r--r--aai-resources/pom.xml13
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java5
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java1
-rw-r--r--aai-resources/src/main/resources/application.properties4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java63
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java2
-rw-r--r--aai-resources/src/test/resources/application-test.properties4
8 files changed, 48 insertions, 46 deletions
diff --git a/aai-resources/pom.xml b/aai-resources/pom.xml
index 51c7e55..4336d67 100644
--- a/aai-resources/pom.xml
+++ b/aai-resources/pom.xml
@@ -32,10 +32,6 @@
</parent>
<properties>
<java.version>1.8</java.version>
- <spring.boot.version>2.3.12.RELEASE</spring.boot.version>
- <spring.version>5.2.15.RELEASE</spring.version>
- <spring.jms.version>${spring.version}</spring.jms.version>
- <spring.test.version>${spring.version}</spring.test.version>
<start-class>org.onap.aai.ResourcesApp</start-class>
<!-- Default docker registry that maven fabric plugin will try to pull from -->
@@ -85,13 +81,18 @@
<schema.ingest.file>${project.basedir}/src/main/resources/application.properties</schema.ingest.file>
<!-- End of Default ONAP Schema Properties -->
+ <spring.boot.version>2.4.13</spring.boot.version>
+ <spring.version>5.3.13</spring.version>
+ <javax.servlet.version>4.0.1</javax.servlet.version>
+ <spring.jms.version>${spring.version}</spring.jms.version>
+ <spring.test.version>${spring.version}</spring.test.version>
<keycloak.version>11.0.2</keycloak.version>
<micrometer-spring-legacy.version>1.3.19</micrometer-spring-legacy.version>
<micrometer-core.version>1.6.6</micrometer-core.version>
<micrometer-registry-prometheus.version>1.6.6</micrometer-registry-prometheus.version>
<micrometer-jersey2>1.6.6</micrometer-jersey2>
<testcontainers.version>1.6.1</testcontainers.version>
- <mockito.core.version>2.4.0</mockito.core.version>
+ <mockito.core.version>3.4.0</mockito.core.version>
<!-- Setting some default value to not complain by editor but it will be overridden by gmaven plugin -->
<!-- Integration tests will be skipped by default. Could be enabled here or by -DskipITs=false-->
@@ -379,7 +380,7 @@
</dependency>
<dependency>
<groupId>io.swagger</groupId>
- <artifactId>swagger-jersey-jaxrs</artifactId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java
index 61ada79..1d20744 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java
@@ -33,6 +33,7 @@ import javax.ws.rs.core.MediaType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.interceptors.AAIContainerFilter;
import org.onap.aai.logging.ErrorLogHelper;
+import org.springframework.http.HttpStatus;
@Priority(AAIResponseFilterPriority.INVALID_RESPONSE_STATUS)
public class InvalidResponseStatus extends AAIContainerFilter implements ContainerResponseFilter {
@@ -41,9 +42,9 @@ public class InvalidResponseStatus extends AAIContainerFilter implements Contain
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
throws IOException {
- if (responseContext.getStatus() == 405) {
+ if (responseContext.getStatus() == HttpStatus.METHOD_NOT_ALLOWED.value()) {
- responseContext.setStatus(400);
+ responseContext.setStatus(HttpStatus.BAD_REQUEST.value());
AAIException e = new AAIException("AAI_3012");
ArrayList<String> templateVars = new ArrayList<>();
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
index 14c1f01..2d0dcdc 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
@@ -91,7 +91,7 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
requestContext.getHeaders().putSingle(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
}
- if (WILDCARD.equals(acceptType) || StringUtils.isEmpty(acceptType) || acceptType.contains(TEXT_PLAIN)) {
+ if (WILDCARD.equals(acceptType) || acceptType.isEmpty() || !StringUtils.hasLength(acceptType) || acceptType.contains(TEXT_PLAIN)) {
UriInfo uriInfo = requestContext.getUriInfo();
if (uriInfo != null) {
MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
index 5208726..c685071 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
@@ -21,7 +21,6 @@
package org.onap.aai.rest;
import io.micrometer.core.annotation.Timed;
-import io.swagger.jaxrs.PATCH;
import java.io.UnsupportedEncodingException;
import java.net.URI;
diff --git a/aai-resources/src/main/resources/application.properties b/aai-resources/src/main/resources/application.properties
index 3905dd8..66a8e53 100644
--- a/aai-resources/src/main/resources/application.properties
+++ b/aai-resources/src/main/resources/application.properties
@@ -20,9 +20,9 @@ spring.jersey.application-path=${schema.uri.base.path}
spring.profiles.active=production,one-way-ssl,dmaap
#The max number of active threads in this pool
-jetty.threadPool.maxThreads=200
+server.jetty.threads.max=200
#The minimum number of threads always kept alive
-jetty.threadPool.minThreads=8
+server.jetty.threads.min=8
#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
server.tomcat.max-idle-time=60000
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
index 357ea41..8cc28fc 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
@@ -27,7 +27,6 @@ import com.jayway.jsonpath.JsonPath;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
-import java.util.Base64;
import java.util.Collections;
import java.util.UUID;
@@ -72,28 +71,29 @@ public class ConfigurationTest extends AbstractSpringRestTest {
@Value("${local.management.port}")
private int mgtPort;
- private HttpEntity<String> httpEntity;
+ private HttpEntity<String> httpEntityGet;
private HttpEntity<String> httpEntityPut;
private HttpEntity<String> httpEntityPatch;
private String baseUrl;
private String actuatorurl;
- private HttpHeaders headers;
+ private HttpHeaders headersGet;
+ private HttpHeaders headersPutPatch;
@Before
public void setup() throws UnsupportedEncodingException {
- headers = new HttpHeaders();
+ headersGet = new HttpHeaders();
+ headersGet.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headersGet.add("Real-Time", "true");
+ headersGet.add("X-FromAppId", "JUNIT");
+ headersGet.add("X-TransactionId", "JUNIT");
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- headers.setContentType(MediaType.APPLICATION_JSON);
- headers.add("Real-Time", "true");
- headers.add("X-FromAppId", "JUNIT");
- headers.add("X-TransactionId", "JUNIT");
+ headersGet.setBasicAuth("AAI","AAI");
- String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
- headers.add("Authorization", "Basic " + authorization);
-
- httpEntity = new HttpEntity<String>(headers);
+ headersPutPatch = new HttpHeaders();
+ headersPutPatch.putAll(headersGet);
+ headersPutPatch.setContentType(MediaType.APPLICATION_JSON);
+ httpEntityGet = new HttpEntity<String>(headersGet);
baseUrl = "http://localhost:" + randomPort;
actuatorurl = "http://localhost:" + mgtPort;
}
@@ -105,7 +105,7 @@ public class ConfigurationTest extends AbstractSpringRestTest {
ResponseEntity<String> responseEntity = null;
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntityGet, String.class);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
// String putBody = " configuration-id, configuration-type configuration-sub-type";
@@ -113,31 +113,31 @@ public class ConfigurationTest extends AbstractSpringRestTest {
+ "\"configuration-sub-type\": \"subtype1\", " + "\"operational-status\": \"example1\", "
+ "\"orchestration-status\": \"example1\", " + "\"configuration-selflink\": \"example1\", "
+ "\"model-customization-id\": \"example1\" " + "}";
- httpEntityPut = new HttpEntity<String>(putBody, headers);
+ httpEntityPut = new HttpEntity<String>(putBody, headersPutPatch);
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntityPut, String.class);
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
String vertexId = responseEntity.getHeaders().getFirst("vertex-id");
responseEntity = restTemplate.exchange(baseUrl + "/aai/v12/resources/id/" + vertexId, HttpMethod.GET,
- httpEntity, String.class);
+ httpEntityGet, String.class);
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntityGet, String.class);
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
String patchBody = "{" + "\"configuration-id\": \"" + cid + "\"," + "\"configuration-type\": \"type2\","
+ "\"configuration-sub-type\": \"subtype2\", " + "\"operational-status\": \"example1\", "
+ "\"orchestration-status\": \"example1\", " + "\"configuration-selflink\": \"example1\", "
+ "\"model-customization-id\": \"example1\" " + "}";
- headers.put("Content-Type", Arrays.asList("application/merge-patch+json"));
- headers.add("X-HTTP-Method-Override", "PATCH");
+ headersPutPatch.put("Content-Type", Arrays.asList("application/merge-patch+json"));
+ headersPutPatch.add("X-HTTP-Method-Override", "PATCH");
- httpEntityPatch = new HttpEntity<String>(patchBody, headers);
+ httpEntityPatch = new HttpEntity<String>(patchBody, headersPutPatch);
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.POST, httpEntityPatch, String.class);
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntityGet, String.class);
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
String body = responseEntity.getBody().toString();
@@ -148,11 +148,11 @@ public class ConfigurationTest extends AbstractSpringRestTest {
patchBody = "{" + "\"configuration-id\": \"" + cid + "\"," + "\"configuration-type\": \"type3\","
+ "\"configuration-sub-type\": \"subtype3\" " + "}";
- httpEntityPatch = new HttpEntity<String>(patchBody, headers);
+ httpEntityPatch = new HttpEntity<String>(patchBody, headersPutPatch);
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PATCH, httpEntityPatch, String.class);
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
- responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntityGet, String.class);
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
body = responseEntity.getBody().toString();
@@ -163,15 +163,16 @@ public class ConfigurationTest extends AbstractSpringRestTest {
}
@Test
- public void TestManagementEndpointConfiguration() {
+ public void testManagementEndpointConfiguration() {
ResponseEntity<String> responseEntity = null;
String responseBody = null;
// set Accept as text/plain in order to get access of endpoint "/actuator/prometheus"
- headers.set("Accept", "text/plain");
- httpEntity = new HttpEntity<String>(headers);
+ headersGet.set("Accept", "text/plain");
+ headersGet.setAccept(Arrays.asList(MediaType.TEXT_PLAIN));
+ httpEntityGet = new HttpEntity<String>(headersGet);
responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntity, String.class);
+ restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntityGet, String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("group_id"));
@@ -179,16 +180,16 @@ public class ConfigurationTest extends AbstractSpringRestTest {
// Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint "/actuator/info" and
// "/actuator/health"
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- httpEntity = new HttpEntity<String>(headers);
+ headersGet.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ httpEntityGet = new HttpEntity<String>(headersGet);
responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/info", HttpMethod.GET, httpEntity, String.class);
+ restTemplate.exchange(actuatorurl + "/actuator/info", HttpMethod.GET, httpEntityGet, String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("aai-resources"));
responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/health", HttpMethod.GET, httpEntity, String.class);
+ restTemplate.exchange(actuatorurl + "/actuator/health", HttpMethod.GET, httpEntityGet, String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("UP"));
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
index a804ee5..27f702f 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
@@ -65,7 +65,7 @@ public class ExceptionHandlerTest extends AAISetup {
@Before
public void setup() {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
MultivaluedHashMap<String, String> headersMultiMap = new MultivaluedHashMap<>();
diff --git a/aai-resources/src/test/resources/application-test.properties b/aai-resources/src/test/resources/application-test.properties
index 4c2b8d0..21e4ca7 100644
--- a/aai-resources/src/test/resources/application-test.properties
+++ b/aai-resources/src/test/resources/application-test.properties
@@ -20,9 +20,9 @@ spring.autoconfigure.exclude=\
spring.profiles.active=production
#The max number of active threads in this pool
-server.tomcat.max-threads=200
+server.tomcat.threads.max=200
#The minimum number of threads always kept alive
-server.tomcat.min-Spare-Threads=25
+server.tomcat.threads.min-spare=25
#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
server.tomcat.max-idle-time=60000