aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BRMSGateway/config.properties4
-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/xacml.pap.properties4
-rw-r--r--ONAP-PDP-REST/pom.xml4
-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/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--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/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/test/java/org/onap/policy/utils/test/testBackUpMonitor.java24
-rw-r--r--packages/install/src/files/base.conf6
30 files changed, 535 insertions, 95 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/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/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/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/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/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/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/test/java/org/onap/policy/utils/test/testBackUpMonitor.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/testBackUpMonitor.java
index 5b3bbdff9..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");
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=