aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2023-01-31 10:43:09 +0000
committerliamfallon <liam.fallon@est.tech>2023-01-31 12:48:56 +0000
commit1e82ff4b693e2920dfde67cdfc30bf0648f1b097 (patch)
treef185097810ad6d45f24e26c201e7e3b5b4ed5bd4 /main/src/test/java/org
parentf1aed94b6821c9a5246023490e6a6d772ba09452 (diff)
Upgrade and clean up dependencies
- Upgrade Hibernate - Upgrade Mockito - Upgrade Mockserver - Remove Powermock (no longer supported) and replace with spring-test ReflectionTestUtils - Upgrade Spring Framework - Add spring-security to allow authentication on unit tests using MockMVC Minor clean-up - Replace deprecated authorization configuraiton on spring boot applications with SecurityFilterChain bean - Change @LocalPort include on tests to use test include rather than runtime include - Remove unused imports - Remove unused constants and variables - Add deprecation annotations where required Issue-ID: POLICY-4482 Change-Id: Ia61e137f7f7b7807f376d894be05d1c357a86bdd Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main/src/test/java/org')
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java8
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java5
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java8
3 files changed, 11 insertions, 10 deletions
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java b/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
index 422d4336..7bdd4c47 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,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.
@@ -47,7 +47,7 @@ import org.onap.policy.common.utils.security.SelfSignedKeyStore;
import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager;
import org.onap.policy.pdpx.main.startstop.Main;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
-import org.powermock.reflect.Whitebox;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* Common base class for REST service tests.
@@ -215,8 +215,8 @@ public class CommonRest {
* @param newAlive the new "alive" status
*/
private void markActivator(boolean newAlive) {
- Object manager = Whitebox.getInternalState(XacmlPdpActivator.getCurrent(), "serviceManager");
- AtomicBoolean running = Whitebox.getInternalState(manager, "running");
+ Object manager = ReflectionTestUtils.getField(XacmlPdpActivator.getCurrent(), "serviceManager");
+ AtomicBoolean running = (AtomicBoolean) ReflectionTestUtils.getField(manager, "running");
running.set(newAlive);
}
}
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
index 17f71ddd..7a9dc4d7 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -40,7 +41,7 @@ import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.comm.XacmlPdpHearbeatPublisher;
import org.onap.policy.pdpx.main.comm.XacmlPdpUpdatePublisher;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
-import org.powermock.reflect.Whitebox;
+import org.springframework.test.util.ReflectionTestUtils;
@RunWith(MockitoJUnitRunner.class)
public class XacmlPdpUpdateListenerTest {
@@ -111,7 +112,7 @@ public class XacmlPdpUpdateListenerTest {
public void testMakePublisher() {
// create a plain listener to test the "real" makePublisher() method
listener = new XacmlPdpUpdateListener(client, state, heartbeat, appmgr);
- assertNotNull(Whitebox.getInternalState(listener, "publisher"));
+ assertNotNull(ReflectionTestUtils.getField(listener, "publisher"));
}
private class MyListener extends XacmlPdpUpdateListener {
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java b/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java
index ff084047..61ba8b85 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,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.
@@ -35,7 +35,7 @@ import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
import org.onap.policy.pdpx.main.parameters.CommonTestData;
import org.onap.policy.pdpx.main.parameters.XacmlPdpParameterGroup;
import org.onap.policy.pdpx.main.parameters.XacmlPdpParameterHandler;
-import org.powermock.reflect.Whitebox;
+import org.springframework.test.util.ReflectionTestUtils;
/**
@@ -70,7 +70,7 @@ public class TestXacmlPdpActivator extends CommonRest {
@Override
@Before
public void setUp() {
- Whitebox.setInternalState(parGroup, PROBE_FIELD_NAME, 4);
+ ReflectionTestUtils.setField(parGroup, PROBE_FIELD_NAME, 4);
activator = new XacmlPdpActivator(parGroup);
}
@@ -96,7 +96,7 @@ public class TestXacmlPdpActivator extends CommonRest {
@Test
public void testXacmlPdpActivator_NoProbe() throws Exception {
- Whitebox.setInternalState(parGroup, PROBE_FIELD_NAME, 0);
+ ReflectionTestUtils.setField(parGroup, PROBE_FIELD_NAME, 0);
activator = new XacmlPdpActivator(parGroup);
activator.start();
assertTrue(activator.isAlive());