summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BRMSGateway/config.properties4
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java3
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java34
-rw-r--r--LogParser/parserlog.properties8
-rw-r--r--LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java4
-rw-r--r--LogParser/src/test/resources/test_config.properties4
-rw-r--r--ONAP-PAP-REST/policyelk.properties4
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java4
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java5
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java5
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java2
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java431
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java22
-rw-r--r--ONAP-PAP-REST/xacml.pap.properties4
-rw-r--r--ONAP-PDP-REST/pom.xml4
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java8
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java103
-rw-r--r--ONAP-PDP-REST/src/test/resources/META-INF/drop.ddl7
-rw-r--r--ONAP-PDP-REST/src/test/resources/META-INF/persistence.xml201
-rw-r--r--ONAP-PDP-REST/src/test/resources/fail.xacml.pdp.properties4
-rw-r--r--ONAP-PDP-REST/src/test/resources/notification.xacml.pdp.properties4
-rw-r--r--ONAP-PDP-REST/src/test/resources/pass.xacml.pdp.properties4
-rw-r--r--ONAP-PDP-REST/src/test/resources/xacml.pdp.properties176
-rw-r--r--ONAP-PDP-REST/xacml.pdp.properties4
-rw-r--r--ONAP-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties4
-rw-r--r--ONAP-SDK-APP/xacml.admin.properties4
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java101
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java543
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java18
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java18
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java27
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java14
-rw-r--r--POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties4
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java42
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java12
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java94
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java232
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java12
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java50
-rw-r--r--POLICY-SDK-APP/src/test/resources/test.properties21
-rw-r--r--POLICY-SDK-APP/src/test/resources/xacml.admin.properties4
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java60
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java17
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java57
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java44
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java30
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java49
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java154
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java443
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java88
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java4
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java26
-rw-r--r--packages/install/src/files/base.conf6
-rw-r--r--pom.xml2
59 files changed, 2632 insertions, 634 deletions
diff --git a/BRMSGateway/config.properties b/BRMSGateway/config.properties
index 762f0ff1f..fa5f9199e 100644
--- a/BRMSGateway/config.properties
+++ b/BRMSGateway/config.properties
@@ -57,9 +57,9 @@ vDNS.artifactID= policy-vDNS-rules
#Integrity Monitor values
#database driver for Integrity Monitor
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
#database URL for Integrity Monitor
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
#database username for Integrity Monitor
javax.persistence.jdbc.user=policy_user
#database password for Integrity Monitor
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
index 43031861b..a11e8b4b7 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSHandler.java
@@ -95,7 +95,7 @@ public class BRMSHandler implements BackUpHandler{
}
}
}
- Boolean failureFlag = false;
+ Boolean failureFlag;
int i = 0;
do{
failureFlag = false;
@@ -118,6 +118,7 @@ public class BRMSHandler implements BackUpHandler{
* (non-Javadoc)
* @see org.onap.policy.utils.BackUpHandler#runOnNotification(org.onap.policy.api.PDPNotification)
*/
+ @Override
public void runOnNotification(PDPNotification notification){
if(notification.getNotificationType().equals(NotificationType.REMOVE)){
removedPolicies(notification.getRemovedPolicies());
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
index c923c3c34..6e8588acb 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
@@ -388,11 +388,11 @@ public class BRMSPush {
selectedName = responseAttributes.get(key);
}
// kmodule configurations
- else if (key.equals("kSessionName")) {
+ else if ("kSessionName".equals(key)) {
kSessionName = responseAttributes.get(key);
}
// Check User Specific values.
- if (key.equals("$controller:")) {
+ if ("$controller:".equals(key)) {
try {
PEDependency dependency = PolicyUtils.jsonStringToObject(responseAttributes.get(key),
PEDependency.class);
@@ -402,7 +402,7 @@ public class BRMSPush {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
}
- } else if (key.equals("$dependency$")) {
+ } else if ("$dependency$".equals(key)) {
String value = responseAttributes.get(key);
if (value.startsWith("[") && value.endsWith("]")) {
value = value.substring(1, value.length() - 1).trim();
@@ -500,7 +500,7 @@ public class BRMSPush {
List<?> pList = query.getResultList();
boolean createFlag = false;
BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
- if (pList.size() > 0) {
+ if (!pList.isEmpty()) {
// Already exists.
brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
if (!brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
@@ -514,7 +514,7 @@ public class BRMSPush {
query.setParameter("cn", controllerName);
List<?> bList = query.getResultList();
BRMSGroupInfo brmsGroupInfo = new BRMSGroupInfo();
- if (bList.size() > 0) {
+ if (!bList.isEmpty()) {
brmsGroupInfo = (BRMSGroupInfo) bList.get(0);
}
brmsPolicyInfo.setPolicyName(policyName);
@@ -528,7 +528,7 @@ public class BRMSPush {
private void syncProject(String selectedName) {
boolean projectExists = checkProject(selectedName);
if (projectExists) {
- String version = null;
+ String version;
version = getVersion(selectedName);
if (version == null) {
LOGGER.error("Error getting local version for the given Controller Name:" + selectedName
@@ -599,7 +599,6 @@ public class BRMSPush {
}
fos.close();
is.close();
- f = null;
LOGGER.info(fileName + " Created..");
}
}
@@ -641,7 +640,7 @@ public class BRMSPush {
private boolean checkRemoteSync(String selectedName, String version) {
List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
- return (artifacts.size() == 0) ? false : true;
+ return artifacts.isEmpty() ? false : true;
}
private List<NexusArtifact> getArtifactFromNexus(String selectedName, String version) {
@@ -690,7 +689,7 @@ public class BRMSPush {
if (artifact != null) {
newVersion = incrementVersion(artifact.getVersion());
}
- if (newVersion.equals("0.1.0")) {
+ if ("0.1.0".equals(newVersion)) {
createFlag = true;
}
setVersion(newVersion, selectedName);
@@ -736,8 +735,9 @@ public class BRMSPush {
}
if (!modifiedGroups.isEmpty()) {
Boolean flag = false;
- for (String group : modifiedGroups.keySet()) {
+ for (Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
InvocationResult result = null;
+ String group = entry.getKey();
try {
InvocationRequest request = new DefaultInvocationRequest();
setVersion(group);
@@ -761,7 +761,7 @@ public class BRMSPush {
if (createFlag) {
addNotification(group, "create");
} else {
- addNotification(group, modifiedGroups.get(group));
+ addNotification(group, entry.getValue());
}
flag = true;
} else {
@@ -795,7 +795,7 @@ public class BRMSPush {
return policyMap.get(name);
} else {
syncGroupInfo();
- return (policyMap.containsKey(name)) ? policyMap.get(name) : null;
+ return policyMap.containsKey(name) ? policyMap.get(name) : null;
}
}
@@ -869,7 +869,7 @@ public class BRMSPush {
pub.send("MyPartitionKey", message);
final List<?> stuck = pub.close(uebDelay, TimeUnit.SECONDS);
- if (stuck.size() > 0) {
+ if (!stuck.isEmpty()) {
LOGGER.error(stuck.size() + " messages unsent");
} else {
LOGGER.debug("Clean exit; Message Published on UEB : " + uebList + "for Topic: " + pubTopic);
@@ -1018,7 +1018,7 @@ public class BRMSPush {
}
private void readGroups(Properties config) throws PolicyException {
- String[] groupNames = null;
+ String[] groupNames;
if (!config.containsKey("groupNames") || config.getProperty("groupNames")==null){
throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "groupNames property is missing or empty from the property file ");
@@ -1069,7 +1069,7 @@ public class BRMSPush {
query.setParameter("cn", name);
List<?> groupList = query.getResultList();
BRMSGroupInfo brmsGroupInfo = null;
- if (groupList.size() > 0) {
+ if (!groupList.isEmpty()) {
LOGGER.info("Controller name already Existing in DB. Will be updating the DB Values" + name);
brmsGroupInfo = (BRMSGroupInfo) groupList.get(0);
}
@@ -1122,8 +1122,8 @@ public class BRMSPush {
Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
query.setParameter("pn", policyName);
List<?> pList = query.getResultList();
- BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
- if (pList.size() > 0) {
+ BRMSPolicyInfo brmsPolicyInfo;
+ if (!pList.isEmpty()) {
// Already exists.
brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
if (brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
diff --git a/LogParser/parserlog.properties b/LogParser/parserlog.properties
index 4a5ecdb9c..66ce34d19 100644
--- a/LogParser/parserlog.properties
+++ b/LogParser/parserlog.properties
@@ -20,14 +20,14 @@
#Health Check Values
RESOURCE_NAME=logparser_pap01
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/onap_sdk
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
#Log Parser application values
-JDBC_DRIVER=com.mysql.jdbc.Driver
-JDBC_URL=jdbc:mysql://localhost:3306/log
+JDBC_DRIVER=org.mariadb.jdbc.Driver
+JDBC_URL=jdbc:mariadb://localhost:3306/log
JDBC_USER=policy_user
JDBC_PASSWORD=policy_user
SERVER=https://localhost:9091/pap/
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 c12797f28..1f42ac39b 100644
--- a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
+++ b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
@@ -122,8 +122,8 @@ public class ParseLogTest {
config = new Properties();
config.put("RESOURCE_NAME", "logparser_pap01");
- config.put("JDBC_DRIVER" ,"com.mysql.jdbc.Driver");
- config.put("JDBC_URL", "jdbc:mysql://localhost:3306/");
+ config.put("JDBC_DRIVER" ,"org.mariadb.jdbc.Driver");
+ config.put("JDBC_URL", "jdbc:mariadb://localhost:3306/");
config.put("JDBC_USER", "root");
config.put("JDBC_PASSWORD", "password");
config.put("JMX_URL", "service:jmx:rmi:///jndi/rmi://localhost:9998/jmxrmi");
diff --git a/LogParser/src/test/resources/test_config.properties b/LogParser/src/test/resources/test_config.properties
index 6512184c8..ca2b9edc9 100644
--- a/LogParser/src/test/resources/test_config.properties
+++ b/LogParser/src/test/resources/test_config.properties
@@ -20,8 +20,8 @@
RESOURCE_NAME=logparser_pap01
-JDBC_DRIVER=com.mysql.jdbc.Driver
-JDBC_URL=jdbc:mysql://localhost:3306/
+JDBC_DRIVER=org.mariadb.jdbc.Driver
+JDBC_URL=jdbc:mariadb://localhost:3306/
JDBC_USER=root
JDBC_PASSWORD=password
jmx_url=service:jmx:rmi:///jndi/rmi://localhost:9996/jmxrmi
diff --git a/ONAP-PAP-REST/policyelk.properties b/ONAP-PAP-REST/policyelk.properties
index 386008ce5..d07fab90a 100644
--- a/ONAP-PAP-REST/policyelk.properties
+++ b/ONAP-PAP-REST/policyelk.properties
@@ -24,7 +24,7 @@ policy.elk.url=http://localhost:9200
#Policy Database properties
-policy.database.driver=com.mysql.jdbc.Driver
-policy.database.url=jdbc:mysql://localhost:3306/onap_sdk?autoReconnect=true&useSSL=false
+policy.database.driver=org.mariadb.jdbc.Driver
+policy.database.url=jdbc:mariadb://localhost:3306/onap_sdk?autoReconnect=true&useSSL=false
policy.database.username=policy_user
policy.database.password=policy_user \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
index eae3e79a9..d870ca86c 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
@@ -63,6 +63,7 @@ import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
+import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.std.IdentifierImpl;
@@ -423,7 +424,6 @@ public class DecisionPolicy extends Policy {
// Values for AAF Provider are here for XML Creation.
ConditionType condition = new ConditionType();
ApplyType decisionApply = new ApplyType();
- String selectedFunction = "boolean-equal";
AttributeValueType value1 = new AttributeValueType();
value1.setDataType(BOOLEAN_DATATYPE);
@@ -439,7 +439,7 @@ public class DecisionPolicy extends Policy {
innerDecisionApply.setFunctionId(FUNCTION_BOOLEAN_ONE_AND_ONLY);
innerDecisionApply.getExpression().add(new ObjectFactory().createAttributeDesignator(value2));
- decisionApply.setFunctionId(dropDownMap.get(selectedFunction));
+ decisionApply.setFunctionId(XACML3.ID_FUNCTION_BOOLEAN_EQUAL.stringValue());
decisionApply.getExpression().add(new ObjectFactory().createAttributeValue(value1));
decisionApply.getExpression().add(new ObjectFactory().createApply(innerDecisionApply));
condition.setExpression(new ObjectFactory().createApply(decisionApply));
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
index d142a46f3..675c82549 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
@@ -35,6 +35,7 @@ import org.json.JSONObject;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.adapters.GridData;
+import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.pap.xacml.rest.util.JsonMessage;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ClosedLoopD2Services;
@@ -1042,6 +1043,10 @@ public class ClosedLoopDictionaryController{
}
return null;
}
+
+ public static void setCommonClassDao(CommonClassDaoImpl commonClassDaoImpl) {
+ commonClassDao = commonClassDaoImpl;
+ }
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
index 86706d154..3a4d7b71b 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
@@ -103,6 +103,11 @@ public class FirewallDictionaryController {
public FirewallDictionaryController(CommonClassDao commonClassDao){
FirewallDictionaryController.commonClassDao = commonClassDao;
}
+
+ public static void setCommonClassDao(CommonClassDao clDao){
+ commonClassDao = clDao;
+ }
+
/*
* This is an empty constructor
*/
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java
index f913c181f..13255ba50 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/ia/DbAuditCompareEntriesTest.java
@@ -233,7 +233,7 @@ public class DbAuditCompareEntriesTest {
entry1.setFlag("flag1");
- entry1.setResoruceNodeName("node1");
+ entry1.setResourceNodeName("node1");
entry1.setResourceName("resourceName");
entry1.setTimeStamp(new Date());
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
index f110c5b6a..0463585cb 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
@@ -23,11 +23,15 @@ package org.onap.policy.pap.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletConfig;
@@ -43,8 +47,14 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
+import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.FirewallDictionaryController;
import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.BRMSParamTemplate;
+import org.onap.policy.rest.jpa.PolicyEditorScopes;
+import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
import org.onap.policy.xacml.std.pap.StdPAPPolicy;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -84,7 +94,7 @@ public class XACMLPAPTest {
@Test
public void testFirwallCreatePolicy() throws IOException, ServletException, SQLException {
httpServletRequest = Mockito.mock(HttpServletRequest.class);
- String json = "";
+ String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"TestFwPolicyConfig\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"cloudsite:dev1a\",\"serviceGroups\":[{\"name\":\"SSH\",\"description\":\"Sshservice entry in servicelist\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"22\"}],\"addressGroups\":[{\"name\":\"test\",\"description\":\"Destination\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/12\"}]},{\"name\":\"TestServers\",\"description\":\"SourceTestServers for firsttesting\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/23\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"FWRuleTestServerToTest\",\"fromZones\":[\"UntrustedZoneTestName\"],\"toZones\":[\"TrustedZoneTestName\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"name\":\"TestServers\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"name\":\"Test\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"SSH\"}],\"action\":\"accept\",\"description\":\"FWrule for Test source to Test destination\",\"enabled\":true,\"log\":true}]}";
Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
@@ -102,10 +112,429 @@ public class XACMLPAPTest {
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
Mockito.verify(httpServletResponse).addHeader("policyName", "test.Config_FW_test.1.xml");
+ }
+
+ @Test
+ public void testBRMSCreatePolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
+ Map<String, String> matchingAttributes = new HashMap<>();
+ Map<String, String> ruleAttributes = new HashMap<>();
+ ruleAttributes.put("templateName", "testPolicy");
+ ruleAttributes.put("samPoll", "5");
+ ruleAttributes.put("value", "test");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Param","test", "testing",
+ "BRMS_PARAM_RULE",false,"test",
+ matchingAttributes, 0, "DROOLS",
+ null, ruleAttributes, "5",
+ "default", "false", "", null, null);
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ setPolicyCreation();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Config_BRMS_Param_test.1.xml");
+ }
+
+ @Test
+ public void testBRMSRawCreatePolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
+ Map<String, String> ruleAttributes = new HashMap<>();
+ ruleAttributes.put("value", "test");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw","test","testig description",
+ "BRMS_RAW_RULE",false,"test", ruleAttributes, 0, "DROOLS",
+ "test", "4",
+ "default", "false", null, null, null);
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ setPolicyCreation();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Config_BRMS_Raw_test.1.xml");
+ }
+
+ @Test
+ public void testClosedLoopPMCreatePolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
+ String json = "{\"test\":\"java\"}";
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_PM", "test", "testing", "onap",
+ json, false, null, "Registration Failure(Trinity)", false, "test", 0, null,
+ "default", "true", "");
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ setPolicyCreation();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Config_PM_test.1.xml");
+ }
+
+ @Test
+ public void testDecisonAAFPolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Decision");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("test", "test rule", "ONAP", "AAF", null, null, null,
+ null, null, null, null, null, null, false, "test", 0);
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Decision_test.1.xml");
+ }
+
+ @Test
+ public void testDecisonGuardPolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Decision");
+ Map<String, String> matchingAttributes = new HashMap<>();
+ matchingAttributes.put("actor","test");
+ matchingAttributes.put("recipe","restart");
+ matchingAttributes.put("targets","test,test1");
+ matchingAttributes.put("clname","");
+ matchingAttributes.put("limit","1");
+ matchingAttributes.put("timeWindow","15");
+ matchingAttributes.put("timeUnits","minute");
+ matchingAttributes.put("guardActiveStart","05:00");
+ matchingAttributes.put("guardActiveEnd","10:00");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("testGuard", "test rule", "PDPD", "GUARD_YAML", matchingAttributes , null, null,
+ null, null, null, null, null, null, false, "test", 0);
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Decision_testGuard.1.xml");
+ }
+
+ @Test
+ public void testDecisonBLGuardPolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Decision");
+ Map<String, String> matchingAttributes = new HashMap<>();
+ matchingAttributes.put("actor","test");
+ matchingAttributes.put("recipe","restart");
+ matchingAttributes.put("clname","test");
+ matchingAttributes.put("guardActiveStart","05:00");
+ matchingAttributes.put("guardActiveEnd","10:00");
+ matchingAttributes.put("blackList","bl1,bl2");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("testblGuard", "test rule", "PDPD", "GUARD_BL_YAML", matchingAttributes , null, null,
+ null, null, null, null, null, null, false, "test", 0);
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ pap.service(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Decision_testblGuard.1.xml");
}
+ @Test
+ public void testConfigPolicy() throws IOException, ServletException, SQLException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
+ Map<String, String> configAttributes = new HashMap<>();
+ configAttributes.put("value", "test");
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Base", "test", "test rule", "TEST", "config", configAttributes, "OTHER",
+ "test body", false, "test",0, "5","default", "false", null);
+ MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+
+ // set DBDao
+ setDBDao();
+ pap.service(httpServletRequest, httpServletResponse);
+
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ Mockito.verify(httpServletResponse).addHeader("successMapKey", "success");
+ Mockito.verify(httpServletResponse).addHeader("policyName", "test.Config_test.1.xml");
+ }
+
+ private void setPolicyCreation() {
+ CommonClassDao commonClassDao = Mockito.mock(CommonClassDao.class);
+ PolicyCreation.setCommonClassDao(commonClassDao);
+ PolicyEditorScopes editorScope = new PolicyEditorScopes();
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserName("API");
+ userInfo.setUserLoginId("API");
+ editorScope.setScopeName("test");
+ editorScope.setUserCreatedBy(userInfo);
+ editorScope.setUserModifiedBy(userInfo);
+ Mockito.when(commonClassDao.getEntityItem(PolicyEditorScopes.class, "scopeName", "test")).thenReturn(editorScope);
+ BRMSParamTemplate template = new BRMSParamTemplate();
+ template.setRuleName("testPolicy");
+ template.setUserCreatedBy(userInfo);
+ String rule = "package com.sample;\n"
+ + "import com.sample.DroolsTest.Message;\n"
+ + "declare Params\n"
+ + "samPoll : int\n"
+ + "value : String\n"
+ + "end\n"
+ + "///This Rule will be generated by the UI.\n"
+ + "rule \"${policyName}.Create parameters structure\"\n"
+ + "salience 1000 \n"
+ + "when\n"
+ + "then\n"
+ + "Params params = new Params();\n"
+ + "params.setSamPoll(76);\n"
+ + "params.setValue(\"test\");\n"
+ + "insertLogical(params);\n"
+ + "end\n"
+ + "rule \"Rule 1: Check parameter structure access from when/then\"\n"
+ + "when\n"
+ + "$param: Params()\n"
+ + "Params($param.samPoll > 50)\n"
+ + "then\n"
+ + "System.out.println(\"Firing rule 1\");\n"
+ + "System.out.println($param);\n"
+ + "end\n";
+ template.setRule(rule );
+ Mockito.when(commonClassDao.getEntityItem(BRMSParamTemplate.class, "ruleName", "testPolicy")).thenReturn(template);
+
+ }
+ @Test
+ public void testClosedLoopCreateDictionary() throws IOException, SQLException, ServletException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ // Check VSCLAction.
+ String json = "{\"dictionaryFields\": {\"vsclaction\": \"testRestAPI\",\"description\": \"testing create\"}}";
+ dictionaryTestSetup(false, "VSCLAction", json);
+ // set DBDao
+ ClosedLoopDictionaryController.setCommonClassDao(new CommonClassDaoImpl());
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check VNFType
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\": {\"vnftype\": \"testrestAPI1\",\"description\": \"testing create\"}}";
+ dictionaryTestSetup(false, "VNFType", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check PEPOptions
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"pepName\":\"testRestAPI\",\"description\":\"testing create\",\"attributes\":[{\"option\":\"test1\",\"number\":\"test\"},{\"option\":\"test2\",\"number\":\"test\"}]}}";
+ dictionaryTestSetup(false, "PEPOptions", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check Varbind
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"varbindName\":\"testRestAPI\",\"varbindDescription\":\"testing\",\"varbindOID\":\"test\"}}";
+ dictionaryTestSetup(false, "Varbind", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check Service
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"serviceName\":\"testRestAPI\",\"description\":\"testing\"}}";
+ dictionaryTestSetup(false, "Service", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check Site
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"siteName\":\"testRestAPI\",\"description\":\"testing\"}}";
+ dictionaryTestSetup(false, "Site", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ }
+
+ @Test
+ public void testFirewallCreateDictionary() throws IOException, SQLException, ServletException {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ // Check SecurityZone.
+ String json = "{\"dictionaryFields\":{\"zoneName\":\"testRestAPI\",\"zoneValue\":\"testing\"}}";
+ dictionaryTestSetup(false, "SecurityZone", json);
+ // set DBDao
+ FirewallDictionaryController.setCommonClassDao(new CommonClassDaoImpl());
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check Action List
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"actionName\":\"testRestAPI\",\"description\":\"test\"}}";
+ dictionaryTestSetup(false, "ActionList", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check Protocol List.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"protocolName\":\"testRestAPI\",\"description\":\"test\"}}";
+ dictionaryTestSetup(false, "ProtocolList", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check Zone.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"zoneName\":\"testRestAPI\",\"zoneValue\":\"test\"}}";
+ dictionaryTestSetup(false, "Zone", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check PrefixList.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"prefixListName\":\"testRestAPI\",\"prefixListValue\":\"127.0.0.1\",\"description\":\"testing\"}}";
+ dictionaryTestSetup(false, "PrefixList", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check AddressGroup.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"groupName\":\"testRestAPIgroup\",\"description\":\"testing\",\"attributes\":[{\"option\":\"testRestAPI\"}, {\"option\":\"testRestAPI\"}]}}";
+ dictionaryTestSetup(false, "AddressGroup", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check ServiceGroup.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"groupName\":\"testRestAPIServiceGroup\",\"attributes\":[{\"option\":\"testRestAPIservice\"}]}}";
+ dictionaryTestSetup(false, "ServiceGroup", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check ServiceList.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"serviceName\":\"testRestAPIservice\",\"serviceDescription\":\"test\",\"servicePorts\":\"8888\",\"transportProtocols\":[{\"option\":\"testRestAPI\"},{\"option\":\"testRestAPI1\"}],\"appProtocols\":[{\"option\":\"testRestAPI\"},{\"option\":\"testRestAPI1\"}]}}";
+ dictionaryTestSetup(false, "ServiceList", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ //
+ // Check TermList.
+ //
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"termName\":\"testRestAPIRule\",\"termDescription\":\"testing\",\"fromZoneDatas\":[{\"option\":\"testRestAPI\"}],\"toZoneDatas\":[{\"option\":\"testRestAPI1\"}],\"sourceListDatas\":[{\"option\":\"Group_testportal\"}],\"destinationListDatas\":[{\"option\":\"testRestAPI\"}],\"sourceServiceDatas\":[{\"option\":\"testRestAPIservice\"},{\"option\":\"testRestAPIservice1\"}],\"destinationServiceDatas\":[{\"option\":\"testRestAPIservice1\"},{\"option\":\"testportalservice2\"}],\"actionListDatas\":[{\"option\":\"testRestAPI\"}]}}";
+ dictionaryTestSetup(false, "TermList", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ }
+
+ private void dictionaryTestSetup(Boolean updateFlag, String dictionaryType, String json) throws IOException, SQLException {
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getHeader("ClientScope")).thenReturn("dictionaryItem");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ if(updateFlag){
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("update");
+ }else{
+ Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
+ }
+ Mockito.when(httpServletRequest.getParameter("dictionaryType")).thenReturn(dictionaryType);
+ MockServletInputStream mockInput = new MockServletInputStream(json.getBytes());
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+ Mockito.when(httpServletRequest.getReader()).thenReturn(new BufferedReader(new InputStreamReader(mockInput)));
+ // set DBDao
+ setDBDao();
+ }
private void setDBDao() throws SQLException {
BasicDataSource dataSource = new BasicDataSource();
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java
index 1a97d7fad..99285e77f 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicyTest.java
@@ -20,9 +20,10 @@
package org.onap.policy.pap.xacml.rest.components;
import static org.junit.Assert.*;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -124,5 +125,24 @@ public class FirewallConfigPolicyTest {
assertTrue(response);
}
+
+ @Test
+ public void testUpdateJson() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+ FirewallConfigPolicy firewallConfigPolicy = new FirewallConfigPolicy();
+ Method method = firewallConfigPolicy.getClass().getDeclaredMethod("updateFirewallDictionaryData", String.class , String.class);
+ method.setAccessible(true);
+ String jsonBody= "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"TestFwPolicyConfig\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"cloudsite:dev1a\",\"serviceGroups\":[{\"name\":\"SSH\",\"description\":\"Sshservice entry in servicelist\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"22\"}],\"addressGroups\":[{\"name\":\"test\",\"description\":\"Destination\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/12\"}]},{\"name\":\"TestServers\",\"description\":\"SourceTestServers for firsttesting\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/23\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"FWRuleTestServerToTest\",\"fromZones\":[\"UntrustedZoneTestName\"],\"toZones\":[\"TrustedZoneTestName\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"name\":\"TestServers\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"name\":\"Test\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"SSH\"}],\"action\":\"accept\",\"description\":\"FWrule for Test source to Test destination\",\"enabled\":true,\"log\":true}]}";
+ String prevJsonBody = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"TestFwPolicy1Config\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"cloudsite:dev\",\"vendorServiceId\":\"test\",\"vendorSpecificData\":{\"idMap\":[{\"Id\":\"cloudsite:dev1a\",\"vendorId\":\"deviceGroup:dev\"}]},\"serviceGroups\":[{\"name\":\"SSH\",\"description\":\"Ssh service entry in service list\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"22\"}],\"addressGroups\":[{\"name\":\"Test\",\"description\":\"Destination Test\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/12\"}]},{\"name\":\"TestServers\",\"description\":\"Source TestServers for first testing\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/23\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"FWRuleTestServerTot\",\"fromZones\":[\"UntrustedZoneTestName\"],\"toZones\":[\"TrustedZoneTName\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"name\":\"TServers\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"name\":\"Test\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"SSH\"}],\"action\":\"accept\",\"description\":\"FW rule for HOHO source to CiscoVCE destination\",\"enabled\":true,\"log\":true}]}";
+ assertFalse((Boolean) method.invoke(firewallConfigPolicy, jsonBody, prevJsonBody));
+ }
+
+ @Test
+ public void testInsertJson() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+ FirewallConfigPolicy firewallConfigPolicy = new FirewallConfigPolicy();
+ Method method = firewallConfigPolicy.getClass().getDeclaredMethod("insertFirewallDicionaryData", String.class);
+ method.setAccessible(true);
+ String jsonBody= "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"TestFwPolicyConfig\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"cloudsite:dev1a\",\"serviceGroups\":[{\"name\":\"SSH\",\"description\":\"Sshservice entry in servicelist\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"22\"}],\"addressGroups\":[{\"name\":\"test\",\"description\":\"Destination\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/12\"}]},{\"name\":\"TestServers\",\"description\":\"SourceTestServers for firsttesting\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"127.0.0.1/23\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"FWRuleTestServerToTest\",\"fromZones\":[\"UntrustedZoneTestName\"],\"toZones\":[\"TrustedZoneTestName\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"name\":\"TestServers\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"name\":\"Test\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"SSH\"}],\"action\":\"accept\",\"description\":\"FWrule for Test source to Test destination\",\"enabled\":true,\"log\":true}]}";
+ assertFalse((Boolean) method.invoke(firewallConfigPolicy, jsonBody));
+ }
} \ No newline at end of file
diff --git a/ONAP-PAP-REST/xacml.pap.properties b/ONAP-PAP-REST/xacml.pap.properties
index 2517ebdcc..dc8300d92 100644
--- a/ONAP-PAP-REST/xacml.pap.properties
+++ b/ONAP-PAP-REST/xacml.pap.properties
@@ -88,8 +88,8 @@ xacml.rest.pdp.idfile=test.properties
#Properties for db access
#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/onap_sdk?failOverReadOnly=false&autoReconnect=true
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk?failOverReadOnly=false&autoReconnect=true
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/ONAP-PDP-REST/pom.xml b/ONAP-PDP-REST/pom.xml
index a2f7f7207..fb957f00d 100644
--- a/ONAP-PDP-REST/pom.xml
+++ b/ONAP-PDP-REST/pom.xml
@@ -212,6 +212,10 @@
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>com.att.aft</groupId>
+ <artifactId>dme2</artifactId>
+ </exclusion>
</exclusions>
</dependency>
</dependencies>
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
index 18c201737..b824312dc 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
@@ -180,6 +180,14 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
private static volatile boolean configThreadTerminate = false;
private transient ONAPLoggingContext baseLoggingContext = null;
private transient IntegrityMonitor im;
+ public IntegrityMonitor getIm() {
+ return im;
+ }
+
+ public void setIm(IntegrityMonitor im) {
+ this.im = im;
+ }
+
/**
* Default constructor.
*/
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 3e3f584a9..594b51c06 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
@@ -27,6 +27,10 @@ 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;
@@ -34,16 +38,18 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.policy.common.ia.DbDAO;
+import org.onap.policy.common.ia.IntegrityAuditProperties;
import org.onap.policy.common.im.AdministrativeStateException;
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
+
+import org.onap.policy.pdp.rest.XACMLPdpServletTest;
import org.powermock.api.mockito.PowerMockito;
-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;
@@ -51,8 +57,6 @@ import com.mockrunner.mock.web.MockServletInputStream;
import junit.framework.TestCase;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(IntegrityMonitor.class) // so PowerMock can mock static method of IntegrityMonitor
public class XACMLPdpServletTest extends TestCase{
private static Logger LOGGER = FlexLogger.getLogger(XACMLPdpServletTest.class);
@@ -65,16 +69,64 @@ public class XACMLPdpServletTest extends TestCase{
private ServletConfig servletConfig;
private XACMLPdpServlet pdpServlet;
private IntegrityMonitor im;
-
+
+ private DbDAO dbDAO;
+ private String persistenceUnit;
+ private Properties properties;
+ private String resourceName;
+ private String dbDriver;
+ private String dbUrl;
+ private String dbUser;
+ private String dbPwd;
+ private String siteName;
+ private String nodeType;
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
@Before
public void setUp(){
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, XACMLPdpServletTest.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/xacmlTest");
+ properties.put(IntegrityAuditProperties.DB_USER, XACMLPdpServletTest.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, XACMLPdpServletTest.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pap");
+ //properties.put("com.sun.management.jmxremote.port", "9999");
+ dbDriver = XACMLPdpServletTest.DEFAULT_DB_DRIVER;
+ dbUrl = "jdbc:h2:file:./sql/xacmlTest";
+ dbUser = XACMLPdpServletTest.DEFAULT_DB_USER;
+ dbPwd = XACMLPdpServletTest.DEFAULT_DB_PWD;
+ siteName = "SiteA";
+ nodeType = "pdp";
+ 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();
+ }
+ //cleanDb(persistenceUnit, properties);
+
httpServletRequest = Mockito.mock(HttpServletRequest.class);
Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
-
+ Mockito.when(httpServletRequest.getRequestURI()).thenReturn("/pdp/test");
mockOutput = Mockito.mock(ServletOutputStream.class);
@@ -90,15 +142,17 @@ public class XACMLPdpServletTest extends TestCase{
//servletConfig
Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
pdpServlet = new XACMLPdpServlet();
+ pdpServlet.setIm(im);
- Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties");
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("src/test/resources/xacml.pdp.properties");
- System.setProperty("xacml.properties", "xacml.pdp.properties");
- System.setProperty("xacml.rest.pdp.config", "config_testing");
- System.setProperty("xacml.rest.pdp.webapps", "/webapps");
- System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml");
+ 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");
@@ -119,8 +173,9 @@ public class XACMLPdpServletTest extends TestCase{
}
Mockito.doNothing().when(im).endTransaction();
}
-
- public void testInit(){
+
+ @Test
+ public void testInit(){
LOGGER.info("XACMLPdpServletTest - testInit");
try {
pdpServlet.init(servletConfig);
@@ -133,12 +188,14 @@ public class XACMLPdpServletTest extends TestCase{
}
+ @Test
public void testDoGetNoTypeError(){
LOGGER.info("XACMLPdpServletTest - testDoGetNoTypeError");
try{
+
pdpServlet.init(servletConfig);
pdpServlet.doGet(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST, "type not 'config' or 'hb'");
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
assertTrue(true);
}catch(Exception e){
System.out.println("Unexpected exception in testDoGetNoTypeError");
@@ -147,6 +204,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoGetConfigType(){
LOGGER.info("XACMLPdpServletTest - testDoGetConfigType");
Mockito.when(httpServletRequest.getParameter("type")).thenReturn("config");
@@ -164,14 +222,14 @@ public class XACMLPdpServletTest extends TestCase{
}
-
+ @Test
public void testDoGetTypeHb(){
LOGGER.info("XACMLPdpServletTest - testDoGetTypeHb");
try{
Mockito.when(httpServletRequest.getParameter("type")).thenReturn("hb");
pdpServlet.init(servletConfig);
pdpServlet.doGet(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_NO_CONTENT);
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
assertTrue(true);
}catch(Exception e){
System.out.println("Unexpected exception in testDoGetTypeHb");
@@ -179,6 +237,8 @@ public class XACMLPdpServletTest extends TestCase{
fail();
}
}
+
+ @Test
public void testDoGetTypeStatus(){
LOGGER.info("XACMLPdpServletTest - testDoGetTypeStatus");
try{
@@ -194,6 +254,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPost(){
LOGGER.info("XACMLPdpServletTest - testDoPost");
try{
@@ -207,6 +268,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPostToLong(){
LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
try{
@@ -223,6 +285,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPostContentLengthNegative(){
LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
try{
@@ -239,6 +302,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPostContentTypeNonValid(){
LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
try{
@@ -255,6 +319,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPostContentTypeConfigurationError(){
LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
try{
@@ -271,6 +336,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPutCacheEmpty(){
LOGGER.info("XACMLPdpServletTest - testDoPutCacheEmpty");
mockInput = Mockito.mock(ServletInputStream.class);
@@ -290,6 +356,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPutConfigPolicies(){
LOGGER.info("XACMLPdpServletTest - testDoPutConfigPolicies");
byte[] b = new byte[20];
@@ -330,6 +397,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDoPutInvalidContentType(){
LOGGER.info("XACMLPdpServletTest - testDoPutToLong");
try{
@@ -349,6 +417,7 @@ public class XACMLPdpServletTest extends TestCase{
}
}
+ @Test
public void testDestroy(){
LOGGER.info("XACMLPdpServletTest - testDestroy");
diff --git a/ONAP-PDP-REST/src/test/resources/META-INF/drop.ddl b/ONAP-PDP-REST/src/test/resources/META-INF/drop.ddl
new file mode 100644
index 000000000..f7138ad52
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/resources/META-INF/drop.ddl
@@ -0,0 +1,7 @@
+DROP TABLE IF EXISTS ConfigurationDataEntity
+DROP TABLE IF EXISTS PolicyEntity
+DROP TABLE IF EXISTS PolicyDBDaoEntity
+DROP TABLE IF EXISTS ActionBodyEntity
+DROP SEQUENCE IF EXISTS seqPolicy
+DROP SEQUENCE IF EXISTS seqConfig
+DROP SEQUENCE IF EXISTS seqActBody
diff --git a/ONAP-PDP-REST/src/test/resources/META-INF/persistence.xml b/ONAP-PDP-REST/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..b44841c9d
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP-PAP-REST
+ ================================================================================
+ Copyright (C) 2017 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.
+ 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.
+ ============LICENSE_END=========================================================
+ -->
+<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+ <persistence-unit name="XACML-PAP-REST">
+ <class>org.onap.policy.rest.jpa.PolicyEntity</class>
+ <class>org.onap.policy.rest.jpa.ConfigurationDataEntity</class>
+ <class>org.onap.policy.rest.jpa.PolicyDBDaoEntity</class>
+ <class>org.onap.policy.rest.jpa.GroupEntity</class>
+ <class>org.onap.policy.rest.jpa.PdpEntity</class>
+ <class>org.onap.policy.rest.jpa.ActionBodyEntity</class>
+ <class>org.onap.policy.rest.jpa.DatabaseLockEntity</class>
+ <class>org.onap.policy.rest.jpa.PolicyVersion</class>
+ <class>org.onap.policy.rest.jpa.PolicyScore</class>
+ <class>org.onap.policy.rest.jpa.FunctionDefinition</class>
+ <class>org.onap.policy.rest.jpa.Attribute</class>
+ <class>org.onap.policy.rest.jpa.Category</class>
+ <class>org.onap.policy.rest.jpa.ConstraintType</class>
+ <class>org.onap.policy.rest.jpa.ConstraintValue</class>
+ <class>org.onap.policy.rest.jpa.Datatype</class>
+ <class>org.onap.policy.rest.jpa.FunctionArgument</class>
+ <class>org.onap.policy.rest.jpa.UserInfo</class>
+ <class>org.onap.policy.rest.jpa.ActionPolicyDict</class>
+ <class>org.onap.policy.rest.jpa.DecisionSettings</class>
+ <class>org.onap.policy.rest.jpa.MicroServiceModels</class>
+ <class>org.onap.policy.rest.jpa.BRMSParamTemplate</class>
+ <class>org.onap.policy.rest.jpa.PolicyEditorScopes</class>
+ <!-- unique to PolicyEngineUtils - will be audited from PAP -->
+ <class>org.onap.policy.jpa.BackUpMonitorEntity</class>
+ <!-- unique to integrity-monitor - will be audited from PAP -->
+ <class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
+ <class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
+ <class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
+ <!-- unique to integrity-audit - will be audited from PAP -->
+ <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+ <exclude-unlisted-classes>false</exclude-unlisted-classes>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ <properties>
+ <!-- The properties defined below are the default settings to be used when someone initially
+ wants to start working with the XACML-PAP-ADMIN web gui. They are not intended for production
+ use.
+
+ They are setup to drop and create the tables and then load an initial set of data into the database
+ every time the application is deployed. So if you add anything to the dictionaries or PIP
+ configuration, they will get lost upon each deployment. It uses an H2 database engine configured
+ for a local file so you don't have to setup you're own SQL database environment to start.
+
+ Instead of modifying this file directly, please refer to the xacml.admin.properties file for
+ customizing the application settings.
+
+ -->
+ <!-- <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.create-source" value="metadata-then-script"/>
+ <property name="javax.persistence.schema-generation.create-script-source" value="META-INF/views.sql" />
+ <property name="javax.persistence.schema-generation.drop-source" value="script"/>
+ <property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.sql" />
+ <property name="javax.persistence.sql-load-script-source" value="META-INF/data.sql" />-->
+
+
+
+ <!-- These properties should be set in the xacml.admin.properties file, so they can be re-used by non-JPA
+ database functionality. -->
+ <!--
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:sql/xacml"/>
+ <property name="javax.persistence.jdbc.user" value="sa"/>
+ <property name="javax.persistence.jdbc.password" value=""/>
+ -->
+ </properties>
+ </persistence-unit>
+
+<persistence-unit name="auditPapPU">
+ <!-- This is the persistence unit used by IntegrityAudit to determine
+ which classes to audit. All the PAP classes are also included in
+ XACML-PAP-ADMIN, so they will be audited there rather than having a
+ duplicate audit run from the XACL-PAP-REST node -->
+ <!-- unique to PolicyEngineUtils - will be audited from PAP -->
+ <class>org.onap.policy.jpa.BackUpMonitorEntity</class>
+ <!-- unique to integrity-monitor - will be audited from PAP -->
+ <class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
+ <class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
+ <class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
+ <!-- unique to integrity-audit - will be audited from PAP -->
+ <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+ <persistence-unit name="testPdpPU" transaction-type="RESOURCE_LOCAL">
+ <!-- This tests all the classes that will be audited in the XACML-PAP-REST and the XACML-PAP_ADMIN -->
+ <!-- XACML-PAP-REST -->
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <class>org.onap.policy.rest.jpa.PolicyEntity</class>
+ <class>org.onap.policy.rest.jpa.ConfigurationDataEntity</class>
+ <class>org.onap.policy.rest.jpa.PolicyDBDaoEntity</class>
+ <class>org.onap.policy.rest.jpa.GroupEntity</class>
+ <class>org.onap.policy.rest.jpa.PdpEntity</class>
+ <class>org.onap.policy.rest.jpa.ActionBodyEntity</class>
+ <class>org.onap.policy.rest.jpa.DatabaseLockEntity</class>
+ <class>org.onap.policy.rest.jpa.PolicyVersion</class>
+ <class>org.onap.policy.rest.jpa.PolicyScore</class>
+ <class>org.onap.policy.rest.jpa.FunctionDefinition</class>
+ <class>org.onap.policy.rest.jpa.Attribute</class>
+ <class>org.onap.policy.rest.jpa.Category</class>
+ <class>org.onap.policy.rest.jpa.ConstraintType</class>
+ <class>org.onap.policy.rest.jpa.ConstraintValue</class>
+ <class>org.onap.policy.rest.jpa.Datatype</class>
+ <class>org.onap.policy.rest.jpa.FunctionArgument</class>
+ <class>org.onap.policy.rest.jpa.UserInfo</class>
+ <class>org.onap.policy.rest.jpa.ActionPolicyDict</class>
+ <class>org.onap.policy.rest.jpa.DecisionSettings</class>
+ <class>org.onap.policy.rest.jpa.MicroServiceModels</class>
+ <!-- unique to XACML-PAP-ADMIN -->
+ <class>org.onap.policy.rest.jpa.ActionList</class>
+ <class>org.onap.policy.rest.jpa.AddressGroup</class>
+ <class>org.onap.policy.rest.jpa.AttributeAssignment</class>
+ <class>org.onap.policy.rest.jpa.BRMSParamTemplate</class>
+ <class>org.onap.policy.rest.jpa.ClosedLoopD2Services</class>
+ <class>org.onap.policy.rest.jpa.ClosedLoopSite</class>
+ <class>org.onap.policy.rest.jpa.DCAEUsers</class>
+ <class>org.onap.policy.rest.jpa.DCAEuuid</class>
+ <class>org.onap.policy.rest.jpa.DescriptiveScope</class>
+ <class>org.onap.policy.rest.jpa.OnapName</class>
+ <class>org.onap.policy.rest.jpa.EnforcingType</class>
+ <class>org.onap.policy.rest.jpa.GlobalRoleSettings</class>
+ <class>org.onap.policy.rest.jpa.GroupPolicyScopeList</class>
+ <class>org.onap.policy.rest.jpa.GroupServiceList</class>
+ <class>org.onap.policy.rest.jpa.MicroServiceConfigName</class>
+ <class>org.onap.policy.rest.jpa.MicroServiceLocation</class>
+ <class>org.onap.policy.rest.jpa.Obadvice</class>
+ <class>org.onap.policy.rest.jpa.ObadviceExpression</class>
+ <class>org.onap.policy.rest.jpa.PEPOptions</class>
+ <class>org.onap.policy.rest.jpa.PIPConfigParam</class>
+ <class>org.onap.policy.rest.jpa.PIPConfiguration</class>
+ <class>org.onap.policy.rest.jpa.PIPResolver</class>
+ <class>org.onap.policy.rest.jpa.PIPResolverParam</class>
+ <class>org.onap.policy.rest.jpa.PIPType</class>
+ <class>org.onap.policy.rest.jpa.PolicyAlgorithms</class>
+ <class>org.onap.policy.rest.jpa.PolicyManagement</class>
+ <class>org.onap.policy.rest.jpa.PolicyScopeService</class>
+ <class>org.onap.policy.rest.jpa.PolicyScopeType</class>
+ <class>org.onap.policy.rest.jpa.PolicyScopeResource</class>
+ <class>org.onap.policy.rest.jpa.PolicyScopeClosedLoop</class>
+ <class>org.onap.policy.rest.jpa.PortList</class>
+ <class>org.onap.policy.rest.jpa.PREFIXLIST</class>
+ <class>org.onap.policy.rest.jpa.ProtocolList</class>
+ <class>org.onap.policy.rest.jpa.RemoteCatalogValues</class>
+ <class>org.onap.policy.rest.jpa.PolicyRoles</class>
+ <class>org.onap.policy.rest.jpa.RuleAlgorithms</class>
+ <class>org.onap.policy.rest.jpa.SecurityZone</class>
+ <class>org.onap.policy.rest.jpa.ServiceList</class>
+ <class>org.onap.policy.rest.jpa.SystemLogDB</class>
+ <class>org.onap.policy.rest.jpa.TermList</class>
+ <class>org.onap.policy.rest.jpa.VarbindDictionary</class>
+ <class>org.onap.policy.rest.jpa.VMType</class>
+ <class>org.onap.policy.rest.jpa.VNFType</class>
+ <class>org.onap.policy.rest.jpa.VSCLAction</class>
+ <class>org.onap.policy.rest.jpa.Zone</class>
+ <!-- unique to PolicyEngineUtils -->
+ <class>org.onap.policy.jpa.BackUpMonitorEntity</class>
+ <!-- unique to integrity-monitor -->
+ <class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
+ <class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
+ <class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
+ <!-- unique to integrity-audit -->
+ <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+
+ <exclude-unlisted-classes>false</exclude-unlisted-classes>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:./sql/xacmlTest"/> <!-- ;MODE=MySQL"/> -->
+ <property name="javax.persistence.jdbc.user" value="sa"/>
+ <property name="javax.persistence.jdbc.password" value=""/>
+ <property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.scripts.create-target" value="./src/test/resources/generatedCreate.ddl"/>
+ <property name="javax.persistence.schema-generation.scripts.drop-target" value="./src/test/resources/generatedDrop.ddl"/>
+ <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.create-source" value="metadata-then-script"/>
+ <property name="javax.persistence.schema-generation.drop-source" value="script"/>
+ <property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.ddl" />
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/ONAP-PDP-REST/src/test/resources/fail.xacml.pdp.properties b/ONAP-PDP-REST/src/test/resources/fail.xacml.pdp.properties
index a16b422bf..fdc7798b4 100644
--- a/ONAP-PDP-REST/src/test/resources/fail.xacml.pdp.properties
+++ b/ONAP-PDP-REST/src/test/resources/fail.xacml.pdp.properties
@@ -122,8 +122,8 @@ xacml.rest.notification.delay=30
REQUEST_BUFFER_SIZE=15
#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/ONAP-PDP-REST/src/test/resources/notification.xacml.pdp.properties b/ONAP-PDP-REST/src/test/resources/notification.xacml.pdp.properties
index 9ca1bba9c..2a3600559 100644
--- a/ONAP-PDP-REST/src/test/resources/notification.xacml.pdp.properties
+++ b/ONAP-PDP-REST/src/test/resources/notification.xacml.pdp.properties
@@ -122,8 +122,8 @@ xacml.rest.notification.delay=30
REQUEST_BUFFER_SIZE=15
#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/ONAP-PDP-REST/src/test/resources/pass.xacml.pdp.properties b/ONAP-PDP-REST/src/test/resources/pass.xacml.pdp.properties
index c9a111012..c3eda591f 100644
--- a/ONAP-PDP-REST/src/test/resources/pass.xacml.pdp.properties
+++ b/ONAP-PDP-REST/src/test/resources/pass.xacml.pdp.properties
@@ -122,8 +122,8 @@ xacml.rest.notification.delay=30
REQUEST_BUFFER_SIZE=15
#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/ONAP-PDP-REST/src/test/resources/xacml.pdp.properties b/ONAP-PDP-REST/src/test/resources/xacml.pdp.properties
new file mode 100644
index 000000000..bb174b9fd
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/resources/xacml.pdp.properties
@@ -0,0 +1,176 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP-PDP-REST
+# ================================================================================
+# Copyright (C) 2017 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.
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+# Default XACML Properties File for PDP RESTful servlet
+#
+# Standard API Factories
+#
+xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory
+xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory
+xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory
+# NOT USED SEE BELOW xacml.pipFinderFactory=org.onap.policy.xacml.std.pip.StdPIPFinderFactory
+xacml.traceEngineFactory=com.att.research.xacml.std.trace.LoggingTraceEngineFactory
+#
+# AT&T PDP Implementation Factories
+#
+xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory
+xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory
+xacml.att.functionDefinitionFactory=org.onap.policy.xacml.custom.OnapFunctionDefinitionFactory
+# NOT USED SEE BELOW xacml.att.policyFinderFactory=org.onap.policy.pdp.std.StdPolicyFinderFactory
+# creteUpdate Policy Implementation Class details.
+createUpdatePolicy.impl.className=org.onap.policy.pdp.rest.api.services.CreateUpdatePolicyServiceImpl
+# AAF Implementation class details
+aafClient.impl.className=org.onap.policy.utils.AAFPolicyClientImpl
+#
+# AT&T RESTful PDP Implementation Factories
+#
+xacml.pipFinderFactory=org.onap.policy.pdp.rest.impl.XACMLPdpPIPFinderFactory
+xacml.att.policyFinderFactory=org.onap.policy.pdp.rest.XACMLPdpPolicyFinderFactory
+#
+# When set to true, this flag tells the StdPolicyFinderFactory to combined all the root policy files into
+# into one PolicySet and use the given Policy Algorithm.
+#
+xacml.att.policyFinderFactory.combineRootPolicies=urn:com:att:xacml:3.0:policy-combining-algorithm:combined-permit-overrides
+#
+# PDP RESTful API properties
+#
+# Set this to the address where the XACML-PAP-REST servlet is running
+xacml.rest.pap.url=http://localhost:8070/pap/
+
+#if multiple paps exist, the xacml.rest.pap.url can be removed and they can be defined like this:
+#xacml.rest.pap.urls=http://localhost:9090/pap/,http://localhost:9091/pap/
+
+#
+# Give the running PDP an ID for the PAP. The url that its running as is a good choice.
+# The PAP identifies PDP's using the URL of the PDP.
+#
+xacml.rest.pdp.id=http://localhost:8082/pdp/
+
+# Give the port number used for the PDP
+
+xacml.jmx.port=0
+
+
+# Notification Properties
+# Notifcation type: websocket, ueb or dmaap... if left blank websocket is the default
+NOTIFICATION_TYPE=websocket
+NOTIFICATION_SERVERS=
+NOTIFICATION_TOPIC=
+NOTIFICATION_DELAY=
+UEB_API_KEY=
+UEB_API_SECRET=
+DMAAP_AAF_LOGIN=
+DMAAP_AAF_PASSWORD=
+
+#
+# Set the directory where the PDP holds its Policy Cache and PIP Configuration
+#
+xacml.rest.pdp.config=config
+
+xacml.rest.pdp.webapps=/home/users/PolicyEngine/webapps/ConfigPAP/
+#
+# Initialize register with PAP servlet
+#
+xacml.rest.pdp.register=true
+#
+# Sleep period in seconds between register attempts
+#
+xacml.rest.pdp.register.sleep=15
+#
+# number of attempts to register. -1 means keep trying forever.
+#
+xacml.rest.pdp.register.retries=-1
+#
+# max number of bytes in a POST of a XML/JSON request
+# old value #32767
+xacml.rest.pdp.maxcontent=99999999
+#
+# Set UserID here
+xacml.rest.pdp.userid=testpdp
+# Set Password here
+xacml.rest.pdp.password=alpha456
+
+# id PAP
+xacml.rest.pap.userid=testpap
+#if multiple paps have different logins, they can be defined like this:
+#http\://localhost\:9090/pap/.xacml.rest.pap.userid=testpap
+
+# pass PAP
+xacml.rest.pap.password=alpha123
+#http\://localhost\:9090/pap/.xacml.rest.pap.password=alpha123
+
+# Delay for Notifications Don't change this. Value in milliSec.
+xacml.rest.notification.delay=30
+
+# Client interval to ping notification service.
+CLIENT_INTERVAL=15000
+
+# Buffer Size.
+REQUEST_BUFFER_SIZE=15
+
+#Properties for db access
+#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
+javax.persistence.jdbc.driver=org.h2.Driver
+javax.persistence.jdbc.url=jdbc:h2:file:./sql/xacmlTest
+javax.persistence.jdbc.user=sa
+javax.persistence.jdbc.password=
+
+#***Properties for IntegrityMonitor integration defined in XACMLRestProperties.java***
+
+#The name of the PDP. Must be unique across the system
+xacml.rest.pdp.resource.name=site_1.pdp_1
+
+#***Properties for IntegrityMonitor integration defined in IntegrityMonitorProperties.java***
+
+#Interval between forward progress counter updates in seconds
+fp_monitor_interval=30
+
+#Number of forward progress counter failures before failover
+failed_counter_threshold=3
+
+#Interval in seconds between test transactions if there is no other traffic
+test_trans_interval=10
+
+#Interval in seconds between updates of the forward progress counter in the DB
+write_fpc_interval=5
+
+#Name of the site
+site_name=site_1
+
+#Node type
+node_type=pdp_xacml
+
+#Dependency groups are groups of resources upon which a node operational state is dependent upon).
+#Each group is a comma-separated list of resource names and groups are separated by a semicolon.
+#A group may contain one or more members. Resource names must match the resource names defined
+#in the respective servers' properties files
+dependency_groups=site_1.pdplp_1;site_1.astragw_1;site_1.brmsgw_1
+
+# this can be DEVL, TEST, PROD
+ENVIRONMENT=DEVL
+xacml.rest.pep.idfile = client.properties
+
+#AAF Policy Name space
+#Not Mandatory for Open Onap
+policy.aaf.namespace =
+policy.aaf.resource =
+# Decision Response settings.
+# can be either PERMIT or DENY.
+decision.indeterminate.response=PERMIT \ No newline at end of file
diff --git a/ONAP-PDP-REST/xacml.pdp.properties b/ONAP-PDP-REST/xacml.pdp.properties
index 6cf2e945b..4d120042a 100644
--- a/ONAP-PDP-REST/xacml.pdp.properties
+++ b/ONAP-PDP-REST/xacml.pdp.properties
@@ -126,8 +126,8 @@ CLIENT_INTERVAL=15000
REQUEST_BUFFER_SIZE=15
#properties for MySql xacml database: PLEASE DO NOT REMOVE... NEEDED FOR APIs
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/onap_sdk
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/ONAP-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties b/ONAP-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
index 304bcbd90..991cb8aee 100644
--- a/ONAP-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
+++ b/ONAP-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
@@ -23,8 +23,8 @@ decryption_key = AGLDdG4D04BKm2IxIWEr8o==
# The following properties MAY require changes by partner applications.
##########################################################################
#Mysql
-db.driver = com.mysql.jdbc.Driver
-db.connectionURL = jdbc:mysql://localhost:3306/onap_sdk
+db.driver = org.mariadb.jdbc.Driver
+db.connectionURL = jdbc:mariadb://localhost:3306/onap_sdk
db.userName = policy_user
db.password = policy_user
db.hib.dialect = org.hibernate.dialect.MySQLDialect
diff --git a/ONAP-SDK-APP/xacml.admin.properties b/ONAP-SDK-APP/xacml.admin.properties
index 0f285b694..333da49a5 100644
--- a/ONAP-SDK-APP/xacml.admin.properties
+++ b/ONAP-SDK-APP/xacml.admin.properties
@@ -87,8 +87,8 @@ xacml.log.db.password=policy_user
xacml.att.log.timeframe=150
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/onap_sdk
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
new file mode 100644
index 000000000..6600a9208
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.xacml.test.std.pap;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.api.pap.OnapPDP;
+import org.onap.policy.xacml.std.pap.StdEngine;
+
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.std.pap.StdPDP;
+
+public class StdEngineTest {
+
+ private static Logger logger = FlexLogger.getLogger(StdEngineTest.class);
+ private Path repository;
+ Properties properties = new Properties();
+ StdEngine stdEngine = null;
+
+ @Before
+ public void setUp(){
+
+ repository = Paths.get("src/test/resources/pdps");
+ try {
+ stdEngine = new StdEngine(repository);
+ } catch (PAPException e) {
+ logger.info(e);
+ } catch (IOException e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDefaultGroup(){
+ try {
+ assertTrue(stdEngine.getDefaultGroup() != null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetGroup(){
+ try {
+ assertTrue(stdEngine.getGroup("1") == null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetOnapPDPGroups(){
+ try {
+ assertTrue(stdEngine.getOnapPDPGroups() != null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetPDP(){
+ try {
+ assertTrue(stdEngine.getPDP("1") == null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetPDPGroup(){
+ try {
+ assertTrue(stdEngine.getPDPGroup(null) == null);
+ } catch (PAPException e) {
+ logger.info(e);
+ }
+ }
+}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
new file mode 100644
index 000000000..da7476b67
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
@@ -0,0 +1,543 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.xacml.test.std.pap;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.xacml.api.pap.OnapPDP;
+import org.onap.policy.xacml.std.pap.StdEngine;
+import org.onap.policy.xacml.std.pap.StdPAPPolicy;
+
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.std.pap.StdPDP;
+
+public class StdPAPPolicyTest {
+
+ private static Logger logger = FlexLogger.getLogger(StdPAPPolicyTest.class);
+ private Path repository;
+ Properties properties = new Properties();
+ StdPAPPolicy stdPAPPolicy;
+
+ @Before
+ public void setUp(){
+
+ repository = Paths.get("src/test/resources/pdps");
+ try {
+ stdPAPPolicy = new StdPAPPolicy();
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetActionAttribute(){
+ try {
+ stdPAPPolicy.setActionAttribute("test");
+ assertTrue(stdPAPPolicy.getActionAttribute() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetActionBody(){
+ try {
+ stdPAPPolicy.setActionBody("actionBody");
+ assertTrue(stdPAPPolicy.getActionBody() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetActionDictHeader(){
+ try {
+ stdPAPPolicy.setActionDictHeader("actionDictHeader");
+ assertTrue(stdPAPPolicy.getActionDictHeader() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetActionDictMethod(){
+ try {
+ stdPAPPolicy.setActionDictMethod("actionDictMethod");
+ assertTrue(stdPAPPolicy.getActionDictMethod() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetActionDictType(){
+ try {
+ stdPAPPolicy.setActionDictType("actionDictType");
+ assertTrue(stdPAPPolicy.getActionDictType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetActionDictUrl(){
+ try {
+ stdPAPPolicy.setActionDictUrl("actionDictUrl");
+ assertTrue(stdPAPPolicy.getActionDictUrl() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetActionPerformer(){
+ try {
+ stdPAPPolicy.setActionPerformer("actionPerformer");
+ assertTrue(stdPAPPolicy.getActionPerformer() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetBrmsController(){
+ try {
+ stdPAPPolicy.setBrmsController("brmsController");
+ assertTrue(stdPAPPolicy.getBrmsController() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetBrmsDependency(){
+ try {
+ stdPAPPolicy.setBrmsDependency(new ArrayList());
+ assertTrue(stdPAPPolicy.getBrmsDependency() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetConfigBodyData(){
+ try {
+ stdPAPPolicy.setConfigBodyData("configBodyData");
+ assertTrue(stdPAPPolicy.getConfigBodyData() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+
+ @Test
+ public void testGetConfigName(){
+ try {
+ stdPAPPolicy.setConfigName("configName");
+ assertTrue(stdPAPPolicy.getConfigName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetConfigPolicyType(){
+ try {
+ stdPAPPolicy.setConfigPolicyType("configPolicyType");
+ assertTrue(stdPAPPolicy.getConfigPolicyType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetConfigType(){
+ try {
+ stdPAPPolicy.setConfigType("configType");
+ assertTrue(stdPAPPolicy.getConfigType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDataTypeList(){
+ try {
+ stdPAPPolicy.setDataTypeList(new ArrayList<String>());
+ assertTrue(stdPAPPolicy.getDataTypeList() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDeleteCondition(){
+ try {
+ stdPAPPolicy.setDeleteCondition("deleteCondition");
+ assertTrue(stdPAPPolicy.getDeleteCondition() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+
+ @Test
+ public void testGetDrlRuleAndUIParams(){
+ try {
+ stdPAPPolicy.setDrlRuleAndUIParams(new HashMap());
+ assertTrue(stdPAPPolicy.getDrlRuleAndUIParams() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDropDownMap(){
+ try {
+ stdPAPPolicy.setDropDownMap(new HashMap());
+ assertTrue(stdPAPPolicy.getDropDownMap() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetDynamicFieldConfigAttributes(){
+ try {
+ assertTrue(stdPAPPolicy.getDynamicFieldConfigAttributes() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDynamicRuleAlgorithmCombo(){
+ try {
+ stdPAPPolicy.setDynamicRuleAlgorithmCombo(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicRuleAlgorithmCombo() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDynamicRuleAlgorithmField1(){
+ try {
+ stdPAPPolicy.setDynamicRuleAlgorithmField1(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicRuleAlgorithmField1() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDictionary(){
+ try {
+ stdPAPPolicy.setDictionary("dictionary");
+ assertTrue(stdPAPPolicy.getDictionary() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDictionaryFields(){
+ try {
+ stdPAPPolicy.setDictionaryFields("dictionaryFields");
+ assertTrue(stdPAPPolicy.getDictionaryFields() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetDictionaryType(){
+ try {
+ stdPAPPolicy.setDictionaryType("dictionaryType");
+ assertTrue(stdPAPPolicy.getDictionaryType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDomainDir(){
+ try {
+ stdPAPPolicy.setDomainDir("domain");
+ assertTrue(stdPAPPolicy.getDomainDir() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testIsDraft(){
+ try {
+ stdPAPPolicy.setDraft(true);
+ assertTrue(stdPAPPolicy.isDraft() == true);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetDynamicRuleAlgorithmLabels(){
+ try {
+ stdPAPPolicy.setDynamicRuleAlgorithmLabels(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicRuleAlgorithmLabels() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetDynamicSettingsMap(){
+ try {
+ stdPAPPolicy.setDynamicSettingsMap(new HashMap());
+ assertTrue(stdPAPPolicy.getDynamicSettingsMap() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetDynamicVariableList(){
+ try {
+ stdPAPPolicy.setDynamicVariableList(new ArrayList());
+ assertTrue(stdPAPPolicy.getDynamicVariableList() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetGuard(){
+ try {
+ stdPAPPolicy.setGuard("domain");
+ assertTrue(stdPAPPolicy.getGuard() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetHighestVersion(){
+ try {
+ stdPAPPolicy.setHighestVersion(123);
+ assertTrue(stdPAPPolicy.getHighestVersion() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testgGtJsonBody(){
+ try {
+ stdPAPPolicy.setJsonBody("jsonBoby");
+ assertTrue(stdPAPPolicy.getJsonBody() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetLocation(){
+ try {
+ stdPAPPolicy.setLocation(new URI("test"));
+ assertTrue(stdPAPPolicy.getLocation() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetMsLocation(){
+ try {
+ stdPAPPolicy.setMsLocation("MsLocation");
+ assertTrue(stdPAPPolicy.getMsLocation() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testSetOldPolicyFileName(){
+ try {
+ stdPAPPolicy.setOldPolicyFileName("domain");
+ assertTrue(stdPAPPolicy.getOldPolicyFileName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetOnapName(){
+ try {
+ stdPAPPolicy.setOnapName("onap");
+ assertTrue(stdPAPPolicy.getOnapName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetPolicyDescription(){
+ try {
+ stdPAPPolicy.setPolicyDescription("description test");
+ assertTrue(stdPAPPolicy.getPolicyDescription() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetPolicyID(){
+ try {
+ stdPAPPolicy.setPolicyID("test");
+ assertTrue(stdPAPPolicy.getPolicyID() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testSetPolicyName(){
+ try {
+ stdPAPPolicy.setPolicyName("MsLocation");
+ assertTrue(stdPAPPolicy.getPolicyName() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testSetPriority(){
+ try {
+ stdPAPPolicy.setPriority("domain");
+ assertTrue(stdPAPPolicy.getPriority() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetProviderComboBox(){
+ try {
+ stdPAPPolicy.setProviderComboBox("onap");
+ assertTrue(stdPAPPolicy.getProviderComboBox() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetRiskLevel(){
+ try {
+ stdPAPPolicy.setRiskLevel("test");
+ assertTrue(stdPAPPolicy.getRiskLevel() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetRiskType(){
+ try {
+ stdPAPPolicy.setRiskType("test");
+ assertTrue(stdPAPPolicy.getRiskType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testGetRuleID(){
+ try {
+ stdPAPPolicy.setRuleID("MsLocation");
+ assertTrue(stdPAPPolicy.getRuleID() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetServiceType(){
+ try {
+ stdPAPPolicy.setServiceType("domain");
+ assertTrue(stdPAPPolicy.getServiceType() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+ @Test
+ public void testGetTTLDate(){
+ try {
+ stdPAPPolicy.setTTLDate("09/20/17");
+ assertTrue(stdPAPPolicy.getTTLDate() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+
+ @Test
+ public void testGetUuid(){
+ try {
+ stdPAPPolicy.setUuid("11212122");
+ assertTrue(stdPAPPolicy.getUuid() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testGetVersion(){
+ try {
+ stdPAPPolicy.setVersion("testv01");
+ assertTrue(stdPAPPolicy.getVersion() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+
+ }
+
+ @Test
+ public void testIsEditPolicy(){
+ try {
+ stdPAPPolicy.setEditPolicy(true);
+ assertTrue(stdPAPPolicy.isEditPolicy() == true);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+ @Test
+ public void testToString(){
+ try {
+ assertTrue(stdPAPPolicy.toString() != null);
+ } catch (Exception e) {
+ logger.info(e);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
index 3febbed44..7ac9ca310 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
@@ -34,6 +34,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -49,9 +50,14 @@ public class CheckPDP {
private static HashMap<String, String> pdpMap = null;
private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
- private CheckPDP(){
+ public static Map<String, String> getPdpMap() {
+ return pdpMap;
+ }
+
+ public CheckPDP(){
//default constructor
}
+
public static boolean validateID(String id) {
// ReadFile
try {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index 4f42023c9..c94c14de2 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -92,16 +92,6 @@ public class PolicyManagerServlet extends HttpServlet {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyManagerServlet.class);
private static final long serialVersionUID = -8453502699403909016L;
- private static boolean jUnit = false;
-
- public static boolean isjUnit() {
- return jUnit;
- }
-
- public static void setjUnit(boolean jUnit) {
- PolicyManagerServlet.jUnit = jUnit;
- }
-
private enum Mode {
LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
}
@@ -542,7 +532,7 @@ public class PolicyManagerServlet extends HttpServlet {
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
List<Object> queryData = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{
queryData = controller.getDataByQuery(query, peParams);
@@ -684,7 +674,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
PolicyController controller = getPolicyControllerInstance();
List<Object> scopesList = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
scopesList = controller.getDataByQuery(scopeNamequery, params);
@@ -709,7 +699,7 @@ public class PolicyManagerServlet extends HttpServlet {
List<Object> activePolicies = null;
List<Object> scopesList = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
activePolicies = controller.getDataByQuery(query, null);
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
@@ -1422,7 +1412,7 @@ public class PolicyManagerServlet extends HttpServlet {
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
List<Object> queryData = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{
queryData = controller.getDataByQuery(query, peParams);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
index a4e476200..2326a9fb7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
@@ -122,7 +122,12 @@ public class PolicyNotificationMail{
boolean sendFlag = false;
SimpleBindings params = new SimpleBindings();
params.put("policyFileName", policyFileName);
- List<Object> watchList = policyNotificationDao.getDataByQuery(query, params);
+ List<Object> watchList = null;
+ if(PolicyController.isjUnit()){
+ watchList = policyNotificationDao.getDataByQuery(query, null);
+ }else{
+ watchList = policyNotificationDao.getDataByQuery(query, params);
+ }
if(watchList != null && !watchList.isEmpty()){
for(Object watch : watchList){
WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index 7234a3b6a..08f80304c 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -82,8 +82,24 @@ public class PolicyRestController extends RestrictedBaseController{
private static final String modal = "model";
private static final String importDictionary = "import_dictionary";
+ private static CommonClassDao commonClassDao;
+
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ PolicyRestController.commonClassDao = commonClassDao;
+ }
+
@Autowired
- CommonClassDao commonClassDao;
+ private PolicyRestController(CommonClassDao commonClassDao){
+ PolicyRestController.commonClassDao = commonClassDao;
+ }
+
+ public PolicyRestController(){
+ //default constructor
+ }
@RequestMapping(value={"/policycreation/save_policy"}, method={RequestMethod.POST})
public void policyCreationController(HttpServletRequest request, HttpServletResponse response) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
index a0f1ba86d..7c60ecfdf 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
@@ -202,7 +202,7 @@ class HtmlProcessor extends SimpleCallback {
combiningAlgo2human.put("only-one-applicable", "to honour the result of the first successfully evaluated $placeholder$ in order");
}
- private Map<String, AttributeIdentifiers> attributeIdentifiersMap = new HashMap<String, AttributeIdentifiers>();
+ private Map<String, AttributeIdentifiers> attributeIdentifiersMap = new HashMap<>();
private final StringWriter stringWriter = new StringWriter();
private final PrintWriter htmlOut = new PrintWriter(stringWriter);
@@ -357,7 +357,7 @@ class HtmlProcessor extends SimpleCallback {
else
policySet(policySet, "li");
- if (policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0)
+ if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty())
htmlOut.println("<ol>");
return super.onPreVisitPolicySet(parent, policySet);
@@ -377,7 +377,7 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.trace("PolicySet: " + policySet.getPolicySetId() +
" Description: " + policySet.getDescription());
- if (policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0)
+ if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty())
htmlOut.println("</ol>");
htmlOut.println("<p></p>");
@@ -421,7 +421,7 @@ class HtmlProcessor extends SimpleCallback {
}
if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null &&
- policySet.getPolicySetOrPolicyOrPolicySetIdReference().size() > 0) {
+ !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) {
String algoDesc = combiningAlgo2human.get(combiningAlgorithm);
if (algoDesc != null) {
algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)";
@@ -449,7 +449,7 @@ class HtmlProcessor extends SimpleCallback {
policy(policy);
- if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0)
+ if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty())
htmlOut.println("<ol type=\"i\">");
return super.onPreVisitPolicy(parent, policy);
@@ -464,7 +464,7 @@ class HtmlProcessor extends SimpleCallback {
LOGGER.trace("PolicySet: " + policy.getPolicyId() +
"Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion());
- if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0)
+ if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty())
htmlOut.println("</ol>");
htmlOut.println("<p></p>");
@@ -506,7 +506,7 @@ class HtmlProcessor extends SimpleCallback {
}
if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition() != null &&
- policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().size() > 0) {
+ !policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) {
String algoDesc = combiningAlgo2human.get(combiningAlgorithm);
if (algoDesc != null) {
algoDesc = algoDesc.replace("$placeholder$", "rule") + " (<i>" + combiningAlgorithm + "</i>)";
@@ -710,7 +710,7 @@ class HtmlProcessor extends SimpleCallback {
//
StdAttribute attribute = null;
AttributeValueType value = match.getAttributeValue();
- String attributeDataType = null;
+ String attributeDataType;
if (match.getAttributeDesignator() != null && value != null) {
AttributeDesignatorType designator = match.getAttributeDesignator();
attribute = new StdAttribute(new IdentifierImpl(designator.getCategory()),
@@ -822,11 +822,12 @@ class HtmlProcessor extends SimpleCallback {
}
private String removePrimitives(String in) {
- in = in.replace("string-", "");
- in = in.replace("integer-", "");
- in = in.replace("double-", "");
- in = in.replace("boolean-", "");
- return in;
+ String newIn = in;
+ newIn = newIn.replace("string-", "");
+ newIn = newIn.replace("integer-", "");
+ newIn = newIn.replace("double-", "");
+ newIn = newIn.replace("boolean-", "");
+ return newIn;
}
private String stringifyCondition(ConditionType condition) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
index 353e08a44..32f40b9e7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/conf/HibernateSession.java
@@ -64,4 +64,6 @@ public class HibernateSession{
logSessionFactory = logSessionFactory1;
}
+ private HibernateSession(){
+ }
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
index f10041e38..392adf039 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopPMController.java
@@ -98,24 +98,24 @@ public class CreateClosedLoopPMController{
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
- if (attributeId.equals("ServiceType")){
+ if ("ServiceType".equals(attributeId)){
LinkedHashMap<String, String> serviceTypePolicyName1 = new LinkedHashMap<>();
String key = "serviceTypePolicyName";
serviceTypePolicyName1.put(key, value);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
index ed0bf4caf..9832f5803 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
@@ -90,6 +90,14 @@ public class CreateFirewallController extends RestrictedBaseController {
private static CommonClassDao commonClassDao;
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ CreateFirewallController.commonClassDao = commonClassDao;
+ }
+
private List<String> tagCollectorList;
private String jsonBody;
List<String> expandablePrefixIPList = new ArrayList<>();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
index 49024ba0d..c96da506f 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java
@@ -43,16 +43,6 @@ import org.onap.policy.common.logging.flexlogger.Logger;
public class SystemLogDbDaoImpl implements SystemLogDbDao {
private static final Logger logger = FlexLogger.getLogger(SystemLogDbDaoImpl.class);
- private static boolean jUnit = false;
-
- public static boolean isjUnit() {
- return jUnit;
- }
-
- public static void setjUnit(boolean jUnit) {
- SystemLogDbDaoImpl.jUnit = jUnit;
- }
-
@SuppressWarnings("unchecked")
@Override
public List<SystemLogDB> getLoggingData() {
@@ -61,7 +51,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
List<SystemLogDB> system = null;
try {
String sqlWhere = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
sqlWhere = "";
}else{
sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) ORDER BY date DESC limit "+PolicyController.getLogTableLimit()+"";
@@ -90,7 +80,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao {
List<SystemLogDB> system = null;
try {
String sqlWhere = null;
- if(jUnit){
+ if(PolicyController.isjUnit()){
sqlWhere = "";
}else{
sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) and logtype = 'error' ORDER BY date DESC limit "+PolicyController.getSystemAlertTableLimit()+"";
diff --git a/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties b/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
index 43b2de708..84c5dc5dd 100644
--- a/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
+++ b/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties
@@ -23,8 +23,8 @@ decryption_key = AGLDdG4D04BKm2IxIWEr8o==
# The following properties MAY require changes by partner applications.
##########################################################################
#Mysql
-db.driver = com.mysql.jdbc.Driver
-db.connectionURL = jdbc:mysql://localhost:3306/onapsdk1707
+db.driver = org.mariadb.jdbc.Driver
+db.connectionURL = jdbc:mariadb://localhost:3306/onapsdk1707
db.userName = root
db.password =
db.hib.dialect = org.hibernate.dialect.MySQLDialect
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
new file mode 100644
index 000000000..47358a8f2
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.admin;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.junit.Test;
+
+public class CheckPDPTest {
+
+ @Test
+ public final void testCheckPDP() {
+ try {
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "test.properties");
+ CheckPDP.validateID("http://localhost:8082/pdp/");
+ assertTrue(CheckPDP.getPdpMap().containsKey("http://localhost:8082/pdp/"));
+ assertTrue(CheckPDP.getEncoding("http://localhost:8082/pdp/").equals("dGVzdHBkcDphbHBoYTQ1Ng=="));
+ } catch (Exception e) {
+ fail("Error occured in CheckPDP test");
+ }
+ }
+
+}
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 970b67878..22cc82a23 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
@@ -64,6 +64,7 @@ public class PolicyManagerServletTest extends Mockito{
@Before
public void setUp() throws Exception{
logger.info("setUp: Entering");
+ PolicyController.setjUnit(true);
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId("Test");
userinfo.setUserName("Test");
@@ -146,7 +147,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
BufferedReader reader = new BufferedReader(new StringReader("{params: { mode: 'DESCRIBEPOLICYFILE', path: 'com.Config_SampleTest1206.1.xml'}}"));
try {
when(request.getReader()).thenReturn(reader);
@@ -168,7 +168,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'LIST', path: '/', onlyFolders: false}}");
list.add("{params: { mode: 'LIST', path: '/com', onlyFolders: false}}");
@@ -197,7 +196,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_SampleTest1206.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -244,7 +242,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -291,7 +288,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -338,7 +334,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_Fault_TestClosedLoopPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -385,7 +380,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_PM_TestClosedLoopPMPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -439,7 +433,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_MS_vFirewall.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -487,7 +480,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Config_FW_TestFireWallPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -532,7 +524,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Action_TestActionPolicy.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
@@ -571,7 +562,6 @@ public class PolicyManagerServletTest extends Mockito{
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PolicyController controller = mock(PolicyController.class);
- PolicyManagerServlet.setjUnit(true);
List<String> list = new ArrayList<>();
list.add("{params: { mode: 'EDITFILE', path: '/com/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml', onlyFolders: false}}");
for(int i =0; i < list.size(); i++){
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
new file mode 100644
index 000000000..2c56a8b7f
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.admin;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.when;
+import org.onap.policy.controller.PolicyController;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.PolicyVersion;
+import org.onap.policy.rest.jpa.WatchPolicyNotificationTable;
+
+public class PolicyNotificationMailTest {
+
+ private PolicyVersion version;
+ private String policyName = "com/Config_Test";
+ private CommonClassDao commonClassDao;
+ private List<Object> data = null;
+
+ @Before
+ public void setUp() throws Exception {
+ PolicyController.setjUnit(true);
+ PolicyController.setSmtpApplicationName("Test");
+ PolicyController.setSmtpEmailExtension("test.com");
+ PolicyController.setSmtpHost("test");
+ PolicyController.setSmtpPort("23");
+ PolicyController.setSmtpPassword("test");
+ PolicyController.setSmtpUsername("test");
+
+ version = new PolicyVersion();
+ version.setPolicyName("com/Config_Test");
+ version.setModifiedBy("xyz");
+
+ WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+ watch.setPolicyName("com/Config_Test");
+ data = new ArrayList<>();
+ data.add(watch);
+
+ commonClassDao = mock(CommonClassDao.class);
+ PolicyController.setCommonClassDao(commonClassDao);
+ when(commonClassDao.getDataByQuery("from WatchPolicyNotificationTable where policyName like:policyFileName", null)).thenReturn(data);
+ }
+
+ @Test
+ public final void testJavaMailSenderImpl() {
+ PolicyNotificationMail notificationMail = new PolicyNotificationMail();
+ try{
+ assertTrue(notificationMail.javaMailSenderImpl() != null);
+ }catch(Exception e){
+ fail();
+ }
+ }
+
+ @Test
+ public final void testSendMail() {
+ PolicyNotificationMail notificationMail = new PolicyNotificationMail();
+ try{
+ notificationMail.sendMail(version, policyName, "EditPolicy", commonClassDao);
+ notificationMail.sendMail(version, policyName, "Rename", commonClassDao);
+ notificationMail.sendMail(version, policyName, "DeleteAll", commonClassDao);
+ notificationMail.sendMail(version, policyName, "DeleteOne", commonClassDao);
+ notificationMail.sendMail(version, policyName, "DeleteScope", commonClassDao);
+ notificationMail.sendMail(version, policyName, "SwitchVersion", commonClassDao);
+ notificationMail.sendMail(version, policyName, "Move", commonClassDao);
+ }catch(Exception e){
+ fail();
+ }
+ }
+
+}
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
new file mode 100644
index 000000000..1bda7cd41
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java
@@ -0,0 +1,232 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.admin;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.controller.CreateFirewallController;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.ActionList;
+import org.onap.policy.rest.jpa.AddressGroup;
+import org.onap.policy.rest.jpa.FWTagPicker;
+import org.onap.policy.rest.jpa.GroupServiceList;
+import org.onap.policy.rest.jpa.PrefixList;
+import org.onap.policy.rest.jpa.SecurityZone;
+import org.onap.policy.rest.jpa.ServiceList;
+import org.onap.policy.rest.jpa.TermList;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class PolicyRestControllerTest {
+
+ private String clRequestString;
+ private String fwRequestString;
+ private String fwViewRequestString;
+ private HttpServletRequest request;
+ private MockHttpServletResponse response;
+ private static CommonClassDao commonClassDao;
+ private List<Object> prefixListData;
+ private List<Object> actionListData;
+ private List<Object> serviceListData;
+ private List<Object> addressGroupData;
+ private List<Object> securityZoneData;
+ private List<Object> serviceGroupData;
+ private List<Object> tagListData;
+ private List<Object> termListData;
+
+ @Before
+ public void setUp() throws Exception {
+ commonClassDao = mock(CommonClassDao.class);
+ HttpSession mockSession = mock(HttpSession.class);
+ request = mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ User user = new User();
+ user.setOrgUserId("Test");
+ Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
+ Mockito.when(request.getSession(false)).thenReturn(mockSession);
+ clRequestString = "{\"policyData\":{\"error\":\"\",\"inprocess\":false,\"model\":{\"name\":\"com\","
+ + "\"subScopename\":\"\",\"path\":[],\"type\":\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\","
+ + "\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":\"Demo\",\"content\":\"\",\"recursive\":false},"
+ + "\"tempModel\":{\"name\":\"com\",\"subScopename\":\"\",\"path\":[],\"type\":\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\","
+ + "\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":\"Demo\",\"content\":\"\",\"recursive\":false},\"$$hashKey\":\"object:1439\","
+ + "\"policy\":{\"policyType\":\"Config\",\"configPolicyType\":\"ClosedLoop_Fault\",\"triggerTrapSignatures\":[1,1,2,3],"
+ + "\"triggerfaultSignatures\":[1,1,2,3],\"traptriggerSignatures\":[{\"id\":\"Trap1\",\"$$hashKey\":\"object:1526\"},"
+ + "{\"id\":\"Trap2\",\"$$hashKey\":\"object:1534\"}],\"connecttriggerSignatures\":[{\"id\":\"C1\",\"$$hashKey\":\"object:1554\","
+ + "\"notBox\":\"NOT\",\"connectTrap1\":\"Trap1\",\"trapCount1\":\"12\",\"operatorBox\":\"AND\",\"connectTrap2\":\"Trap2\","
+ + "\"trapCount2\":\"14\"}],\"faulttriggerSignatures\":[{\"id\":\"Fault1\",\"$$hashKey\":\"object:1566\"},{\"id\":\"Fault2\","
+ + "\"$$hashKey\":\"object:1575\"}],\"connectVerificationSignatures\":[{\"id\":\"C1\",\"$$hashKey\":\"object:1595\","
+ + "\"notBox\":\"NOT\",\"connectTrap1\":\"Fault1\",\"trapCount1\":\"11\",\"operatorBox\":\"AND\",\"connectTrap2\":\"Fault2\","
+ + "\"trapCount2\":\"12\"}],\"jsonBodyData\":{\"trapMaxAge\":\"300\",\"vnfType\":\"Test\",\"closedLoopPolicyStatus\":\"Active\","
+ + "\"vUSP\":true,\"trinity\":true,\"vDNS\":true,\"mcr\":true,\"gamma\":true,\"actions\":\"Test\",\"timeInterval\":\"11\","
+ + "\"timeOutvPRO\":\"11\",\"timeOutRuby\":\"11\",\"retrys\":\"1\",\"agingWindow\":\"12\",\"geoLink\":\"test\","
+ + "\"emailAddress\":\"aa@test.com\",\"pepName\":\"Test\",\"pepAction\":\"test\",\"conditions\":\"SEND\"},"
+ + "\"policyName\":\"SampleTest\",\"policyDescription\":\"SampleTest\",\"riskType\":\"SampleRiskType\",\"riskLevel\":\"1\","
+ + "\"guard\":\"True\",\"onapName\":\"SampleDemo\",\"ttlDate\":\"14/09/2017\",\"clearTimeOut\":\"123\",\"trapMaxAge\":\"11\","
+ + "\"verificationclearTimeOut\":\"13\"}},\"trapData\":{\"trap1\":[{\"id\":\"A1\",\"$$hashKey\":\"object:1528\","
+ + "\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"}],\"trap2\":[{\"id\":\"A1\","
+ + "\"$$hashKey\":\"object:1536\",\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"},"
+ + "{\"id\":\"A2\",\"$$hashKey\":\"object:1542\",\"notBox\":\"NOT\",\"trigger1\":\"A1\",\"operatorBox\":\"AND\",\"trigger2\":"
+ + "\"Test\"},{\"id\":\"A3\",\"$$hashKey\":\"object:1548\",\"notBox\":\"NOT\",\"trigger1\":\"A1\",\"operatorBox\":\"OR\","
+ + "\"trigger2\":\"A2\"}]},\"faultData\":{\"trap1\":[{\"id\":\"A1\",\"$$hashKey\":\"object:1568\",\"notBox\":\"NOT\","
+ + "\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"}],\"trap2\":[{\"id\":\"A1\",\"$$hashKey\":\"object:1577\","
+ + "\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"AND\",\"trigger2\":\"Test\"},{\"id\":\"A2\",\"$$hashKey\":"
+ + "\"object:1583\",\"notBox\":\"NOT\",\"trigger1\":\"Test\",\"operatorBox\":\"OR\",\"trigger2\":\"Test\"},{\"id\":\"A3"
+ + "\",\"$$hashKey\":\"object:1589\",\"notBox\":\"NOT\",\"trigger1\":\"A1\",\"operatorBox\":\"AND\",\"trigger2\":\"A2\"}]}}";
+
+
+ fwRequestString = "{\"policyData\":{\"error\":\"\",\"inprocess\":false,\"model\":{\"name\":\"com\",\"subScopename\":\"\",\"path\":[],"
+ + "\"type\":\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\",\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":"
+ + "\"Demo\",\"content\":\"\",\"recursive\":false},\"tempModel\":{\"name\":\"com\",\"subScopename\":\"\",\"path\":[],\"type\":"
+ + "\"dir\",\"size\":0,\"date\":\"2017-06-01T15:45:36.000Z\",\"version\":\"\",\"createdBy\":\"Demo\",\"modifiedBy\":\"Demo\","
+ + "\"content\":\"\",\"recursive\":false},\"$$hashKey\":\"object:260\",\"policy\":{\"policyType\":\"Config\",\"configPolicyType"
+ + "\":\"Firewall Config\",\"attributes\":[{\"id\":\"choice1\",\"$$hashKey\":\"object:338\",\"key\":\"Test\",\"value\":\"Test\"}],"
+ + "\"fwattributes\":[],\"policyName\":\"SampleTest\",\"policyDescription\":\"SampleTest\",\"riskType\":\"SampleRiskType\","
+ + "\"riskLevel\":\"1\",\"guard\":\"True\",\"configName\":\"SampleTest\",\"ttlDate\":\"14/09/2017\",\"securityZone\":\"Test\"}}}";
+
+ fwViewRequestString = "{\"policyData\":{\"policyType\":\"Config\",\"configPolicyType\":\"Firewall Config\",\"attributes\":[{\"id\":"
+ + "\"choice1\",\"$$hashKey\":\"object:338\",\"key\":\"Test\",\"value\":\"Test\"}],\"fwattributes\":[],\"policyName\":"
+ + "\"SampleTest\",\"policyDescription\":\"SampleTest\",\"riskType\":\"SampleRiskType\",\"riskLevel\":\"1\",\"guard\":\"True\","
+ + "\"configName\":\"SampleTest\",\"ttlDate\":\"14/09/2017\",\"securityZone\":\"Test\"}}";
+
+
+
+ prefixListData = new ArrayList<>();
+ PrefixList prefixList = new PrefixList();
+ prefixList.setPrefixListName("Test");
+ prefixList.setPrefixListValue("10.10.10.10/12");
+ prefixListData.add(prefixList);
+ when(commonClassDao.getData(PrefixList.class)).thenReturn(prefixListData);
+
+ actionListData = new ArrayList<>();
+ ActionList actionList = new ActionList();
+ actionList.setActionName("Test");
+ actionListData.add(actionList);
+ when(commonClassDao.getData(ActionList.class)).thenReturn(actionListData);
+
+ serviceListData = new ArrayList<>();
+ ServiceList serviceList = new ServiceList();
+ serviceList.setServiceName("Test");
+ serviceList.setServiceType("SERVICE");
+ serviceList.setServiceTransProtocol("Test");
+ serviceList.setServiceAppProtocol("Test");
+ serviceList.setServicePorts("8080");
+ serviceListData.add(serviceList);
+ when(commonClassDao.getData(ServiceList.class)).thenReturn(serviceListData);
+
+ addressGroupData = new ArrayList<>();
+ AddressGroup addressGroup = new AddressGroup();
+ addressGroup.setGroupName("Group_Test");
+ addressGroup.setServiceList("Test");
+ addressGroupData.add(addressGroup);
+ when(commonClassDao.getData(AddressGroup.class)).thenReturn(addressGroupData);
+
+ securityZoneData = new ArrayList<>();
+ SecurityZone securityZone = new SecurityZone();
+ securityZone.setZoneName("Test");
+ securityZone.setZoneValue("Test");
+ securityZoneData.add(securityZone);
+ when(commonClassDao.getData(SecurityZone.class)).thenReturn(securityZoneData);
+
+ serviceGroupData = new ArrayList<>();
+ GroupServiceList serviceGroup = new GroupServiceList();
+ serviceGroup.setGroupName("Group_Test");
+ serviceGroup.setServiceList("Test");
+ serviceGroupData.add(serviceGroup);
+ when(commonClassDao.getData(GroupServiceList.class)).thenReturn(serviceGroupData);
+
+ tagListData = new ArrayList<>();
+ FWTagPicker fwPicker = new FWTagPicker();
+ fwPicker.setTagPickerName("Test");
+ fwPicker.setTagValues("Test:8080");
+ tagListData.add(fwPicker);
+ when(commonClassDao.getData(FWTagPicker.class)).thenReturn(tagListData);
+
+ termListData = new ArrayList<>();
+ TermList termList = new TermList();
+ termList.setTermName("Test");
+ termList.setFromZones("Test");
+ termList.setToZones("Test");
+ termList.setSrcIPList("Test");
+ termList.setDestIPList("Test");
+ termList.setSrcPortList("Test");
+ termList.setDestPortList("Test");
+ termList.setAction("Test");
+ termListData.add(termList);
+ when(commonClassDao.getData(TermList.class)).thenReturn(termListData);
+ when(commonClassDao.getDataById(TermList.class, "termName", "Test")).thenReturn(termListData);
+ }
+
+ @Test
+ public final void testPolicyCreationController() {
+ PolicyRestController controller = new PolicyRestController();
+ BufferedReader reader = new BufferedReader(new StringReader(clRequestString));
+ try {
+ Mockito.when(request.getReader()).thenReturn(reader);
+ controller.policyCreationController(request, response);
+ } catch (IOException e) {
+ fail();
+ }
+ PolicyRestController controller1 = new PolicyRestController();
+ CreateFirewallController.setCommonClassDao(commonClassDao);
+ BufferedReader reader1 = new BufferedReader(new StringReader(fwRequestString));
+ try {
+ Mockito.when(request.getReader()).thenReturn(reader1);
+ controller1.policyCreationController(request, response);
+ } catch (IOException e) {
+ fail();
+ }
+
+ CreateFirewallController fwController = new CreateFirewallController();
+ CreateFirewallController.setCommonClassDao(commonClassDao);
+ BufferedReader reader2 = new BufferedReader(new StringReader(fwViewRequestString));
+ try {
+ Mockito.when(request.getReader()).thenReturn(reader2);
+ fwController.setFWViewRule(request, response);
+ } catch (IOException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public final void testDeleteElasticData() {
+ PolicyRestController controller = new PolicyRestController();
+ try {
+ controller.deleteElasticData("Test");
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+}
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
index 4931d20d7..f4acaeb9a 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyUserInfoControllerTest.java
@@ -41,12 +41,12 @@ public class PolicyUserInfoControllerTest {
@Before
public void setUp() throws Exception {
HttpSession mockSession = mock(HttpSession.class);
- request = mock(HttpServletRequest.class);
- response = new MockHttpServletResponse();
- User user = new User();
- user.setOrgUserId("Test");
- Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
- Mockito.when(request.getSession(false)).thenReturn(mockSession);
+ request = mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+ User user = new User();
+ user.setOrgUserId("Test");
+ Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
+ Mockito.when(request.getSession(false)).thenReturn(mockSession);
}
@Test
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 d4b0c650b..63ca29d90 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
@@ -20,9 +20,13 @@
package org.onap.policy.daoImp;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
@@ -39,9 +43,9 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.conf.HibernateSession;
import org.onap.policy.controller.PolicyController;
-import org.onap.policy.daoImp.CommonClassDaoImpl;
import org.onap.policy.rest.jpa.OnapName;
import org.onap.policy.rest.jpa.PolicyEntity;
+import org.onap.policy.rest.jpa.PolicyRoles;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.SystemLogDB;
import org.onap.policy.rest.jpa.UserInfo;
@@ -392,11 +396,49 @@ public class CommonClassDaoImplTest{
fail();
}
}
+
+ @Test
+ public void testCommonClassDaoImplMethods(){
+ try{
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ UserInfo userInfoUpdate = (UserInfo) data.get(0);
+ userInfoUpdate.setUserName("Test1");
+ commonClassDao.update(userInfoUpdate);
+ List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+ assertTrue(data1.size() == 1);
+ UserInfo data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestID:Test1");
+ assertTrue("TestID".equals(data2.getUserLoginId()));
+ List<Object> data3 = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
+ assertTrue(data3.size() == 1);
+ PolicyRoles roles = new PolicyRoles();
+ roles.setRole("admin");
+ roles.setLoginId(userInfo);
+ roles.setScope("test");
+ commonClassDao.save(roles);
+ List<PolicyRoles> roles1 = commonClassDao.getUserRoles();
+ assertTrue(roles1.size() == 1);
+ List<String> multipleData = new ArrayList<>();
+ multipleData.add("TestID:Test1");
+ List<Object> data4 = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", multipleData);
+ assertTrue(data4.size() == 1);
+ commonClassDao.delete(data2);
+ }catch(Exception e){
+ logger.debug("Exception Occured"+e);
+ fail();
+ }
+ }
+
+
@Test
public final void testGetLoggingData() {
SystemLogDbDaoImpl system = new SystemLogDbDaoImpl();
- SystemLogDbDaoImpl.setjUnit(true);
+ PolicyController.setjUnit(true);
try{
assertTrue(system.getLoggingData() != null);
}catch(Exception e){
@@ -407,7 +449,7 @@ public class CommonClassDaoImplTest{
@Test
public final void testGetSystemAlertData() {
SystemLogDbDaoImpl system = new SystemLogDbDaoImpl();
- SystemLogDbDaoImpl.setjUnit(true);
+ PolicyController.setjUnit(true);
try{
assertTrue(system.getSystemAlertData() != null);
}catch(Exception e){
diff --git a/POLICY-SDK-APP/src/test/resources/test.properties b/POLICY-SDK-APP/src/test/resources/test.properties
new file mode 100644
index 000000000..e882dfd20
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/test.properties
@@ -0,0 +1,21 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 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.
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+PDP_URL=http://localhost:8082/pdp/, testpdp, alpha456;http://localhost:8081/pdp/, testpdp, alpha456
diff --git a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
index 0f285b694..333da49a5 100644
--- a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
+++ b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
@@ -87,8 +87,8 @@ xacml.log.db.password=policy_user
xacml.att.log.timeframe=150
-javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
-javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/onap_sdk
+javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
+javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
javax.persistence.jdbc.user=policy_user
javax.persistence.jdbc.password=policy_user
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
index 25636fb45..862b654b8 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
@@ -21,37 +21,39 @@
package org.onap.policy.api;
import java.util.Map;
+
/**
* <code>LoadedPolicy</code> defines the Policy that has been Loaded into the PDP.
- *
- * @version 0.2
+ *
+ * @version 0.2
*/
public interface LoadedPolicy {
- /**
- * Gets the <code>String</code> format of the Policy Name that has been Loaded into the PDP.
- *
- * @return <code>String</code> format of Policy Name
- */
- public String getPolicyName();
-
- /**
- * Gets the <code>String</code> format of the Policy Version that has been Loaded into the PDP.
- *
- * @return <code>String</code> format of the Policy Version.
- */
- public String getVersionNo();
-
- /**
- * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config Type.
- *
- * @return the <code>Map</code> of <code>String,String</code> format of the matches in the policy.
- */
- public Map<String, String> getMatches();
-
- /**
- * Gets the <code>UpdateType</code> of {@link org.onap.policy.api.UpdateType} received.
- *
- * @return <code>UpdateType</code> associated with this <code>PDPNotification</code>
- */
- public UpdateType getUpdateType();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Name that has been Loaded into the PDP.
+ *
+ * @return <code>String</code> format of Policy Name
+ */
+ String getPolicyName();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Version that has been Loaded into the PDP.
+ *
+ * @return <code>String</code> format of the Policy Version.
+ */
+ String getVersionNo();
+
+ /**
+ * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config Type.
+ *
+ * @return the <code>Map</code> of <code>String,String</code> format of the matches in the policy.
+ */
+ Map<String, String> getMatches();
+
+ /**
+ * Gets the <code>UpdateType</code> of {@link org.onap.policy.api.UpdateType} received.
+ *
+ * @return <code>UpdateType</code> associated with this <code>PDPNotification</code>
+ */
+ UpdateType getUpdateType();
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
index 837eba967..78b79a08f 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
@@ -19,17 +19,20 @@
*/
package org.onap.policy.api;
+
/**
* Defines the methods which need to run when an Event or Notification is received.
- *
+ *
* @version 0.1
*/
@FunctionalInterface
public interface NotificationHandler {
- /**
- * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.
- *
- * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object that has information of the notification.
- */
- public void notificationReceived(PDPNotification notification);
+
+ /**
+ * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.
+ *
+ * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification}
+ * is the object that has information of the notification.
+ */
+ void notificationReceived(PDPNotification notification);
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
index 730ad022d..8b65a420d 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
@@ -23,36 +23,35 @@ package org.onap.policy.api;
/**
* Enumeration of the Update Type that has occurred in the <code>PDPNotification</code> of
* {@link org.onap.policy.api.PDPNotification}
- *
+ *
* @version 0.1
*/
public enum NotificationType {
- /**
- * Indicates that a policy has been updated
- */
- UPDATE("update"),
- /**
- * Indicates that a policy has been removed
- */
- REMOVE("remove"),
- /**
- * Indicates that both update and removal of policy events has occurred.
- */
- BOTH("both")
- ;
-
- private String name;
-
- private NotificationType(String name){
- this.name = name;
- }
-
- /**
- * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
- * @return the <code>String</code> Type of <code>UpdateType</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
+ /**
+ * Indicates that a policy has been updated
+ */
+ UPDATE("update"),
+ /**
+ * Indicates that a policy has been removed
+ */
+ REMOVE("remove"),
+ /**
+ * Indicates that both update and removal of policy events has occurred.
+ */
+ BOTH("both");
+
+ private String name;
+
+ NotificationType(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
+ * @return the <code>String</code> Type of <code>UpdateType</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
index a88ec06cb..9ab508281 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
@@ -24,29 +24,29 @@ import java.util.Collection;
/**
* Defines the <code>Notification</code> event sent from PDP to Client PEP.
- *
+ *
* @version 0.2
*/
public interface PDPNotification {
- /**
- * Gets the <code>Collection</code> of {@link org.onap.policy.api.RemovedPolicy} objects received.
- *
- * @return the <code>Collection</code> which consists of <code>RemovedPolicy</code> objects.
- */
- public Collection<RemovedPolicy> getRemovedPolicies();
-
- /**
- * Gets the <code>Collection</code> of {@link org.onap.policy.api.LoadedPolicy} objects receieved.
- *
- * @return the <code>Collection</code> which consists of <code>UpdatedPolicy</code> objects.
- */
- public Collection<LoadedPolicy> getLoadedPolicies();
-
- /**
- * Gets the <code>NotificationType</code> of {@link org.onap.policy.api.NotificationType} received.
- *
- * @return <code>NotificationType</code> associated with this <code>PDPNotification</code>
- */
- public NotificationType getNotificationType();
-
+
+ /**
+ * Gets the <code>Collection</code> of {@link org.onap.policy.api.RemovedPolicy} objects received.
+ *
+ * @return the <code>Collection</code> which consists of <code>RemovedPolicy</code> objects.
+ */
+ Collection<RemovedPolicy> getRemovedPolicies();
+
+ /**
+ * Gets the <code>Collection</code> of {@link org.onap.policy.api.LoadedPolicy} objects receieved.
+ *
+ * @return the <code>Collection</code> which consists of <code>UpdatedPolicy</code> objects.
+ */
+ Collection<LoadedPolicy> getLoadedPolicies();
+
+ /**
+ * Gets the <code>NotificationType</code> of {@link org.onap.policy.api.NotificationType} received.
+ *
+ * @return <code>NotificationType</code> associated with this <code>PDPNotification</code>
+ */
+ NotificationType getNotificationType();
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
index f26c1499a..e8125a1dc 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
@@ -19,23 +19,25 @@
*/
package org.onap.policy.api;
+
/**
* <code>RemovedPolicy</code> defines the Policy that has been removed
- *
+ *
* @version 0.1
*/
public interface RemovedPolicy {
- /**
- * Gets the <code>String</code> format of the Policy Name that has been removed.
- *
- * @return <code>String</code> format of Policy Name
- */
- public String getPolicyName();
-
- /**
- * Gets the <code>String</code> format of the Policy Version that has been removed.
- *
- * @return <code>String</code> format of Policy Version
- */
- public String getVersionNo();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Name that has been removed.
+ *
+ * @return <code>String</code> format of Policy Name
+ */
+ String getPolicyName();
+
+ /**
+ * Gets the <code>String</code> format of the Policy Version that has been removed.
+ *
+ * @return <code>String</code> format of Policy Version
+ */
+ String getVersionNo();
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
index deeecddd0..7f401fec0 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
@@ -23,32 +23,31 @@ package org.onap.policy.api;
/**
* Enumeration of the Update Type that has occurred in the <code>UpdatedPolicy</code> of
* {@link org.onap.policy.api.LoadedPolicy}
- *
+ *
* @version 0.1
*/
public enum UpdateType {
- /**
- * Indicates that a policy has been updated
- */
- UPDATE("update"),
- /**
- * Indicates that a policy is new
- */
- NEW("new")
- ;
-
- private String name;
-
- private UpdateType(String name){
- this.name = name;
- }
-
- /**
- * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
- * @return the <code>String</code> Type of <code>UpdateType</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
+ /**
+ * Indicates that a policy has been updated
+ */
+ UPDATE("update"),
+ /**
+ * Indicates that a policy is new
+ */
+ NEW("new");
+
+ private String name;
+
+ UpdateType(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
+ * @return the <code>String</code> Type of <code>UpdateType</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java b/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
index f2e7f3ff8..1bfffce6c 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
@@ -22,7 +22,6 @@ package org.onap.policy.jpa;
import java.io.Serializable;
import java.util.Date;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -38,80 +37,81 @@ import javax.persistence.TemporalType;
@Entity
-@Table(name="BackUpMonitorEntity")
-@NamedQuery(name="BackUpMonitorEntity.findAll", query= "SELECT b FROM BackUpMonitorEntity b ")
-public class BackUpMonitorEntity implements Serializable{
- private static final long serialVersionUID = -9190606334322230630L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
- private int id;
-
- @Column(name="node_name", nullable=false)
- private String resourceNodeName;
-
- @Column(name="resource_name", nullable=false, unique=true)
- private String resourceName;
-
- @Column(name="flag", nullable=false)
- private String flag;
-
- @Lob
- @Column(name="notification_record")
- private String notificationRecord;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="last_seen")
- private Date timeStamp;
-
- @PrePersist
- public void prePersist(){
- this.timeStamp = new Date();
- }
-
- @PreUpdate
- public void preUpdate(){
- this.timeStamp = new Date();
- }
-
- public String getResourceName(){
- return this.resourceName;
- }
-
- public String getResourceNodeName(){
- return this.resourceNodeName;
- }
-
- public String getFlag(){
- return this.flag;
- }
-
- public String getNotificationRecord(){
- return this.notificationRecord;
- }
-
- public Date getTimeStamp(){
- return this.timeStamp;
- }
-
- public void setResourceName(String resourceName){
- this.resourceName = resourceName;
- }
-
- public void setResoruceNodeName(String resourceNodeName){
- this.resourceNodeName = resourceNodeName;
- }
-
- public void setFlag(String flag){
- this.flag = flag;
- }
-
- public void setNotificationRecord(String notificationRecord){
- this.notificationRecord = notificationRecord;
- }
-
- public void setTimeStamp(Date timeStamp){
- this.timeStamp = timeStamp;
- }
+@Table(name = "BackUpMonitorEntity")
+@NamedQuery(name = "BackUpMonitorEntity.findAll", query = "SELECT b FROM BackUpMonitorEntity b ")
+public class BackUpMonitorEntity implements Serializable {
+
+ private static final long serialVersionUID = -9190606334322230630L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "node_name", nullable = false)
+ private String resourceNodeName;
+
+ @Column(name = "resource_name", nullable = false, unique = true)
+ private String resourceName;
+
+ @Column(name = "flag", nullable = false)
+ private String flag;
+
+ @Lob
+ @Column(name = "notification_record")
+ private String notificationRecord;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "last_seen")
+ private Date timeStamp;
+
+ @PrePersist
+ public void prePersist() {
+ this.timeStamp = new Date();
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.timeStamp = new Date();
+ }
+
+ public String getResourceName() {
+ return this.resourceName;
+ }
+
+ public String getResourceNodeName() {
+ return this.resourceNodeName;
+ }
+
+ public String getFlag() {
+ return this.flag;
+ }
+
+ public String getNotificationRecord() {
+ return this.notificationRecord;
+ }
+
+ public Date getTimeStamp() {
+ return this.timeStamp;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public void setResourceNodeName(String resourceNodeName) {
+ this.resourceNodeName = resourceNodeName;
+ }
+
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+ public void setNotificationRecord(String notificationRecord) {
+ this.notificationRecord = notificationRecord;
+ }
+
+ public void setTimeStamp(Date timeStamp) {
+ this.timeStamp = timeStamp;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
index 259a70d37..8c6c9580d 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
-
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
@@ -38,229 +37,221 @@ import org.onap.policy.api.RemovedPolicy;
*
*/
public class NotificationStore {
- private static StdPDPNotification notificationRecord = new StdPDPNotification();
-
- public static StdPDPNotification getDeltaNotification(StdPDPNotification newNotification){
- StdPDPNotification notificationDelta = new StdPDPNotification();
- ArrayList<StdRemovedPolicy> removedDelta = new ArrayList<>();
- ArrayList<StdLoadedPolicy> updatedDelta = new ArrayList<>();
- Collection<StdLoadedPolicy> newUpdatedPolicies = new ArrayList<>();
- Collection<StdRemovedPolicy> newRemovedPolicies = new ArrayList<>();
- Collection<LoadedPolicy> oldUpdatedLostPolicies = notificationRecord.getLoadedPolicies();
- Collection<RemovedPolicy> oldRemovedPolicies = notificationRecord.getRemovedPolicies();
- Collection<LoadedPolicy> oldUpdatedPolicies = notificationRecord.getLoadedPolicies();
- Boolean update = false;
- Boolean remove = false;
- // if the NotificationRecord is empty
- if(notificationRecord.getRemovedPolicies()==null || notificationRecord.getLoadedPolicies()==null){
- if(newNotification!=null){
- notificationRecord = newNotification;
- }
- return notificationDelta;
- }
- // do the Delta operation.
- if(newNotification!=null){
- // check for old removed policies.
- if(!newNotification.getRemovedPolicies().isEmpty()){
- for(RemovedPolicy newRemovedPolicy: newNotification.getRemovedPolicies()){
- //Look for policy Not in Remove
- Boolean removed = true;
- for(RemovedPolicy oldRemovedPolicy: notificationRecord.getRemovedPolicies()){
- if(newRemovedPolicy.getPolicyName().equals(oldRemovedPolicy.getPolicyName())){
- if(newRemovedPolicy.getVersionNo().equals(oldRemovedPolicy.getVersionNo())){
- removed = false;
- // Don't want a duplicate.
- oldRemovedPolicies.remove(oldRemovedPolicy);
- }
- }
- }
- //We need to change our record we have an Update record of this remove.
- for(LoadedPolicy oldUpdatedPolicy: notificationRecord.getLoadedPolicies()){
- if(newRemovedPolicy.getPolicyName().equals(oldUpdatedPolicy.getPolicyName())){
- if(newRemovedPolicy.getVersionNo().equals(oldUpdatedPolicy.getVersionNo())){
- oldUpdatedPolicies.remove(oldUpdatedPolicy);
- oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
- }
- }
- }
- if(removed){
- remove = true;
- notificationRecord.getRemovedPolicies().add(newRemovedPolicy);
- removedDelta.add((StdRemovedPolicy)newRemovedPolicy);
- }
- // This will be converted to New Later.
- oldRemovedPolicies.add(newRemovedPolicy);
- }
- }
- // Check for old Updated Policies.
- if(!newNotification.getLoadedPolicies().isEmpty()){
- for(LoadedPolicy newUpdatedPolicy: newNotification.getLoadedPolicies()){
- // Look for policies which are not in Update
- Boolean updated = true;
- for(LoadedPolicy oldUpdatedPolicy: notificationRecord.getLoadedPolicies()){
- if(newUpdatedPolicy.getPolicyName().equals(oldUpdatedPolicy.getPolicyName())){
- if(newUpdatedPolicy.getVersionNo().equals(oldUpdatedPolicy.getVersionNo())){
- updated = false;
- // Remove the policy from copy.
- oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
- // Eliminating Duplicate.
- oldUpdatedPolicies.remove(oldUpdatedPolicy);
- }
- }
- }
- // Change the record if the policy has been Removed earlier.
- for(RemovedPolicy oldRemovedPolicy: notificationRecord.getRemovedPolicies()){
- if(oldRemovedPolicy.getPolicyName().equals(newUpdatedPolicy.getPolicyName())){
- if(oldRemovedPolicy.getVersionNo().equals(newUpdatedPolicy.getVersionNo())){
- oldRemovedPolicies.remove(oldRemovedPolicy);
- }
- }
- }
- if(updated){
- update = true;
- updatedDelta.add((StdLoadedPolicy)newUpdatedPolicy);
- }
- // This will be converted to new Later
- oldUpdatedPolicies.add(newUpdatedPolicy);
- }
- // Conversion of Update to Remove if that occurred.
- if(!oldUpdatedLostPolicies.isEmpty()){
- for(LoadedPolicy updatedPolicy: oldUpdatedLostPolicies){
- StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
- removedPolicy.setPolicyName(updatedPolicy.getPolicyName());
- removedPolicy.setVersionNo(updatedPolicy.getVersionNo());
- removedDelta.add(removedPolicy);
- remove = true;
- }
- }
- }
- // Update our Record.
- if(!oldUpdatedPolicies.isEmpty()){
- for(LoadedPolicy updatedPolicy: oldUpdatedPolicies){
- newUpdatedPolicies.add((StdLoadedPolicy)updatedPolicy);
- }
- }
- if(!oldRemovedPolicies.isEmpty()){
- for(RemovedPolicy removedPolicy: oldRemovedPolicies){
- newRemovedPolicies.add((StdRemovedPolicy)removedPolicy);
- }
- }
- notificationRecord.setRemovedPolicies(newRemovedPolicies);
- notificationRecord.setLoadedPolicies(newUpdatedPolicies);
- // Update the notification Result.
- notificationDelta.setRemovedPolicies(removedDelta);
- notificationDelta.setLoadedPolicies(updatedDelta);
- if(remove&&update){
- notificationDelta.setNotificationType(NotificationType.BOTH);
- }else if(remove){
- notificationDelta.setNotificationType(NotificationType.REMOVE);
- }else if(update){
- notificationDelta.setNotificationType(NotificationType.UPDATE);
- }
- }
- return notificationDelta;
- }
-
- public static void recordNotification(StdPDPNotification notification){
- if(notification!=null){
- if(notificationRecord.getRemovedPolicies()==null || notificationRecord.getLoadedPolicies()==null){
- notificationRecord = notification;
- }else{
- // Check if there is anything new and update the record.
- if(notificationRecord.getLoadedPolicies()!=null || notificationRecord.getRemovedPolicies()!=null){
- HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
- for(RemovedPolicy rPolicy: notificationRecord.getRemovedPolicies()){
- StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
- sRPolicy.setPolicyName(rPolicy.getPolicyName());
- sRPolicy.setVersionNo(rPolicy.getVersionNo());
- removedPolicies.add(sRPolicy);
- }
- HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
- for(LoadedPolicy uPolicy: notificationRecord.getLoadedPolicies()){
- StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
- sUPolicy.setMatches(uPolicy.getMatches());
- sUPolicy.setPolicyName(uPolicy.getPolicyName());
- sUPolicy.setVersionNo(uPolicy.getVersionNo());
- sUPolicy.setUpdateType(uPolicy.getUpdateType());
- updatedPolicies.add(sUPolicy);
- }
-
- // Checking with the new updated policies.
- if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
- for(LoadedPolicy newUpdatedPolicy: notification.getLoadedPolicies()){
- // If it was removed earlier then we need to remove from our record
- Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
- while(oldRemovedPolicy.hasNext()){
- RemovedPolicy policy = oldRemovedPolicy.next();
- if(newUpdatedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newUpdatedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldRemovedPolicy.remove();
- }
- }
- }
- // If it was previously updated need to Overwrite it to the record.
- Iterator<StdLoadedPolicy> oldUpdatedPolicy = updatedPolicies.iterator();
- while(oldUpdatedPolicy.hasNext()){
- LoadedPolicy policy = oldUpdatedPolicy.next();
- if(newUpdatedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newUpdatedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldUpdatedPolicy.remove();
- }
- }
- }
- StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
- sUPolicy.setMatches(newUpdatedPolicy.getMatches());
- sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
- sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
- sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
- updatedPolicies.add(sUPolicy);
- }
- }
- // Checking with New Removed Policies.
- if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
- for(RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()){
- // If it was previously removed Overwrite it to the record.
- Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
- while(oldRemovedPolicy.hasNext()){
- RemovedPolicy policy = oldRemovedPolicy.next();
- if(newRemovedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newRemovedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldRemovedPolicy.remove();
- }
- }
- }
- // If it was added earlier then we need to remove from our record.
- Iterator<StdLoadedPolicy> oldUpdatedPolicy = updatedPolicies.iterator();
- while(oldUpdatedPolicy.hasNext()){
- LoadedPolicy policy = oldUpdatedPolicy.next();
- if(newRemovedPolicy.getPolicyName().equals(policy.getPolicyName())) {
- if(newRemovedPolicy.getVersionNo().equals(policy.getVersionNo())) {
- oldUpdatedPolicy.remove();
- }
- }
- }
- StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
- sRPolicy.setPolicyName(newRemovedPolicy.getPolicyName());
- sRPolicy.setVersionNo(newRemovedPolicy.getVersionNo());
- removedPolicies.add(sRPolicy);
- }
- }
- notificationRecord.setRemovedPolicies(removedPolicies);
- notificationRecord.setLoadedPolicies(updatedPolicies);
- }
- if(!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies().isEmpty()){
- notificationRecord.setNotificationType(NotificationType.BOTH);
- }else if(!notificationRecord.getLoadedPolicies().isEmpty()){
- notificationRecord.setNotificationType(NotificationType.UPDATE);
- }else if(!notificationRecord.getRemovedPolicies().isEmpty()){
- notificationRecord.setNotificationType(NotificationType.REMOVE);
- }
- }
- }
- }
-
- // This should return the current Notification Record.
- public static PDPNotification getNotificationRecord(){
- return notificationRecord;
- }
+
+ private static StdPDPNotification notificationRecord = new StdPDPNotification();
+
+ public static StdPDPNotification getDeltaNotification(StdPDPNotification newNotification) {
+ StdPDPNotification notificationDelta = new StdPDPNotification();
+ ArrayList<StdRemovedPolicy> removedDelta = new ArrayList<>();
+ ArrayList<StdLoadedPolicy> updatedDelta = new ArrayList<>();
+ Collection<StdLoadedPolicy> newUpdatedPolicies = new ArrayList<>();
+ Collection<StdRemovedPolicy> newRemovedPolicies = new ArrayList<>();
+ Collection<LoadedPolicy> oldUpdatedLostPolicies = notificationRecord.getLoadedPolicies();
+ Collection<RemovedPolicy> oldRemovedPolicies = notificationRecord.getRemovedPolicies();
+ Collection<LoadedPolicy> oldUpdatedPolicies = notificationRecord.getLoadedPolicies();
+ Boolean update = false;
+ Boolean remove = false;
+ // if the NotificationRecord is empty
+ if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
+ if (newNotification != null) {
+ notificationRecord = newNotification;
+ }
+ return notificationDelta;
+ }
+ // do the Delta operation.
+ if (newNotification != null) {
+ // check for old removed policies.
+ if (!newNotification.getRemovedPolicies().isEmpty()) {
+ for (RemovedPolicy newRemovedPolicy : newNotification.getRemovedPolicies()) {
+ //Look for policy Not in Remove
+ Boolean removed = true;
+ String policyName = newRemovedPolicy.getPolicyName();
+ String ver = newRemovedPolicy.getVersionNo();
+ for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
+ if (policyName.equals(oldRemovedPolicy.getPolicyName())
+ && ver.equals(oldRemovedPolicy.getVersionNo())) {
+ removed = false;
+ // Don't want a duplicate.
+ oldRemovedPolicies.remove(oldRemovedPolicy);
+ }
+ }
+ //We need to change our record we have an Update record of this remove.
+ for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
+ if (policyName.equals(oldUpdatedPolicy.getPolicyName())
+ && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+ oldUpdatedPolicies.remove(oldUpdatedPolicy);
+ oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
+ }
+ }
+ if (removed) {
+ remove = true;
+ notificationRecord.getRemovedPolicies().add(newRemovedPolicy);
+ removedDelta.add((StdRemovedPolicy) newRemovedPolicy);
+ }
+ // This will be converted to New Later.
+ oldRemovedPolicies.add(newRemovedPolicy);
+ }
+ }
+ // Check for old Updated Policies.
+ if (!newNotification.getLoadedPolicies().isEmpty()) {
+ for (LoadedPolicy newUpdatedPolicy : newNotification.getLoadedPolicies()) {
+ // Look for policies which are not in Update
+ Boolean updated = true;
+ String policyName = newUpdatedPolicy.getPolicyName();
+ String ver = newUpdatedPolicy.getVersionNo();
+ for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
+ if (policyName.equals(oldUpdatedPolicy.getPolicyName())
+ && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+ updated = false;
+ // Remove the policy from copy.
+ oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
+ // Eliminating Duplicate.
+ oldUpdatedPolicies.remove(oldUpdatedPolicy);
+ }
+ }
+ // Change the record if the policy has been Removed earlier.
+ for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
+ if (oldRemovedPolicy.getPolicyName().equals(policyName)
+ && oldRemovedPolicy.getVersionNo().equals(ver)) {
+ oldRemovedPolicies.remove(oldRemovedPolicy);
+ }
+ }
+ if (updated) {
+ update = true;
+ updatedDelta.add((StdLoadedPolicy) newUpdatedPolicy);
+ }
+ // This will be converted to new Later
+ oldUpdatedPolicies.add(newUpdatedPolicy);
+ }
+ // Conversion of Update to Remove if that occurred.
+ if (!oldUpdatedLostPolicies.isEmpty()) {
+ for (LoadedPolicy updatedPolicy : oldUpdatedLostPolicies) {
+ StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
+ removedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+ removedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+ removedDelta.add(removedPolicy);
+ remove = true;
+ }
+ }
+ }
+ // Update our Record.
+ if (!oldUpdatedPolicies.isEmpty()) {
+ for (LoadedPolicy updatedPolicy : oldUpdatedPolicies) {
+ newUpdatedPolicies.add((StdLoadedPolicy) updatedPolicy);
+ }
+ }
+ if (!oldRemovedPolicies.isEmpty()) {
+ for (RemovedPolicy removedPolicy : oldRemovedPolicies) {
+ newRemovedPolicies.add((StdRemovedPolicy) removedPolicy);
+ }
+ }
+ notificationRecord.setRemovedPolicies(newRemovedPolicies);
+ notificationRecord.setLoadedPolicies(newUpdatedPolicies);
+ // Update the notification Result.
+ notificationDelta.setRemovedPolicies(removedDelta);
+ notificationDelta.setLoadedPolicies(updatedDelta);
+ if (remove && update) {
+ notificationDelta.setNotificationType(NotificationType.BOTH);
+ } else if (remove) {
+ notificationDelta.setNotificationType(NotificationType.REMOVE);
+ } else if (update) {
+ notificationDelta.setNotificationType(NotificationType.UPDATE);
+ }
+ }
+ return notificationDelta;
+ }
+
+ public static void recordNotification(StdPDPNotification notification) {
+ if (notification != null) {
+ if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
+ notificationRecord = notification;
+ } else {
+ // Check if there is anything new and update the record.
+ if (notificationRecord.getLoadedPolicies() != null || notificationRecord.getRemovedPolicies() != null) {
+ HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
+ for (RemovedPolicy rPolicy : notificationRecord.getRemovedPolicies()) {
+ StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
+ sRPolicy.setPolicyName(rPolicy.getPolicyName());
+ sRPolicy.setVersionNo(rPolicy.getVersionNo());
+ removedPolicies.add(sRPolicy);
+ }
+ HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
+ for (LoadedPolicy uPolicy : notificationRecord.getLoadedPolicies()) {
+ StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
+ sUPolicy.setMatches(uPolicy.getMatches());
+ sUPolicy.setPolicyName(uPolicy.getPolicyName());
+ sUPolicy.setVersionNo(uPolicy.getVersionNo());
+ sUPolicy.setUpdateType(uPolicy.getUpdateType());
+ updatedPolicies.add(sUPolicy);
+ }
+
+ // Checking with the new updated policies.
+ if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+ for (LoadedPolicy newUpdatedPolicy : notification.getLoadedPolicies()) {
+ // If it was removed earlier then we need to remove from our record
+ Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
+ String policyName = newUpdatedPolicy.getPolicyName();
+ String ver = newUpdatedPolicy.getVersionNo();
+ while (oldRemovedPolicy.hasNext()) {
+ RemovedPolicy policy = oldRemovedPolicy.next();
+ if (policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo())) {
+ oldRemovedPolicy.remove();
+ }
+ }
+ // If it was previously updated need to Overwrite it to the record.
+ updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo()));
+
+ StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
+ sUPolicy.setMatches(newUpdatedPolicy.getMatches());
+ sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
+ sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
+ sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
+ updatedPolicies.add(sUPolicy);
+ }
+ }
+ // Checking with New Removed Policies.
+ if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+ for (RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()) {
+ // If it was previously removed Overwrite it to the record.
+ Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
+ String policyName = newRemovedPolicy.getPolicyName();
+ String ver = newRemovedPolicy.getVersionNo();
+ while (oldRemovedPolicy.hasNext()) {
+ RemovedPolicy policy = oldRemovedPolicy.next();
+ if (policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo())) {
+ oldRemovedPolicy.remove();
+ }
+ }
+ // If it was added earlier then we need to remove from our record.
+ updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
+ && ver.equals(policy.getVersionNo()));
+
+ StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
+ sRPolicy.setPolicyName(policyName);
+ sRPolicy.setVersionNo(ver);
+ removedPolicies.add(sRPolicy);
+ }
+ }
+ notificationRecord.setRemovedPolicies(removedPolicies);
+ notificationRecord.setLoadedPolicies(updatedPolicies);
+ }
+ if (!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies()
+ .isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.BOTH);
+ } else if (!notificationRecord.getLoadedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.UPDATE);
+ } else if (!notificationRecord.getRemovedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.REMOVE);
+ }
+ }
+ }
+ }
+
+ // This should return the current Notification Record.
+ public static PDPNotification getNotificationRecord() {
+ return notificationRecord;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
index fe7807185..1640fe8db 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
@@ -22,59 +22,53 @@ package org.onap.policy.std;
import java.util.Collection;
import java.util.HashSet;
-
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.api.RemovedPolicy;
-public class StdPDPNotification implements PDPNotification{
- private Collection<StdRemovedPolicy> removedPolicies = null;
- private Collection<StdLoadedPolicy> loadedPolicies = null;
- private Collection<RemovedPolicy> removed = null;
- private Collection<LoadedPolicy> updated = null;
- private NotificationType notificationType= null;
-
- @Override
- public Collection<RemovedPolicy> getRemovedPolicies() {
- removed = new HashSet<RemovedPolicy>();
- if(removedPolicies!=null){
- for(RemovedPolicy removedPolicy: removedPolicies){
- removed.add(removedPolicy);
- }
- return this.removed;
- }else{
- return null;
- }
- }
+public class StdPDPNotification implements PDPNotification {
+
+ private Collection<StdRemovedPolicy> removedPolicies = null;
+ private Collection<StdLoadedPolicy> loadedPolicies = null;
+ private Collection<RemovedPolicy> removed = null;
+ private Collection<LoadedPolicy> updated = null;
+ private NotificationType notificationType = null;
+
+ @Override
+ public Collection<RemovedPolicy> getRemovedPolicies() {
+ removed = new HashSet<>();
+ if (removedPolicies != null) {
+ removed.addAll(removedPolicies);
+ return this.removed;
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<LoadedPolicy> getLoadedPolicies() {
+ updated = new HashSet<>();
+ if (loadedPolicies != null) {
+ updated.addAll(loadedPolicies);
+ return updated;
+ }
+ return null;
+ }
+
+ @Override
+ public NotificationType getNotificationType() {
+ return notificationType;
+ }
- @Override
- public Collection<LoadedPolicy> getLoadedPolicies() {
- updated = new HashSet<LoadedPolicy>();
- if(loadedPolicies!=null){
- for(LoadedPolicy updatedPolicy: loadedPolicies){
- updated.add(updatedPolicy);
- }
- return updated;
- }else{
- return null;
- }
- }
+ public void setNotificationType(NotificationType notificationType) {
+ this.notificationType = notificationType;
+ }
- @Override
- public NotificationType getNotificationType() {
- return notificationType;
- }
+ public void setLoadedPolicies(Collection<StdLoadedPolicy> loadedPolicies) {
+ this.loadedPolicies = loadedPolicies;
+ }
- public void setNotificationType(NotificationType notificationType){
- this.notificationType= notificationType;
- }
-
- public void setLoadedPolicies(Collection<StdLoadedPolicy> loadedPolicies) {
- this.loadedPolicies = loadedPolicies;
- }
-
- public void setRemovedPolicies(Collection<StdRemovedPolicy> removedPolicies) {
- this.removedPolicies = removedPolicies;
- }
+ public void setRemovedPolicies(Collection<StdRemovedPolicy> removedPolicies) {
+ this.removedPolicies = removedPolicies;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
index 3cdb51577..9aab2ad45 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
@@ -248,7 +248,7 @@ public class BackUpMonitor {
// This is New. create an entry as Master.
LOGGER.info("Adding resource " + resourceName + " to Database");
BackUpMonitorEntity bMEntity = new BackUpMonitorEntity();
- bMEntity.setResoruceNodeName(resourceNodeName);
+ bMEntity.setResourceNodeName(resourceNodeName);
bMEntity.setResourceName(resourceName);
bMEntity = setMaster(bMEntity);
bMEntity.setTimeStamp(new Date());
@@ -297,7 +297,7 @@ public class BackUpMonitor {
} else {
// Resource name is null -> No resource with same name.
selfEntity = new BackUpMonitorEntity();
- selfEntity.setResoruceNodeName(resourceNodeName);
+ selfEntity.setResourceNodeName(resourceNodeName);
selfEntity.setResourceName(resourceName);
selfEntity.setTimeStamp(new Date());
selfEntity = setSlave(selfEntity);
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
index afc3d0dce..39434a7e7 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
@@ -61,8 +61,8 @@ public class testBackUpMonitor {
@Test (expected = PersistenceException.class)
public void backUpMonitorTestFail() throws Exception{
Properties properties = new Properties();
- properties.setProperty("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
- properties.setProperty("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xacml");
+ properties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ properties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/onap_sdk");
properties.setProperty("javax.persistence.jdbc.user", "policy_user");
properties.setProperty("javax.persistence.jdbc.password", "");
BackUpMonitor.getInstance(BackUpMonitor.ResourceNode.BRMS.toString(), "brms_test" , properties, new Handler());
@@ -71,8 +71,8 @@ public class testBackUpMonitor {
@Test
public void backUpMonitorTestFailNoUser() throws Exception{
Properties properties = new Properties();
- properties.setProperty("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
- properties.setProperty("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xacml");
+ properties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ properties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/onap_sdk");
properties.setProperty("javax.persistence.jdbc.user", "");
properties.setProperty("javax.persistence.jdbc.password", "password");
BackUpMonitor bum = BackUpMonitor.getInstance(BackUpMonitor.ResourceNode.BRMS.toString(), "brms_test" , properties, new Handler());
@@ -82,7 +82,7 @@ public class testBackUpMonitor {
@Test
public void backUpMonitorTestFailNoURL() throws Exception{
Properties properties = new Properties();
- properties.setProperty("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
+ properties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
properties.setProperty("javax.persistence.jdbc.url", "");
properties.setProperty("javax.persistence.jdbc.user", "test");
properties.setProperty("javax.persistence.jdbc.password", "password");
@@ -95,7 +95,7 @@ public class testBackUpMonitor {
public void backUpMonitorTestFailNoDriver() throws Exception{
Properties properties = new Properties();
properties.setProperty("javax.persistence.jdbc.driver", "");
- properties.setProperty("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xacml");
+ properties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/onap_sdk");
properties.setProperty("javax.persistence.jdbc.user", "test");
properties.setProperty("javax.persistence.jdbc.password", "password");
properties.setProperty("ping_interval", "500");
@@ -106,8 +106,8 @@ public class testBackUpMonitor {
@Test
public void backUpMonitorTestFailNoNode() throws Exception{
Properties properties = new Properties();
- properties.setProperty("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
- properties.setProperty("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xacml");
+ properties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ properties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/onap_sdk");
properties.setProperty("javax.persistence.jdbc.user", "test");
properties.setProperty("javax.persistence.jdbc.password", "password");
properties.setProperty("ping_interval", "");
@@ -118,8 +118,8 @@ public class testBackUpMonitor {
@Test
public void backUpMonitorTestFailNoResource() throws Exception{
Properties properties = new Properties();
- properties.setProperty("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
- properties.setProperty("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xacml");
+ properties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ properties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/onap_sdk");
properties.setProperty("javax.persistence.jdbc.user", "test");
properties.setProperty("javax.persistence.jdbc.password", "password");
BackUpMonitor bum = BackUpMonitor.getInstance(BackUpMonitor.ResourceNode.BRMS.toString(), null , properties, new Handler());
@@ -135,8 +135,8 @@ public class testBackUpMonitor {
@Test
public void backUpMonitorTestFailNoHandler() throws Exception{
Properties properties = new Properties();
- properties.setProperty("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
- properties.setProperty("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xacml");
+ properties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ properties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/onap_sdk");
properties.setProperty("javax.persistence.jdbc.user", "test");
properties.setProperty("javax.persistence.jdbc.password", "password");
properties.setProperty("ping_interval", "500");
@@ -252,7 +252,7 @@ public class testBackUpMonitor {
origBM.setFlag("SLAVE");
origBM.setTimeStamp(new Date());
BackUpMonitorEntity bMEntity = new BackUpMonitorEntity();
- bMEntity.setResoruceNodeName(ResourceNode.BRMS.toString());
+ bMEntity.setResourceNodeName(ResourceNode.BRMS.toString());
bMEntity.setResourceName("brms_test2");
bMEntity.setFlag("MASTER");
bMEntity.setTimeStamp(new Date());
diff --git a/packages/install/src/files/base.conf b/packages/install/src/files/base.conf
index 92c6d9015..cd08d4a41 100644
--- a/packages/install/src/files/base.conf
+++ b/packages/install/src/files/base.conf
@@ -2,9 +2,9 @@ JAVA_HOME=/usr/lib/jvm/java-8-oracle
POLICY_HOME=/opt/app/policy
KEYSTORE_PASSWD=PolicyR0ck$
-JDBC_DRIVER=com.mysql.jdbc.Driver
-JDBC_URL=jdbc:mysql://localhost:3306/xacml
-JDBC_LOG_URL=jdbc:mysql://localhost:3306/log
+JDBC_DRIVER=org.mariadb.jdbc.Driver
+JDBC_URL=jdbc:mariadb://localhost:3306/onap_sdk
+JDBC_LOG_URL=jdbc:mariadb://localhost:3306/log
JDBC_USER=policy_user
JDBC_PASSWORD=
diff --git a/pom.xml b/pom.xml
index 96cc5015d..c615114d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>0.1.1</version>
<relativePath/>
</parent>