Upgrade and clean up dependencies 85/133085/1
authorliamfallon <liam.fallon@est.tech>
Tue, 31 Jan 2023 10:43:09 +0000 (10:43 +0000)
committerliamfallon <liam.fallon@est.tech>
Tue, 31 Jan 2023 12:48:56 +0000 (12:48 +0000)
- 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>
applications/common/pom.xml
applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtilsTest.java
applications/match/pom.xml
applications/naming/pom.xml
applications/optimization/pom.xml
main/pom.xml
main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java

index d7e2b60..ce96081 100644 (file)
@@ -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.
@@ -38,8 +39,8 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-api-mockito2</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
index e684cde..ef74bea 100644 (file)
@@ -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.
@@ -116,6 +117,7 @@ public class ToscaPolicyTranslatorUtilsTest {
         assertThat(((ApplyType) obj).getExpression()).hasSize(2);
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testDecodeProperties() throws ToscaPolicyConversionException {
         Data data = ToscaPolicyTranslatorUtils.decodeProperties(Map.of("value", 20), Data.class);
index 2f67100..8bc317e 100644 (file)
@@ -3,6 +3,7 @@
   ONAP Policy Engine - XACML PDP
   ================================================================================
   Copyright (C) 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.
@@ -34,8 +35,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-api-mockito2</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
index a33e15b..50d2ee3 100644 (file)
@@ -3,6 +3,7 @@
   ONAP Policy Engine - XACML PDP
   ================================================================================
   Copyright (C) 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.
@@ -34,8 +35,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-api-mockito2</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
index 417e59e..eac0791 100644 (file)
@@ -3,6 +3,7 @@
   ONAP Policy Engine - XACML PDP
   ================================================================================
   Copyright (C) 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.
@@ -34,8 +35,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-api-mockito2</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
index b251fee..af1c8c5 100644 (file)
@@ -4,6 +4,7 @@
   ================================================================================
   Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
   Modifications Copyright (C) 2020 Bell Canada.
+  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.
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-api-mockito2</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
index 422d433..7bdd4c4 100644 (file)
@@ -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);
     }
 }
index 17f71dd..7a9dc4d 100644 (file)
@@ -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 {
index ff08404..61ba8b8 100644 (file)
@@ -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());