diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2020-01-21 19:17:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-21 19:17:15 +0000 |
commit | 3fcc3204c1c65a5e5f774088bca1fd81dedd9ddb (patch) | |
tree | b1d2274b8b745ec90cdcc78c38b7ba6503f7472f | |
parent | 40483cec64275e908c498309503cb17fbbd81c7a (diff) | |
parent | e37f5a70bcf3fd8073418c13416cc79c0ef47d59 (diff) |
Merge "policy/engine jdk11 upgrades"
30 files changed, 256 insertions, 101 deletions
diff --git a/BRMSGateway/pom.xml b/BRMSGateway/pom.xml index 5b344af8a..8f6a79df1 100644 --- a/BRMSGateway/pom.xml +++ b/BRMSGateway/pom.xml @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -109,7 +109,7 @@ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> + <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories> <includeResources>true</includeResources> <includeTestSourceDirectory>true</includeTestSourceDirectory> <includeTestResources>true</includeTestResources> @@ -123,7 +123,7 @@ <dependency> <groupId>org.onap.oparent</groupId> <artifactId>checkstyle</artifactId> - <version>0.1.1</version> + <version>${oparent.version}</version> <scope>compile</scope> </dependency> </dependencies> diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java index de1a7d6eb..994e97368 100644 --- a/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java +++ b/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017, 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest2() throws PolicyException { + public void testBrmsHandlerFail2() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "defaultName"; prop.remove = true; @@ -92,7 +92,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest3() throws PolicyException { + public void testBrmsHandlerFail3() throws PolicyException { PropertyChange prop = new PropertyChange(); prop.key = "repositoryID"; prop.remove = true; @@ -107,7 +107,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest4() throws PolicyException { + public void testBrmsHandlerFail4() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "repositoryURL"; prop.remove = true; @@ -118,7 +118,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest5() throws PolicyException { + public void testBrmsHandlerFail5() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "repositoryName"; prop.remove = true; @@ -129,7 +129,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest6() throws PolicyException { + public void testBrmsHandlerFail6() throws PolicyException { PropertyChange prop = new PropertyChange(); prop.key = "repositoryURL"; prop.value = "http://nexus:8081/nexus/content/repositories/releases," @@ -146,7 +146,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest7() throws PolicyException { + public void testBrmsHandlerFail7() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "repositoryPassword"; prop.remove = true; @@ -157,7 +157,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest8() throws PolicyException { + public void testBrmsHandlerFail8() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "policyKeyID"; prop.remove = true; @@ -168,7 +168,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest9() throws PolicyException { + public void testBrmsHandlerFail9() throws PolicyException { PropertyChange prop = new PropertyChange(); prop.key = "sync"; prop.value = "true"; @@ -188,7 +188,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest10() throws PolicyException { + public void testBrmsHandlerFail10() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "groupNames"; prop.value = ""; @@ -200,7 +200,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest11() throws PolicyException { + public void testBrmsHandlerFail11() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "default.groupID"; prop.remove = true; @@ -211,7 +211,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest12() throws PolicyException { + public void testBrmsHandlerFail12() throws PolicyException { final PropertyChange prop = new PropertyChange(); prop.key = "default.artifactID"; prop.remove = true; @@ -222,7 +222,7 @@ public class BrmsPushTest { } @Test(expected = PolicyException.class) - public void brmsHandlerFailTest13() throws PolicyException { + public void testBrmsHandlerFail13() throws PolicyException { PropertyChange prop = new PropertyChange(); prop.key = "NOTIFICATION_TYPE"; prop.value = "dmaap"; diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java index 8fda22e26..079db2109 100644 --- a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java +++ b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ package org.onap.policy.brms.api; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; @@ -38,14 +38,16 @@ import org.onap.policy.api.NotificationType; import org.onap.policy.std.StdPDPNotification; import org.onap.policy.utils.BackUpMonitor; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest({Persistence.class, BackUpMonitor.class}) public class BrmsHandlerTest { - @PrepareForTest({Persistence.class, BackUpMonitor.class}) @Test - public void negativeTestNotifications() throws Exception { + public void testNegativeTestNotifications() throws Exception { // Mock emf, persistence, and query final EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class); final EntityManager em = Mockito.mock(EntityManager.class); diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java index 4141a8bd2..3adc55700 100644 --- a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java +++ b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsPushTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ package org.onap.policy.brms.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import java.util.HashMap; import java.util.List; @@ -46,15 +46,17 @@ import org.onap.policy.utils.BackUpHandler; import org.onap.policy.utils.BackUpMonitor; import org.onap.policy.utils.BackUpMonitorException; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest({Persistence.class, BackUpMonitor.class}) public class BrmsPushTest { @Rule public ExpectedException thrown = ExpectedException.none(); - @PrepareForTest({Persistence.class, BackUpMonitor.class}) @Test public void testPush() throws BackUpMonitorException, PolicyException { // Mock emf, persistence, and query diff --git a/LogParser/pom.xml b/LogParser/pom.xml index b0281ba88..24ebb6d38 100644 --- a/LogParser/pom.xml +++ b/LogParser/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -135,7 +135,7 @@ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> + <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories> <includeResources>true</includeResources> <includeTestSourceDirectory>true</includeTestSourceDirectory> <includeTestResources>true</includeTestResources> diff --git a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java index 313750eeb..6609778a0 100644 --- a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java +++ b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * LogParser * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,11 +47,13 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.xacml.parser.LogEntryObject.LogType; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -@PrepareForTest({ ParseLogTest.class, IntegrityMonitor.class }) @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*"}) +@PrepareForTest({ ParseLogTest.class, IntegrityMonitor.class }) public class ParseLogTest { private static Logger logger = FlexLogger.getLogger(ParseLogTest.class); diff --git a/ONAP-PAP-REST/pom.xml b/ONAP-PAP-REST/pom.xml index 33c6e84dc..111c24201 100644 --- a/ONAP-PAP-REST/pom.xml +++ b/ONAP-PAP-REST/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. Modifications Copyright (C) 2019 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,8 +54,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.8</source> - <target>1.8</target> + <release>${java.version}</release> </configuration> </plugin> </plugins> @@ -115,6 +114,27 @@ <artifactId>javax.servlet-api</artifactId> </dependency> <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>${version.javax.bind}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.3.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.activation</groupId> + <artifactId>javax.activation-api</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>javax.xml</groupId> + <artifactId>jaxp-api</artifactId> + <version>1.4.2</version> + </dependency> + <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java index ffac655a6..fcec4a652 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static org.mockito.ArgumentMatchers.anyString; import java.io.File; import java.util.ArrayList; @@ -35,7 +36,6 @@ import org.json.JSONObject; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Matchers; import org.mockito.Mockito; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; @@ -45,11 +45,14 @@ import org.onap.policy.pap.xacml.rest.components.Policy; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.PolicyDbDaoEntity; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.mock.web.MockHttpServletResponse; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xalan.*", "com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest(UpdateOthersPAPS.class) public class UpdateOthersPAPSTest { private static Logger logger = FlexLogger.getLogger(UpdateOthersPAPSTest.class); @@ -110,7 +113,7 @@ public class UpdateOthersPAPSTest { when(Policy.getActionHome()).thenReturn("test"); File mockedFile = Mockito.mock(File.class); Mockito.when(mockedFile.exists()).thenReturn(true); - PowerMockito.whenNew(File.class).withParameterTypes(String.class).withArguments(Matchers.anyString()) + PowerMockito.whenNew(File.class).withParameterTypes(String.class).withArguments(anyString()) .thenReturn(mockedFile); updateOtherPaps.updateConfiguration(data, response); assertTrue(response.getStatus() == 200); diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java index d0e4416f9..885230da4 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import com.mockrunner.mock.web.MockHttpServletRequest; @@ -51,10 +51,13 @@ import org.onap.policy.rest.jpa.PolicyVersion; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; import org.onap.policy.xacml.std.pap.StdEngine; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest(DeleteHandler.class) public class DeleteHandlerTest { @Before public void setUp() { diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java index ebd3292aa..8136c8329 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,13 @@ import org.onap.policy.pap.xacml.rest.XACMLPapServlet; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.PolicyVersion; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest(CommonClassDao.class) public class MetricServiceTest { @PrepareForTest({XACMLPapServlet.class}) @Test diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java index fb768f7d7..841fad641 100644 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PDP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017, 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -59,6 +59,9 @@ public class PapUrlResolverTest { succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); + Assert.assertEquals("http://one.localhost.com", rs.getUrl()); + rs.getNext(); + Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://two.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); @@ -66,9 +69,6 @@ public class PapUrlResolverTest { rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://four.localhost.com", rs.getUrl()); - rs.getNext(); - Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://one.localhost.com", rs.getUrl()); rs.succeeded(); rs.getNext(); Assert.assertFalse(rs.hasMoreUrls()); @@ -128,13 +128,13 @@ public class PapUrlResolverTest { String succeeded = "-1,8/13/15 5:41 PM,8/13/15 4:41 PM,-1"; PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://two.localhost.com", rs.getUrl()); + Assert.assertEquals("http://one.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://three.localhost.com", rs.getUrl()); + Assert.assertEquals("http://two.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://one.localhost.com", rs.getUrl()); + Assert.assertEquals("http://three.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://four.localhost.com", rs.getUrl()); @@ -186,13 +186,13 @@ public class PapUrlResolverTest { succeeded = "-1,-1,-1,-1"; rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://two.localhost.com", rs.getUrl()); + Assert.assertEquals("http://one.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://three.localhost.com", rs.getUrl()); + Assert.assertEquals("http://two.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://one.localhost.com", rs.getUrl()); + Assert.assertEquals("http://three.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://four.localhost.com", rs.getUrl()); @@ -204,6 +204,9 @@ public class PapUrlResolverTest { succeeded = "-1,-1,-1,-1"; rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); + Assert.assertEquals("http://one.localhost.com", rs.getUrl()); + rs.getNext(); + Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://two.localhost.com", rs.getUrl()); rs.getNext(); Assert.assertTrue(rs.hasMoreUrls()); @@ -212,9 +215,6 @@ public class PapUrlResolverTest { Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://four.localhost.com", rs.getUrl()); rs.getNext(); - Assert.assertTrue(rs.hasMoreUrls()); - Assert.assertEquals("http://one.localhost.com", rs.getUrl()); - rs.getNext(); Assert.assertFalse(rs.hasMoreUrls()); urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com"; diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java index 17601a280..eb6910ca7 100644 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PDP-REST * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -47,6 +47,7 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.xacml.std.pap.StdPDPPolicy; import org.onap.policy.xacml.std.pap.StdPDPStatus; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.mock.web.MockHttpServletResponse; @@ -56,6 +57,7 @@ import com.mockrunner.mock.web.MockServletInputStream; import junit.framework.TestCase; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*", "org.w3c.dom.*"}) @PrepareForTest({IntegrityMonitor.class}) public class XACMLPdpServletTest extends TestCase { private static Logger LOGGER = FlexLogger.getLogger(XACMLPdpServletTest.class); diff --git a/ONAP-PDP/checkstyle-suppressions.xml b/ONAP-PDP/checkstyle-suppressions.xml new file mode 100644 index 000000000..ee01ae5ae --- /dev/null +++ b/ONAP-PDP/checkstyle-suppressions.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2020 AT&T Technologies. All rights reserved. + ================================================================================ + 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. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + + **** NOTE **** + This file is needed to suppress checkstyle for properties files. + ************** +--> + +<!DOCTYPE suppressions PUBLIC + "-//Puppy Crawl//DTD Suppressions 1.0//EN" + "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> + +<suppressions> + <suppress files="\.properties" checks="[a-zA-Z0-9]*"/> +</suppressions> diff --git a/ONAP-PDP/pom.xml b/ONAP-PDP/pom.xml index 044219523..7613258f0 100644 --- a/ONAP-PDP/pom.xml +++ b/ONAP-PDP/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -99,12 +99,13 @@ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> + <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories> <includeResources>true</includeResources> <includeTestSourceDirectory>true</includeTestSourceDirectory> <includeTestResources>true</includeTestResources> <excludes> </excludes> + <suppressionsLocation>/checkstyle-suppressions.xml</suppressionsLocation> <consoleOutput>true</consoleOutput> <failOnViolation>true</failOnViolation> <violationSeverity>warning</violationSeverity> diff --git a/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java b/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java index d3ee544a5..9447a951a 100644 --- a/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java +++ b/ONAP-PDP/src/test/java/org/onap/policy/xacml/pdp/OnapPdpEngineFactoryTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PDP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*"}) +@PrepareForTest(OnapPdpEngineFactory.class) public class OnapPdpEngineFactoryTest { @Test public final void testNewEngine() { @@ -61,7 +64,7 @@ public class OnapPdpEngineFactoryTest { @PrepareForTest({ EvaluationContextFactory.class, FactoryFinder.class }) @Test(expected = FactoryException.class) - public void negTestEngine() throws FactoryException { + public void testNegTestEngine() throws FactoryException { // Setup test data PowerMockito.mockStatic(FactoryFinder.class); PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(null); @@ -74,7 +77,7 @@ public class OnapPdpEngineFactoryTest { @PrepareForTest({ EvaluationContextFactory.class, FactoryFinder.class }) @Test(expected = FactoryException.class) - public void negTestEngine2() throws FactoryException { + public void testNegTestEngine2() throws FactoryException { // Setup test data PowerMockito.mockStatic(FactoryFinder.class); PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(null); diff --git a/ONAP-SDK-APP/pom.xml b/ONAP-SDK-APP/pom.xml index 240ee7f65..fa41d92fe 100644 --- a/ONAP-SDK-APP/pom.xml +++ b/ONAP-SDK-APP/pom.xml @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -185,6 +185,11 @@ </plugins> </build> <dependencies> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito2</artifactId> + <scope>test</scope> + </dependency> <!-- Policy overlay war --> <dependency> <groupId>org.onap.policy.engine</groupId> diff --git a/ONAP-XACML/pom.xml b/ONAP-XACML/pom.xml index 75bf1c036..8bb78f6c0 100644 --- a/ONAP-XACML/pom.xml +++ b/ONAP-XACML/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -48,6 +48,32 @@ <artifactId>httpcore</artifactId> </dependency> <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>${version.javax.bind}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.3.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.activation</groupId> + <artifactId>javax.activation-api</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>javax.xml</groupId> + <artifactId>jaxp-api</artifactId> + <version>1.4.2</version> + </dependency> + <dependency> + <groupId>javax.xml.parsers</groupId> + <artifactId>jaxp-api</artifactId> + <version>1.4.5</version> + </dependency> + <dependency> <groupId>com.att.research.xacml</groupId> <artifactId>xacml</artifactId> <version>1.0.2</version> diff --git a/POLICY-SDK-APP/pom.xml b/POLICY-SDK-APP/pom.xml index 6a98e0f6e..9c8716b6d 100644 --- a/POLICY-SDK-APP/pom.xml +++ b/POLICY-SDK-APP/pom.xml @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -75,6 +75,11 @@ </properties> <dependencies> <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito2</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </dependency> diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java index d8c691ad5..cf85186a0 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java @@ -73,12 +73,14 @@ import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.portalsdk.core.web.support.UserUtils; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; import org.springframework.mock.web.MockHttpServletResponse; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) public class PolicyManagerServletTest extends Mockito { private static Logger logger = FlexLogger.getLogger(PolicyManagerServletTest.class); @@ -834,7 +836,6 @@ public class PolicyManagerServletTest extends Mockito { PowerMockito.mockStatic(ServletFileUpload.class); when(ServletFileUpload.isMultipartContent(mockRequest)).thenReturn(true); servlet.doPost(mockRequest, mockResponse); - PowerMockito.verifyStatic(ServletFileUpload.class, Mockito.times(1)); } @SuppressWarnings("unchecked") @@ -939,9 +940,9 @@ public class PolicyManagerServletTest extends Mockito { mockPolicyController, resultList); assertTrue(result); - verify(mockPolicyController, atLeast(1)).getRoles(any(String.class)); - verify(mockPolicyController, atLeast(1)).getRoles(any(String.class)); - verify(mockPolicyController, atLeast(1)).getData(any(Class.class)); + verify(mockPolicyController, atLeast(1)).getRoles(any()); + verify(mockPolicyController, atLeast(1)).getRoles(any()); + verify(mockPolicyController, atLeast(1)).getData(any()); verify(mockPolicyController, atLeast(1)).getEntityItem(UserInfo.class, "userLoginId", "sampleUserName"); verify(mockPolicyVersion, atLeast(1)).getPolicyName(); verify(mockPolicyVersion, atLeast(1)).getModifiedDate(); diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java index be38e799c..b2e1b9228 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java @@ -62,12 +62,14 @@ import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.portalsdk.core.web.support.UserUtils; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; import org.springframework.mock.web.MockHttpServletResponse; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) public class PolicyRestControllerTest { private String clRequestString; diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AdminTabControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AdminTabControllerTest.java index b4a4130ab..eccab040c 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AdminTabControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AdminTabControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017, 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -115,7 +115,7 @@ public class AdminTabControllerTest { @Test public void testGetAdminTabEntityDataException() throws IOException { HttpServletResponse mockResponse = Mockito.mock(HttpServletResponse.class); - when(mockResponse.getWriter()).thenThrow(Exception.class); + when(mockResponse.getWriter()).thenThrow(IOException.class); admin.getAdminTabEntityData(request, mockResponse); verify(mockResponse).getWriter(); } diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java index 5e390da53..95d566278 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -24,7 +24,7 @@ package org.onap.policy.controller; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -53,10 +53,12 @@ import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.web.support.AppUtils; import org.onap.portalsdk.core.web.support.UserUtils; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) public class AutoPushControllerTest { private PolicyController controller = new PolicyController(); private AutoPushController apController = new AutoPushController(); diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyExportAndImportControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyExportAndImportControllerTest.java index 84e9ccf84..4b348cf2b 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyExportAndImportControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyExportAndImportControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ package org.onap.policy.controller; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import com.mockrunner.mock.web.MockHttpServletRequest; @@ -48,10 +48,12 @@ import org.onap.policy.rest.jpa.UserInfo; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.web.support.UserUtils; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) public class PolicyExportAndImportControllerTest { @Test public void testSetAndGet() { diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyNotificationControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyNotificationControllerTest.java index 509f4a692..31b2dffb3 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyNotificationControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyNotificationControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -24,7 +24,7 @@ package org.onap.policy.controller; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import com.mockrunner.mock.web.MockHttpServletRequest; @@ -42,13 +42,15 @@ import org.onap.policy.rest.dao.CommonClassDao; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.web.support.UserUtils; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.web.servlet.ModelAndView; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest({UserUtils.class}) public class PolicyNotificationControllerTest { - @PrepareForTest({UserUtils.class}) @Test public void testWatch() throws IOException { // Mock user utilities diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java index dbe49c7c3..2b1052044 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017, 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -40,6 +40,7 @@ import javax.script.SimpleBindings; import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; import org.h2.tools.Server; import org.hibernate.Criteria; +import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; @@ -463,7 +464,7 @@ public class CommonClassDaoImplTest { @SuppressWarnings("unchecked") @Test - public void testExceptions() { + public void testExceptions() throws HibernateException { SessionFactory sfMock = Mockito.mock(SessionFactory.class); Session mockSession = Mockito.mock(Session.class); Criteria crMock = Mockito.mock(Criteria.class); @@ -474,11 +475,11 @@ public class CommonClassDaoImplTest { when(sfMock.openSession()).thenReturn(mockSession); when(mockSession.createCriteria(OnapName.class)).thenReturn(crMock); - when(crMock.list()).thenThrow(Exception.class); - when(mockSession.close()).thenThrow(Exception.class); + when(crMock.list()).thenThrow(HibernateException.class); + when(mockSession.close()).thenThrow(HibernateException.class); when(mockSession.beginTransaction()).thenReturn(mockTransaction); - doThrow(Exception.class).when(mockTransaction).commit(); + doThrow(HibernateException.class).when(mockTransaction).commit(); List<?> dataList = commonClassDao.getData(OnapName.class); assertNull(dataList); diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/SystemLogDbDaoImplTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/SystemLogDbDaoImplTest.java index 5675d3fc9..44f034c20 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/SystemLogDbDaoImplTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/SystemLogDbDaoImplTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; import java.util.List; + +import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; @@ -50,8 +52,8 @@ public class SystemLogDbDaoImplTest { when(sfMock.openSession()).thenReturn(mockSession); when(mockSession.beginTransaction()).thenReturn(mockTransaction); - doThrow(Exception.class).when(mockTransaction).commit(); - when(mockSession.close()).thenThrow(Exception.class); + doThrow(HibernateException.class).when(mockTransaction).commit(); + when(mockSession.close()).thenThrow(HibernateException.class); PolicyController.setjUnit(true); } diff --git a/PolicyEngineAPI/pom.xml b/PolicyEngineAPI/pom.xml index 6bde8fb07..94c06b79e 100644 --- a/PolicyEngineAPI/pom.xml +++ b/PolicyEngineAPI/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -31,7 +31,39 @@ <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.json</artifactId> - <version>1.0.4</version> + <version>1.1.4</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>${version.javax.bind}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.3.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.activation</groupId> + <artifactId>javax.activation-api</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>javax.xml.ws</groupId> + <artifactId>jaxws-api</artifactId> + <version>2.3.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.xml</groupId> + <artifactId>jaxp-api</artifactId> + <version>1.4.2</version> + </dependency> + <dependency> + <groupId>javax.xml.parsers</groupId> + <artifactId>jaxp-api</artifactId> + <version>1.4.5</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> @@ -90,8 +122,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.8</source> - <target>1.8</target> + <release>${java.version}</release> </configuration> </plugin> <plugin> diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java index 90e00c2c3..a7f609904 100644 --- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java @@ -5,6 +5,7 @@ * Copyright (C) 2018 Ericsson. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung + * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,8 @@ package org.onap.policy.std; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.spy; @@ -103,6 +104,8 @@ import org.onap.policy.api.PushPolicyParameters; import org.onap.policy.models.APIDictionaryResponse; import org.onap.policy.models.APIPolicyConfigResponse; import org.onap.policy.std.utils.PolicyConfigConstants; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -111,6 +114,8 @@ import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestClientException; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest(StdPolicyEngine.class) public class StdPolicyEngineTest { private static final String ONAP_NAME_VAL = "ONAP_NAME"; diff --git a/packages/docker/src/main/docker/Dockerfile b/packages/docker/src/main/docker/Dockerfile index 7ef47b423..580beccb6 100644 --- a/packages/docker/src/main/docker/Dockerfile +++ b/packages/docker/src/main/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM onap/policy-common-alpine:1.4.0 +FROM onap/policy-jdk-debian LABEL maintainer="Policy Team" @@ -8,9 +8,9 @@ ARG POLICY_LOGS=/var/log/onap ENV BUILD_VERSION_ENGINE ${BUILD_VERSION_ENGINE} ENV POLICY_LOGS ${POLICY_LOGS} -RUN apk add --no-cache mariadb-client - -RUN mkdir -p /tmp/policy-install ${POLICY_LOGS} && \ +RUN apt update && \ + apt-get install -y mariadb-client && \ + mkdir -p /tmp/policy-install ${POLICY_LOGS} && \ chown policy:policy /tmp/policy-install ${POLICY_LOGS} && \ rmdir ${POLICY_HOME}/etc/ssl && \ rmdir ${POLICY_HOME}/etc @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.policy.parent</groupId> <artifactId>integration</artifactId> - <version>3.1.0</version> + <version>3.1.1-SNAPSHOT</version> <relativePath /> </parent> <groupId>org.onap.policy.engine</groupId> @@ -35,8 +35,6 @@ <description>The ONAP Policy Engine main pom</description> <properties> <!-- Project common build settings --> - <project.source.version>1.8</project.source.version> - <project.target.version>1.8</project.target.version> <project.encoding>UTF-8</project.encoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- Project path properties --> @@ -56,8 +54,8 @@ <commons.fileupload.version>1.3.3</commons.fileupload.version> <commons.compress.version>1.18</commons.compress.version> <elasticsearch.version>6.8.2</elasticsearch.version> - <version.policy.common>1.6.1</version.policy.common> - <version.policy.models>2.2.0</version.policy.models> + <version.policy.common>1.6.2-SNAPSHOT</version.policy.common> + <version.policy.models>2.2.1-SNAPSHOT</version.policy.models> </properties> <modules> <module>PolicyEngineUtils</module> @@ -109,7 +107,7 @@ <!-- org.w3c.dom dependencies --> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> - <version>1.3.03</version> + <version>1.4.01</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> @@ -142,7 +140,7 @@ <!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito --> <dependency> <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito</artifactId> + <artifactId>powermock-api-mockito2</artifactId> <scope>test</scope> </dependency> <dependency> @@ -159,7 +157,7 @@ <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> - <version>3.1</version> + <version>4.1</version> <scope>test</scope> </dependency> <dependency> @@ -191,8 +189,7 @@ <artifactId>maven-compiler-plugin</artifactId> <configuration> <encoding>${project.encoding}</encoding> - <source>${project.source.version}</source> - <target>${project.target.version}</target> + <release>${java.version}</release> </configuration> </plugin> <plugin> |