diff options
author | Dan Timoney <dtimoney@att.com> | 2023-01-31 08:15:34 -0500 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2023-02-07 10:24:42 -0500 |
commit | 72aef3a6324c78a62d0eff65217d4861440841f5 (patch) | |
tree | 7a208d5d4630a046e05768e004956c4c9cffa253 /plugins | |
parent | 8393d347d303d70e4ff4c7c91b7454467545cab3 (diff) |
Fix Java 17 jUnit errors
Add explicit lombok dependency to resolve compile error when compiling
under java 17
Fixed code issues in jUnit tests due to restrictions on reflection
in Java 17, which disallow jUnit from setting system properties
or environment variables.
Issue-ID: CCSDK-3813
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I278ee869d2ce0568b29ecc29c37d00d7fce757a8
Diffstat (limited to 'plugins')
4 files changed, 17 insertions, 23 deletions
diff --git a/plugins/grToolkit/provider/pom.xml b/plugins/grToolkit/provider/pom.xml index 87f2a789a..e39e17434 100755 --- a/plugins/grToolkit/provider/pom.xml +++ b/plugins/grToolkit/provider/pom.xml @@ -150,6 +150,7 @@ <environmentVariables> <ODL_USER>admin</ODL_USER> <ODL_PASSWORD>admin</ODL_PASSWORD> + <SDNC_CONFIG_DIR>src/test/resources</SDNC_CONFIG_DIR> </environmentVariables> </configuration> </plugin> @@ -160,6 +161,7 @@ <environmentVariables> <ODL_USER>admin</ODL_USER> <ODL_PASSWORD>admin</ODL_PASSWORD> + <SDNC_CONFIG_DIR>src/test/resources</SDNC_CONFIG_DIR> </environmentVariables> </configuration> </plugin> diff --git a/plugins/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java b/plugins/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java index 6495c89cf..98e55e50d 100644 --- a/plugins/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java +++ b/plugins/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java @@ -46,7 +46,6 @@ import java.util.stream.Stream; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.contrib.java.lang.system.EnvironmentVariables; import org.onap.ccsdk.sli.core.dblib.DBLibConnection; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; @@ -81,13 +80,10 @@ public class GrToolkitProviderTest { Properties properties; @Rule - public final EnvironmentVariables environmentVariables = new EnvironmentVariables(); - @Rule public WireMockRule wireMockRule = new WireMockRule(9999); @Before public void setup() { - environmentVariables.set("SDNC_CONFIG_DIR","src/test/resources"); dataBroker = mock(DataBroker.class); notificationProviderService = mock(NotificationPublishService.class); rpcProviderRegistry = mock(RpcProviderService.class); diff --git a/plugins/properties-node/provider/pom.xml b/plugins/properties-node/provider/pom.xml index ddae8edca..66b79b14b 100755 --- a/plugins/properties-node/provider/pom.xml +++ b/plugins/properties-node/provider/pom.xml @@ -33,17 +33,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>com.github.stefanbirkner</groupId> - <artifactId>system-rules</artifactId> - <version>1.19.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.onap.ccsdk.sli.core</groupId> <artifactId>sli-common</artifactId> <scope>provided</scope> @@ -57,4 +46,17 @@ <artifactId>jettison</artifactId> </dependency> </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <environmentVariables> + <deployer_pass>sdncp-123</deployer_pass> + </environmentVariables> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java index 34ac4685f..f5259845d 100644 --- a/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java +++ b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java @@ -1,13 +1,8 @@ package jtest.org.onap.ccsdk.sli.plugins.prop; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; - -import org.junit.Rule; import org.junit.Test; -import org.junit.contrib.java.lang.system.EnvironmentVariables; import static org.junit.Assert.assertEquals; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -18,8 +13,7 @@ import org.slf4j.LoggerFactory; public class TestPropertiesNode { private static final Logger log = LoggerFactory.getLogger(TestPropertiesNode.class); - @Rule - public EnvironmentVariables environmentVariables = new EnvironmentVariables(); + @Test public void testJSONFileParsing() throws SvcLogicException { @@ -134,7 +128,7 @@ public class TestPropertiesNode { @Test public void testTXTFileParsing() throws SvcLogicException { - environmentVariables.set("deployer_pass", "sdncp-123"); + assertEquals("sdncp-123", System.getenv("deployer_pass")); SvcLogicContext ctx = new SvcLogicContext(); |