aboutsummaryrefslogtreecommitdiffstats
path: root/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2023-01-31 10:39:50 +0000
committerliamfallon <liam.fallon@est.tech>2023-01-31 11:16:31 +0000
commit987b9f7a030a2389216c998225abb2602ef2dba3 (patch)
treec3973249317b67b1a258a765703730d8421a8a62 /common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
parent6c4fc8693221990eca8000d07c208749c635a769 (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: Iec5ba1283acd506c9f3c7fe7b5d7858db6abbaa7 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java')
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
index bbf77179..13f525c9 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2018-2020 Ericsson, AT&T. 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,28 +44,28 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.PropertyUtil.Listener;
-import org.powermock.reflect.Whitebox;
+import org.springframework.test.util.ReflectionTestUtils;
public class PropertyUtilTest {
private static final String TIMER_FIELD = "timer";
private static final File FILE = new File("target/test.properties");
private static Timer saveTimer;
-
+
private TimerTask task;
private Timer timer;
private TestListener testListener;
-
+
@BeforeClass
public static void setUpBeforeClass() {
- saveTimer = Whitebox.getInternalState(PropertyUtil.LazyHolder.class, TIMER_FIELD);
-
+ saveTimer = (Timer) ReflectionTestUtils.getField(PropertyUtil.LazyHolder.class, TIMER_FIELD);
+
}
-
+
@AfterClass
public static void tearDownAfterClass() {
- Whitebox.setInternalState(PropertyUtil.LazyHolder.class, TIMER_FIELD, saveTimer);
-
+ ReflectionTestUtils.setField(PropertyUtil.LazyHolder.class, TIMER_FIELD, saveTimer);
+
}
/**
@@ -74,15 +75,15 @@ public class PropertyUtilTest {
public void setUp() throws IOException {
task = null;
timer = mock(Timer.class);
- Whitebox.setInternalState(PropertyUtil.LazyHolder.class, TIMER_FIELD, timer);
-
+ ReflectionTestUtils.setField(PropertyUtil.LazyHolder.class, TIMER_FIELD, timer);
+
doAnswer(args -> {
task = args.getArgument(0, TimerTask.class);
return null;
}).when(timer).schedule(any(TimerTask.class), anyLong(), anyLong());
-
+
testListener = new TestListener();
-
+
FileOutputStream fileOutputStream = new FileOutputStream(FILE);
Properties properties = new Properties();
properties.put("testProperty", "testValue");
@@ -95,7 +96,7 @@ public class PropertyUtilTest {
PropertyUtil.stopListening(FILE, testListener);
FILE.delete();
}
-
+
@Test
public void testTimer() {
assertNotNull(saveTimer);