From 987b9f7a030a2389216c998225abb2602ef2dba3 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 31 Jan 2023 10:39:50 +0000 Subject: 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: Iec5ba1283acd506c9f3c7fe7b5d7858db6abbaa7 Signed-off-by: liamfallon --- integrity-monitor/pom.xml | 10 ++++++++-- .../test/java/org/onap/policy/common/im/AllSeemsWellTest.java | 5 +++-- .../java/org/onap/policy/common/im/IntegrityMonitorTest.java | 5 +++-- .../org/onap/policy/common/im/IntegrityMonitorTestBase.java | 7 ++++--- 4 files changed, 18 insertions(+), 9 deletions(-) (limited to 'integrity-monitor') diff --git a/integrity-monitor/pom.xml b/integrity-monitor/pom.xml index 8050b426..72762ef5 100644 --- a/integrity-monitor/pom.xml +++ b/integrity-monitor/pom.xml @@ -3,6 +3,7 @@ ONAP Policy Engine - Common Modules ================================================================================ Copyright (C) 2017-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. @@ -37,8 +38,13 @@ - org.powermock - powermock-api-mockito2 + org.mockito + mockito-core + test + + + org.springframework + spring-test test diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java index a46be4f0..b5c15904 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modificaitons 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. @@ -33,9 +34,9 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.test.util.ReflectionTestUtils; public class AllSeemsWellTest extends IntegrityMonitorTestBase { private static final String ALL_SEEMS_WELL_MSG = "'AllSeemsWellTest - ALLSEEMSWELL'"; @@ -93,7 +94,7 @@ public class AllSeemsWellTest extends IntegrityMonitorTestBase { } }; - Whitebox.setInternalState(IntegrityMonitor.class, IM_INSTANCE_FIELD, im); + ReflectionTestUtils.setField(IntegrityMonitor.class, IM_INSTANCE_FIELD, im); } @After diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java index 0def27e0..451a384c 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modificaitons 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,9 +41,9 @@ import org.junit.Test; import org.onap.policy.common.im.jpa.ForwardProgressEntity; import org.onap.policy.common.im.jpa.ResourceRegistrationEntity; import org.onap.policy.common.im.jpa.StateManagementEntity; -import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.test.util.ReflectionTestUtils; /* * All JUnits are designed to run in the local development environment @@ -906,7 +907,7 @@ public class IntegrityMonitorTest extends IntegrityMonitorTestBase { } }; - Whitebox.setInternalState(IntegrityMonitor.class, IM_INSTANCE_FIELD, im); + ReflectionTestUtils.setField(IntegrityMonitor.class, IM_INSTANCE_FIELD, im); // wait for the monitor thread to start waitCycles(1); diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java index c034482f..ffa45a25 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java @@ -3,6 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Modificaitons 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. @@ -35,9 +36,9 @@ import org.onap.policy.common.utils.jpa.EntityTransCloser; import org.onap.policy.common.utils.test.log.logback.ExtractAppender; import org.onap.policy.common.utils.time.CurrentTime; import org.onap.policy.common.utils.time.TestTime; -import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.test.util.ReflectionTestUtils; /** * All JUnits are designed to run in the local development environment where they have write @@ -153,7 +154,7 @@ public class IntegrityMonitorTestBase { IntegrityMonitor.setUnitTesting(true); testTime = new TestTime(); - Whitebox.setInternalState(MonitorTime.class, TIME_INSTANCE_FIELD, testTime); + ReflectionTestUtils.setField(MonitorTime.class, TIME_INSTANCE_FIELD, testTime); properties = new Properties(); properties.put(IntegrityMonitorProperties.DB_DRIVER, DB_DRIVER); @@ -187,7 +188,7 @@ public class IntegrityMonitorTestBase { systemProps.put(JMX_PORT_PROP, savedJmxPort); } - Whitebox.setInternalState(MonitorTime.class, TIME_INSTANCE_FIELD, savedTime); + ReflectionTestUtils.setField(MonitorTime.class, TIME_INSTANCE_FIELD, savedTime); IntegrityMonitor.setUnitTesting(false); -- cgit 1.2.3-korg