From 349b4ae7179173f9261d9a432094cb55dc433820 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Fri, 21 Jul 2023 09:41:01 +0100 Subject: Java 17 Upgrade Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares --- .../endpoints/http/server/test/HttpClientTest.java | 16 ++++----- .../endpoints/http/server/test/HttpServerTest.java | 13 +++----- .../http/server/test/JsonExceptionMapperTest.java | 3 +- .../endpoints/http/server/test/MyGsonProvider.java | 5 +-- .../endpoints/http/server/test/MyYamlProvider.java | 5 +-- .../http/server/test/RestEchoService.java | 39 ++++++++++++---------- .../endpoints/http/server/test/RestEndpoints.java | 9 ++--- .../http/server/test/RestMockHealthCheck.java | 15 +++++---- .../endpoints/http/server/test/RestServerTest.java | 26 +++++++-------- .../http/server/test/TestAafAuthFilter.java | 3 +- .../server/test/TestAafGranularAuthFilter.java | 3 +- .../http/server/test/TestAuthorizationFilter.java | 3 +- .../endpoints/http/server/test/TestFilter.java | 11 +++--- .../http/server/test/YamlExceptionMapperTest.java | 3 +- .../http/server/test/YamlJacksonHandlerTest.java | 6 ++-- .../server/test/YamlMessageBodyHandlerTest.java | 3 +- .../common/endpoints/utils/PropertyUtilsTest.java | 12 ++++--- 17 files changed, 94 insertions(+), 81 deletions(-) (limited to 'policy-endpoints/src/test/java/org') diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java index da8ea7ae..27e7dc5f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java @@ -28,7 +28,11 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import io.prometheus.client.exporter.MetricsServlet; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.InvocationCallback; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -36,10 +40,6 @@ import java.util.Properties; import java.util.TreeMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.InvocationCallback; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import lombok.Getter; import org.junit.AfterClass; import org.junit.Before; @@ -490,7 +490,7 @@ public class HttpClientTest { response = clientPdp.get("metrics"); assertEquals(200, response.getStatus()); - response = clientPdp.get("swagger.json"); + response = clientPdp.get("openapi.json"); assertEquals(200, response.getStatus()); assertFalse(MyGsonProvider.hasWrittenSome()); @@ -534,7 +534,7 @@ public class HttpClientTest { } - class MyEntity { + static class MyEntity { private String myParameter; @@ -552,7 +552,7 @@ public class HttpClientTest { } - class MyCallback implements InvocationCallback { + static class MyCallback implements InvocationCallback { @Getter private Response response; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java index dcb3906d..48cacaf9 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java @@ -32,7 +32,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; -import io.prometheus.client.exporter.MetricsServlet; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; @@ -64,7 +64,7 @@ public class HttpServerTest { private static final String LOCALHOST = "localhost"; private static final String JSON_MEDIA = "application/json"; private static final String YAML_MEDIA = YamlMessageBodyHandler.APPLICATION_YAML; - private static final String SWAGGER_JSON = "/swagger.json"; + private static final String SWAGGER_JSON = "/openapi.json"; private static final String JUNIT_ECHO_HELLO = "/junit/echo/hello"; private static final String JUNIT_ECHO_FULL_REQUEST = "/junit/echo/full/request"; private static final String SOME_TEXT = "some text"; @@ -73,7 +73,7 @@ public class HttpServerTest { /** * Logger. */ - private static Logger logger = LoggerFactory.getLogger(HttpServerTest.class); + private static final Logger logger = LoggerFactory.getLogger(HttpServerTest.class); private static final String LOCALHOST_PREFIX = "http://localhost:"; @@ -286,7 +286,7 @@ public class HttpServerTest { assertEquals(reqText, response); response = http(portUrl + SWAGGER_JSON); - assertThat(response).contains("Swagger Server"); + assertThat(response).contains("openapi"); } @Test @@ -410,11 +410,6 @@ public class HttpServerTest { assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive()); assertEquals(1, HttpServletServerFactoryInstance.getServerFactory().inventory().size()); - System.setProperty("cadi_longitude", "0.0"); - System.setProperty("cadi_latitude", "0.0"); - server.setAafAuthentication("/*"); - assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf()); - HttpServletServerFactoryInstance.getServerFactory().destroy(port); assertEquals(0, HttpServletServerFactoryInstance.getServerFactory().inventory().size()); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java index 59ce0c1c..27e98670 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ package org.onap.policy.common.endpoints.http.server.test; import static org.junit.Assert.assertEquals; import com.google.gson.JsonSyntaxException; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.JsonExceptionMapper; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java index 8343d02d..78c41cc2 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +21,13 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import lombok.AccessLevel; import lombok.Setter; import org.onap.policy.common.gson.GsonMessageBodyHandler; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java index 098ecb44..624d7686 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +21,13 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import lombok.AccessLevel; import lombok.Setter; import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java index 373950b2..b4a652aa 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,29 +21,30 @@ package org.onap.policy.common.endpoints.http.server.test; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler; -@Api(value = "echo") @Path("/junit/echo") public class RestEchoService { @GET @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echo(@PathParam("word") String word) { return word; } @@ -50,7 +52,7 @@ public class RestEchoService { @PUT @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echoPut(@PathParam("word") String word, Object entity) { return "PUT:" + word + ":" + entity.toString(); } @@ -58,7 +60,8 @@ public class RestEchoService { @POST @Path("/full/request") @Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML}) - @ApiOperation(value = "echoes back the request structure", response = RestEchoReqResp.class) + @Operation(summary = "echoes back the request structure") + @ApiResponse(content = {@Content(schema = @Schema(implementation = RestEchoReqResp.class))}) public Response echoFullyPost(RestEchoReqResp reqResp) { return Response.status(Status.OK).entity(reqResp).build(); } @@ -66,7 +69,7 @@ public class RestEchoService { @POST @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echoPost(@PathParam("word") String word, Object entity) { return "POST:" + word + ":" + entity.toString(); } @@ -74,7 +77,7 @@ public class RestEchoService { @DELETE @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echoDelete(@PathParam("word") String word) { return "DELETE:" + word; } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java index cafab42f..cbcf4c9a 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java @@ -3,6 +3,7 @@ * policy-endpoints * ================================================================================ * Copyright (C) 2017, 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +21,11 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import java.util.List; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java index f0d68c0c..f476dbaf 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java @@ -3,6 +3,7 @@ * policy-endpoints * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; @Path("/") public class RestMockHealthCheck { @@ -40,7 +41,7 @@ public class RestMockHealthCheck { @GET @Path("pdp/test") @Produces(MediaType.APPLICATION_JSON) - public Response pdpHealthCheck() { + public Response pdpHealthCheck() { return Response.status(Status.INTERNAL_SERVER_ERROR).entity("At least some Dead").build(); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java index c025d425..216c4fd9 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java @@ -33,7 +33,18 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.prometheus.client.exporter.MetricsServlet; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import java.io.IOException; import java.io.PrintWriter; import java.net.HttpURLConnection; @@ -43,17 +54,6 @@ import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.Properties; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import lombok.Getter; import org.apache.commons.io.IOUtils; import org.junit.AfterClass; @@ -384,7 +384,7 @@ public class RestServerTest { } } - private static class Filter2 implements javax.servlet.Filter { + private static class Filter2 implements jakarta.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java index 27d45c8d..a9a19424 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter; public class TestAafAuthFilter extends AafAuthFilter { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java index 183e5ae7..bccff70f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter; import org.onap.policy.common.utils.network.NetworkUtil; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java index f3cd7424..59ec6f13 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.AuthorizationFilter; public class TestAuthorizationFilter extends AuthorizationFilter { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java index 44b37656..155e12bb 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; public class TestFilter implements Filter { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java index 96c23ed3..5317eadb 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.policy.common.endpoints.http.server.test; import static org.junit.Assert.assertEquals; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java index 8d65bbd6..b2b81c26 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,12 +26,13 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.gson.JsonObject; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; -import javax.ws.rs.core.MediaType; import lombok.ToString; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.YamlJacksonHandler; @@ -66,7 +68,7 @@ public class YamlJacksonHandlerTest { ByteArrayOutputStream outstr = new ByteArrayOutputStream(); hdlr.writeTo(data, Data.class, Data.class, null, null, null, outstr); - assertEquals("abc: def\nhello: world\nmyId: 100\nvalue: a value\n", outstr.toString("UTF-8")); + assertEquals("abc: def\nhello: world\nmyId: 100\nvalue: a value\n", outstr.toString(StandardCharsets.UTF_8)); /* * Ensure everything deserializes as expected. diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java index c0927aa9..962c09db 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -32,7 +34,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; -import javax.ws.rs.core.MediaType; import lombok.ToString; import org.junit.Before; import org.junit.Test; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java index 048a3902..f8665a90 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.policy.common.endpoints.utils; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -76,11 +78,11 @@ public class PropertyUtilsTest { @Test public void testGetBoolean() { - assertEquals(true, utils.getBoolean(".my-bool", false)); - assertEquals(false, utils.getBoolean(".my-bool2", true)); - assertEquals(true, utils.getBoolean(".empty-bool", true)); - assertEquals(false, utils.getBoolean(".invalid-bool", true)); - assertEquals(true, utils.getBoolean(".missing-bool", true)); + assertTrue(utils.getBoolean(".my-bool", false)); + assertFalse(utils.getBoolean(".my-bool2", true)); + assertTrue(utils.getBoolean(".empty-bool", true)); + assertFalse(utils.getBoolean(".invalid-bool", true)); + assertTrue(utils.getBoolean(".missing-bool", true)); assertNull(invalidName); assertNull(invalidValue); -- cgit 1.2.3-korg