summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java99
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java41
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java80
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java55
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java31
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java11
-rw-r--r--docs/platform/aaf.rst4
7 files changed, 177 insertions, 144 deletions
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 b017bc2a4..8707ee0ff 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
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
* 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.
@@ -26,15 +28,14 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Random;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
+
import javax.servlet.ServletConfig;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -52,8 +53,10 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
+
import com.att.research.xacml.util.XACMLProperties;
import com.mockrunner.mock.web.MockServletInputStream;
+
import junit.framework.TestCase;
@RunWith(PowerMockRunner.class)
@@ -68,7 +71,6 @@ public class XACMLPdpServletTest extends TestCase {
private ServletInputStream mockInput;
private ServletConfig servletConfig;
private XACMLPdpServlet pdpServlet;
- private String persistenceUnit;
private Properties properties;
private String resourceName;
private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
@@ -77,6 +79,8 @@ public class XACMLPdpServletTest extends TestCase {
private StdPDPStatus status;
private StdPDPPolicy foobarPolicy;
+ private static final String ERROR_TEXT = "Exception occurred: ";
+
@Override
@Before
public void setUp() {
@@ -87,7 +91,6 @@ public class XACMLPdpServletTest extends TestCase {
foobarPolicy.setName("nothing");
status.addLoadedPolicy(foobarPolicy);
-
properties = new Properties();
properties.put(IntegrityAuditProperties.DB_DRIVER, XACMLPdpServletTest.DEFAULT_DB_DRIVER);
properties.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/xacmlTest");
@@ -95,25 +98,16 @@ public class XACMLPdpServletTest extends TestCase {
properties.put(IntegrityAuditProperties.DB_PWD, XACMLPdpServletTest.DEFAULT_DB_PWD);
properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
properties.put(IntegrityAuditProperties.NODE_TYPE, "pap");
- persistenceUnit = "testPdpPU";
resourceName = "siteA.pdp1";
System.setProperty("com.sun.management.jmxremote.port", "9999");
- EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
-
- EntityManager em = emf.createEntityManager();
- // Start a transaction
- EntityTransaction et = em.getTransaction();
-
IntegrityMonitor im = null;
try {
im = IntegrityMonitor.getInstance(resourceName, properties);
- } catch (Exception e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
- // cleanDb(persistenceUnit, properties);
httpServletRequest = Mockito.mock(HttpServletRequest.class);
Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
@@ -145,11 +139,7 @@ public class XACMLPdpServletTest extends TestCase {
System.setProperty("xacml.properties", "src/test/resources/xacml.pdp.properties");
System.setProperty("xacml.rest.pdp.config", "src/test/resources/config_testing");
System.setProperty("xacml.rest.pdp.webapps", "src/test/resources/webapps");
- /*
- * System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml");
- * System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml");
- * System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml");
- */
+
System.setProperty("xacml.rest.pdp.register", "false");
System.setProperty("com.sun.management.jmxremote.port", "9999");
@@ -161,8 +151,8 @@ public class XACMLPdpServletTest extends TestCase {
PowerMockito
.when(IntegrityMonitor.getInstance(Mockito.anyString(), Mockito.any(Properties.class)))
.thenReturn(im);
- } catch (Exception e1) {
- LOGGER.error("Exception Occured" + e1);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
}
try {
@@ -173,6 +163,13 @@ public class XACMLPdpServletTest extends TestCase {
Mockito.doNothing().when(im).endTransaction();
}
+ @Override
+ @After
+ public void tearDown()
+ {
+ System.clearProperty("xacml.rest.pdp.config");
+ }
+
@Test
public void testInit() {
LOGGER.info("XACMLPdpServletTest - testInit");
@@ -181,7 +178,7 @@ public class XACMLPdpServletTest extends TestCase {
assertTrue(true);
} catch (Exception e) {
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
@@ -206,7 +203,7 @@ public class XACMLPdpServletTest extends TestCase {
XACMLPdpLoader.sendNotification();
assertTrue(true);
} catch (Exception e) {
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
@@ -231,7 +228,7 @@ public class XACMLPdpServletTest extends TestCase {
XACMLPdpLoader.sendNotification();
assertTrue(true);
} catch (Exception e) {
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
@@ -249,7 +246,7 @@ public class XACMLPdpServletTest extends TestCase {
regThread.run();
assertTrue(true);
} catch (Exception e) {
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -264,8 +261,7 @@ public class XACMLPdpServletTest extends TestCase {
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoGetNoTypeError");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -281,8 +277,7 @@ public class XACMLPdpServletTest extends TestCase {
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoGetConfigType");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
@@ -298,8 +293,7 @@ public class XACMLPdpServletTest extends TestCase {
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoGetTypeHb");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -314,8 +308,7 @@ public class XACMLPdpServletTest extends TestCase {
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoGetTypeStatus");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -328,8 +321,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.doPost(httpServletRequest, httpServletResponse);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPost");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -345,8 +337,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.doPost(httpServletRequest, httpServletResponse);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPostToLong");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -362,8 +353,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.doPost(httpServletRequest, httpServletResponse);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPostContentLengthNegative");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -379,8 +369,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.doPost(httpServletRequest, httpServletResponse);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPostContentTypeNonValid");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -396,8 +385,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.doPost(httpServletRequest, httpServletResponse);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPostContentTypeConfigurationError");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -417,8 +405,7 @@ public class XACMLPdpServletTest extends TestCase {
"PUT must contain at least one property");
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPutCacheEmpty");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -439,8 +426,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.doPut(httpServletRequest, httpServletResponse);
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPutConfigPolicies");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -459,8 +445,7 @@ public class XACMLPdpServletTest extends TestCase {
"Content-Length larger than server will accept.");
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPutToLong");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -480,8 +465,7 @@ public class XACMLPdpServletTest extends TestCase {
"Invalid cache: 'policies' or content-type: 'text/json'");
assertTrue(true);
} catch (Exception e) {
- System.out.println("Unexpected exception in testDoPutInvalidContentType");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
@@ -494,8 +478,7 @@ public class XACMLPdpServletTest extends TestCase {
pdpServlet.init(servletConfig);
pdpServlet.destroy();
} catch (Exception e) {
- System.out.println("Unexpected exception in testDestroy");
- LOGGER.error("Exception Occured" + e);
+ LOGGER.error(ERROR_TEXT + e);
fail();
}
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
index 23e47f418..3461825ac 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
* 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.
@@ -19,7 +21,10 @@
*/
package org.onap.policy.pdp.rest.api.services;
-import static org.junit.Assert.*;
+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 java.io.FileInputStream;
import java.text.SimpleDateFormat;
@@ -31,8 +36,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.UUID;
-import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.AttributeType;
import org.onap.policy.api.PolicyConfigType;
@@ -40,18 +46,21 @@ import org.onap.policy.api.PolicyException;
import org.onap.policy.api.PolicyParameters;
public class BRMSParamPolicyServiceTest {
-
+
BRMSParamPolicyService service = null;
-
- @Before
- public void setUp() throws Exception {
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
Properties prop = new Properties();
prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
PAPServices.setJunit(true);
-
+ }
+
+ @Before
+ public void setUp() throws Exception {
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
policyParameters.setPolicyName("Test.testBRMSPolicy");
@@ -62,23 +71,23 @@ public class BRMSParamPolicyServiceTest {
policyParameters.setGuard(true);
policyParameters.setRiskLevel("5");
policyParameters.setRiskType("TEST");
-
+
Map<String, String> ruleAttributes = new HashMap<>();
ruleAttributes.put("templateName", "Sample");
- ruleAttributes.put("controller", "default");
- ruleAttributes.put("SamPoll", "300");
+ ruleAttributes.put("controller", "default");
+ ruleAttributes.put("SamPoll", "300");
ruleAttributes.put("value", "abcd");
Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
attributes.put(AttributeType.RULE, ruleAttributes);
policyParameters.setAttributes(attributes);
-
+
String policyName = "testBRMSPolicy";
String policyScope = "Test";
service = new BRMSParamPolicyService(policyName, policyScope, policyParameters, date.toString());
}
- @After
- public void tearDown() throws Exception {
+ @AfterClass
+ public static void tearDownAfterClass() {
PAPServices.setPaps(null);
PAPServices.setJunit(false);
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java
index b9e9403d4..8781b827e 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
* 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.
@@ -20,43 +22,59 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.assertEquals;
+
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.PolicyParameters;
public class BRMSRawPolicyServiceTest {
- @Test
- public void testRaw() throws FileNotFoundException, IOException {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
- prop.clear();
-
- String systemKey = "xacml.properties";
- String testVal = "testVal";
- PolicyParameters testParams = new PolicyParameters();
-
- // Set the system property temporarily
- String oldProperty = System.getProperty(systemKey);
- System.setProperty(systemKey, "xacml.pdp.properties");
-
- BRMSRawPolicyService service = new BRMSRawPolicyService(testVal, testVal, testParams, testVal);
- assertEquals(false, service.getValidation());
- assertEquals("PE300 - Data Issue: No Rule Body given", service.getMessage());
-
- // Restore the original system property
- if (oldProperty != null) {
- System.setProperty(systemKey, oldProperty);
- } else {
- System.clearProperty(systemKey);
+
+ private static final String SYSTEM_KEY = "xacml.properties";
+ private static String oldProperty;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+ oldProperty = System.getProperty(SYSTEM_KEY);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ // Restore the original system property
+ if (oldProperty != null) {
+ System.setProperty(SYSTEM_KEY, oldProperty);
+ } else {
+ System.clearProperty(SYSTEM_KEY);
+ }
+ }
+
+ @Test
+ public void testRaw() throws FileNotFoundException, IOException {
+
+ String testVal = "testVal";
+ PolicyParameters testParams = new PolicyParameters();
+
+ // Set the system property temporarily
+ System.setProperty(SYSTEM_KEY, "xacml.pdp.properties");
+
+ BRMSRawPolicyService service =
+ new BRMSRawPolicyService(testVal, testVal, testParams, testVal);
+ assertEquals(false, service.getValidation());
+ assertEquals("PE300 - Data Issue: No Rule Body given", service.getMessage());
}
- }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java
index 16f5a4732..5a3a6b387 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
* 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.
@@ -28,37 +30,50 @@ import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.PolicyParameters;
public class ConfigPolicyServiceTest {
- @Test
- public void testRaw() throws FileNotFoundException, IOException {
+
+ private static final String SYSTEM_KEY = "xacml.properties";
+ private static String oldProperty;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
Properties prop = new Properties();
prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
PAPServices.setJunit(true);
-
- String systemKey = "xacml.properties";
+ oldProperty = System.getProperty(SYSTEM_KEY);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ // Restore the original system property
+ if (oldProperty != null) {
+ System.setProperty(SYSTEM_KEY, oldProperty);
+ } else {
+ System.clearProperty(SYSTEM_KEY);
+ }
+ }
+
+ @Test
+ public void testRaw() throws FileNotFoundException, IOException {
+
String testVal = "testVal";
PolicyParameters testParams = new PolicyParameters();
-
+
// Set the system property temporarily
- String oldProperty = System.getProperty(systemKey);
- System.setProperty(systemKey, "xacml.pdp.properties");
-
+ System.setProperty(SYSTEM_KEY, "xacml.pdp.properties");
+
ConfigPolicyService service = new ConfigPolicyService(testVal, testVal, testParams, testVal);
assertEquals(service.getValidation(), false);
assertEquals(service.getMessage(), "PE300 - Data Issue: No Config Body given.");
-
- // Restore the original system property
- if (oldProperty != null) {
- System.setProperty(systemKey, oldProperty);
- }
- else {
- System.clearProperty(systemKey);
- }
- }
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java
index 79ca2e646..5a4195b79 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
* 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.
@@ -19,7 +21,9 @@
*/
package org.onap.policy.pdp.rest.api.services;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
@@ -29,8 +33,9 @@ import java.util.List;
import java.util.Properties;
import java.util.UUID;
-import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyException;
@@ -40,16 +45,18 @@ public class OptimizationPolicyServiceTest {
OptimizationPolicyService service = null;
- @Before
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
Properties prop = new Properties();
prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
String succeeded = prop.getProperty("xacml.rest.pap.url");
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
PAPServices.setJunit(true);
- prop.clear();
-
+ }
+
+ @Before
+ public void setUp() throws Exception {
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.Optimization);
policyParameters.setPolicyName("Test.testOOFPolicy");
@@ -67,8 +74,10 @@ public class OptimizationPolicyServiceTest {
service = new OptimizationPolicyService(policyName, policyScope, policyParameters, date.toString());
}
- @After
- public void tearDown() throws Exception {
+ @AfterClass
+ public static void tearDownAfterClass() {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
}
@Test
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 b5706a8ed..dcff39b88 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
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
* 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.
@@ -20,16 +22,13 @@
package org.onap.policy.pdp.rest.api.test;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import java.lang.reflect.Method;
-
import org.junit.Test;
import org.onap.policy.api.DictionaryParameters;
import org.onap.policy.pdp.rest.api.services.GetDictionaryService;
public class GetDictionaryServiceTest {
-
+
@Test
public void dictionaryJsonTest() throws Exception{
Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class);
diff --git a/docs/platform/aaf.rst b/docs/platform/aaf.rst
index a64afae16..50e109407 100644
--- a/docs/platform/aaf.rst
+++ b/docs/platform/aaf.rst
@@ -13,13 +13,13 @@ The pap, console, pdp-x, brmsgw, and pdp-d components have been migrated from HT
AAF is supported for externally facing entry points into the Policy subsystem. These are:
* PDP-D supports AAF for its telemetry and healthcheck APIs.
-* PDP-X supports AAF for its external policy APIs. It is currently disabled as some of clients are not AAF-capable, and this is a global setting.
+* PDP-X supports AAF for its external policy APIs. It is currently disabled as some of clients are not AAF-capable, and this is a global setting.
* Console (for Browser Portal redirects) supports AAF when accessed through Portal.
+--------+------+------------+-----+-----+---------------------------------+
| Policy | Role | Remote |HTTPS| AAF | Notes |
+========+======+============+=====+=====+=================================+
-| pdp-d |server| \* |true |true |Healthchek and Telemetry APIs |
+| pdp-d |server| \* |true |true |Healthcheck and Telemetry APIs |
+--------+------+------------+-----+-----+---------------------------------+
| pdp-d |client| aaf |true |true |Two-way TLS |
+--------+------+------------+-----+-----+---------------------------------+