aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PDP-REST/src/test/java/org')
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java54
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java8
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java2
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java1
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java11
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java2
6 files changed, 42 insertions, 36 deletions
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 cf3ddb3b2..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
* ================================================================================
@@ -28,7 +28,7 @@ import java.util.Date;
import java.util.Properties;
import org.junit.Assert;
import org.junit.Test;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRestProperties;
public class PapUrlResolverTest {
@@ -41,7 +41,7 @@ public class PapUrlResolverTest {
String failed = "-1,-1,-1,-1";
String succeeded = "-1,-1,-1,-1";
PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertEquals(rs.getProperties().getProperty(XACMLRestProperties.PROP_PAP_URLS),
+ Assert.assertEquals(rs.getProperties().getProperty(XacmlRestProperties.PROP_PAP_URLS),
urls);
rs.failed();
@@ -51,14 +51,17 @@ public class PapUrlResolverTest {
Assert.assertFalse(rs.hasMoreUrls());
Properties prop = rs.getProperties();
Assert.assertEquals(df.format(new Date()) + ",-1,-1,-1",
- prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS));
+ prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS));
Assert.assertEquals("-1," + df.format(new Date()) + ",-1,-1",
- prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS));
+ prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS));
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS);
+ 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,18 +69,15 @@ 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());
prop = rs.getProperties();
Assert.assertEquals("-1,-1,-1,-1",
- prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS));
+ prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS));
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS);
+ 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());
@@ -85,8 +85,8 @@ public class PapUrlResolverTest {
rs.getNext();
Assert.assertFalse(rs.hasMoreUrls());
prop = rs.getProperties();
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS);
+ 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());
@@ -94,8 +94,8 @@ public class PapUrlResolverTest {
rs.getNext();
Assert.assertFalse(rs.hasMoreUrls());
prop = rs.getProperties();
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS);
+ 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());
@@ -104,7 +104,7 @@ public class PapUrlResolverTest {
Assert.assertFalse(rs.hasMoreUrls());
prop = rs.getProperties();
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS);
}
@SuppressWarnings("unused")
@@ -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 14c231aed..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-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2019 Samsung
* ================================================================================
@@ -41,12 +41,13 @@ import org.mockito.Mockito;
import org.onap.policy.common.ia.IntegrityAuditProperties;
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.IntegrityMonitorException;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
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);
@@ -223,7 +225,7 @@ public class XACMLPdpServletTest extends TestCase {
public void testXACMLPdpRegisterThread() {
LOGGER.info("XACMLPdpServletTest - testXACMLPdpRegisterThread");
try {
- ONAPLoggingContext baseLoggingContext = new ONAPLoggingContext();
+ OnapLoggingContext baseLoggingContext = new OnapLoggingContext();
baseLoggingContext.setServer("localhost");
XACMLPdpRegisterThread regThread = new XACMLPdpRegisterThread(baseLoggingContext);
regThread.run();
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java
index 4544b6b1c..1904b4bf0 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java
@@ -76,7 +76,7 @@ public class GetDictionaryServiceTest {
result = (String) formatDictionary.invoke(gds, input);
assertNotNull(result);
//
- dp.setDictionary("PEPOptions");
+ dp.setDictionary("PepOptions");
gds = new GetDictionaryService(dp, null);
result = (String) formatDictionary.invoke(gds, input);
assertNotNull(result);
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java
index d1da554d9..d09059978 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertTrue;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
-import org.json.JSONObject;
import org.junit.Test;
import org.onap.policy.pdp.rest.api.utils.PolicyApiUtils;
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java
index 0795526fc..4f03221b7 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java
@@ -24,11 +24,15 @@ package org.onap.policy.pdp.rest.auth.test;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
+
+import com.att.research.xacml.util.XACMLProperties;
+
import java.io.UnsupportedEncodingException;
import java.util.Base64;
import javax.servlet.ServletRequest;
import org.junit.Test;
import org.onap.policy.pdp.rest.restauth.AuthenticationService;
+import org.onap.policy.rest.XacmlRestProperties;
public class AuthenticationServiceTest {
private final String testCred = "python:test";
@@ -40,10 +44,13 @@ public class AuthenticationServiceTest {
String systemKey = "xacml.properties";
// Set the system property temporarily
- String oldProperty = System.getProperty(systemKey);
+ final String oldProperty = System.getProperty(systemKey);
System.setProperty(systemKey, "xacml.pdp.properties");
- ServletRequest request = mock(ServletRequest.class);
+ XACMLProperties.setProperty("enable_aaf", "false");
+ XACMLProperties.setProperty(XacmlRestProperties.PROP_PEP_IDFILE, "client.properties");
+ ServletRequest request = mock(ServletRequest.class);
+ AuthenticationService.getEnvironment();
assertTrue(AuthenticationService.checkPermissions(null, basicCred, "getConfig", "DEVL", request));
// Restore the original system property
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java
index 261226527..190f93aa7 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java
@@ -23,8 +23,6 @@ package org.onap.policy.pdp.rest.notifications.test;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.onap.policy.api.NotificationType;