diff options
author | liamfallon <liam.fallon@est.tech> | 2023-01-31 10:43:09 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2023-01-31 12:48:56 +0000 |
commit | 1e82ff4b693e2920dfde67cdfc30bf0648f1b097 (patch) | |
tree | f185097810ad6d45f24e26c201e7e3b5b4ed5bd4 | |
parent | f1aed94b6821c9a5246023490e6a6d772ba09452 (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>
9 files changed, 33 insertions, 20 deletions
diff --git a/applications/common/pom.xml b/applications/common/pom.xml index d7e2b603..ce960811 100644 --- a/applications/common/pom.xml +++ b/applications/common/pom.xml @@ -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> diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtilsTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtilsTest.java index e684cde4..ef74beae 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtilsTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtilsTest.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. @@ -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); diff --git a/applications/match/pom.xml b/applications/match/pom.xml index 2f671000..8bc317e4 100644 --- a/applications/match/pom.xml +++ b/applications/match/pom.xml @@ -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> diff --git a/applications/naming/pom.xml b/applications/naming/pom.xml index a33e15bd..50d2ee3c 100644 --- a/applications/naming/pom.xml +++ b/applications/naming/pom.xml @@ -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> diff --git a/applications/optimization/pom.xml b/applications/optimization/pom.xml index 417e59e0..eac07910 100644 --- a/applications/optimization/pom.xml +++ b/applications/optimization/pom.xml @@ -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> diff --git a/main/pom.xml b/main/pom.xml index b251fee2..af1c8c5c 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -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. @@ -118,8 +119,13 @@ <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> 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()); |