diff options
author | 2023-08-21 14:35:56 +0100 | |
---|---|---|
committer | 2023-08-22 09:05:59 +0000 | |
commit | 182c1dbd18c9bb3c4696e8e74fb0ff8cd7a581e6 (patch) | |
tree | b0621323bc8e8823f204607f4bde819e0d9373bc /main/src/test/java/org | |
parent | 7808675f394deacc75e89866159b24ae35f63919 (diff) |
Upgrade Java 17
Issue-ID: POLICY-4803
Change-Id: Ic7852fffa2f5a2f407900e7caae9e70bd50b267f
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'main/src/test/java/org')
3 files changed, 27 insertions, 13 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java index 9f6fab5a..57fa97d1 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java +++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java @@ -133,6 +133,22 @@ public class CommonTestData { /** * Returns an instance of ReceptionHandlerParameters for test cases. * + * @param port the port + * @return the restServerParameters object + */ + public RestServerParameters getRestServerParameters(final int port) { + final var fileName = "src/test/resources/parameters/RestServerParameters.json"; + try { + var json = Files.readString(new File(fileName).toPath()); + return coder.decode(json.replace("6969", String.valueOf(port)), RestServerParameters.class); + } catch (final Exception exp) { + throw new RuntimeException("cannot read/decode " + fileName, exp); + } + } + + /** + * Returns an instance of ReceptionHandlerParameters for test cases. + * * @param isEmpty boolean value to represent that object created should be empty or not * @return the receptionHandlerParameters object */ diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java index ce4cda24..ec4b001d 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java @@ -28,17 +28,16 @@ import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.MediaType; import java.io.IOException; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.Before; import org.junit.Test; -import org.mockito.internal.util.reflection.Whitebox; import org.onap.policy.common.endpoints.http.server.RestServer; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.report.HealthCheckReport; @@ -82,8 +81,7 @@ public class TestDistributionRestServer { port = NetworkUtil.allocPort(); final String reportString = "HealthCheckReport(name=Policy SSD, url=" + SELF + ", healthy=false, code=500, message=not alive)"; - final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false); - Whitebox.setInternalState(restServerParams, "port", port); + final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(port); restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME); final RestServer restServer = new RestServer(restServerParams, null, DistributionRestController.class); restServer.start(); diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java index 82e40ccd..ecb49ce6 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java @@ -25,16 +25,16 @@ package org.onap.policy.distribution.main.rest; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertEquals; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.MediaType; import java.io.IOException; import java.security.SecureRandom; import java.util.Properties; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.Before; import org.junit.Test; |