Merge "JUnit additions for PAP-REST,REST"
authorPamela Dragosh <pdragosh@research.att.com>
Sun, 25 Mar 2018 00:00:19 +0000 (00:00 +0000)
committerGerrit Code Review <gerrit@onap.org>
Sun, 25 Mar 2018 00:00:19 +0000 (00:00 +0000)
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
docs/platform/index.rst
docs/platform/modAmsterTemplate.rst
docs/platform/runningEclipse.rst
docs/platform/tutorial_cl.rst

index ca2b679..5208ad7 100644 (file)
@@ -35,18 +35,25 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
 import org.hibernate.SessionFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.onap.policy.common.ia.IntegrityAuditProperties;
 import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
 import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
 import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
@@ -73,8 +80,8 @@ import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
 
 import com.mockrunner.mock.web.MockServletInputStream;
 
-
 public class XACMLPAPTest {
+       private static final Log logger = LogFactory.getLog(XACMLPAPTest.class);
 
     private static final String ENVIRONMENT_HEADER = "Environment";
     private List<String> headers = new ArrayList<>();
@@ -86,6 +93,48 @@ public class XACMLPAPTest {
     private SessionFactory sessionFactory;
     private CommonClassDao commonClassDao;
 
+       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 setUpDB() throws Exception {
+               logger.info("setUpDB: Entering");
+
+               Properties properties = new Properties();
+               properties.put(IntegrityAuditProperties.DB_DRIVER, XACMLPAPTest.DEFAULT_DB_DRIVER);
+               properties.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/xacmlTest");
+               properties.put(IntegrityAuditProperties.DB_USER, XACMLPAPTest.DEFAULT_DB_USER);
+               properties.put(IntegrityAuditProperties.DB_PWD, XACMLPAPTest.DEFAULT_DB_PWD);
+               properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+               properties.put(IntegrityAuditProperties.NODE_TYPE, "pap");
+
+               //Clean the iaTest DB table for IntegrityAuditEntity entries
+               cleanDb("testPapPU", properties);
+
+               logger.info("setUpDB: Exiting");
+       }
+
+       public void cleanDb(String persistenceUnit, Properties properties){
+               logger.debug("cleanDb: enter");
+
+               EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+
+               EntityManager em = emf.createEntityManager();
+               // Start a transaction
+               EntityTransaction et = em.getTransaction();
+
+               et.begin();
+
+               // Clean up the DB
+               em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
+
+               // commit transaction
+               et.commit();
+               em.close();
+               logger.debug("cleanDb: exit");
+       }
+
     @Before
     public void setUp() throws ServletException {
         httpServletRequest = Mockito.mock(HttpServletRequest.class);
index 1bedf09..2b89ee7 100644 (file)
@@ -10,7 +10,6 @@ Policy Engine Platform
    offeredapis.rst
    installation.rst
    policygui.rst
-   modAmsterTemplate.rst
 
 Policy Software Architecture
 ----------------------------
@@ -39,8 +38,9 @@ Policy Platform Tutorials
    deployPDPPAP.rst
    guardpolicy.rst
    guardpdp.rst
-   runningEclipse.rst
    clsimulation.rst
+   modAmsterTemplate.rst
+   runningEclipse.rst
    tutorial_cl.rst
    tutorial_vDNS.rst
    tutorial_VOLTE.rst
index 690dd5d..c08dbb6 100644 (file)
@@ -2,9 +2,9 @@
 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
 .. http://creativecommons.org/licenses/by/4.0
 
-****************************************
-Modifying the Amsterdam release template 
-****************************************
+******************************
+Modifying the Release Template
+******************************
 
 .. contents::
     :depth: 3
index 4d26fda..b2bcd88 100644 (file)
@@ -44,7 +44,8 @@ An HTTP 200 message for the GET request will also appear in the console in Eclip
 
     .. image:: RunEcl_pdpd_200.png
 
-.. seealso:: To create a controller and run a control loop please refer to Modifying the Amsterdam release template.
+
+.. seealso:: To create a controller and run a control loop, refer to `Modifying the Release Template  <modAmsterTemplate.html>`_.
 
 
 End of Document
index f73bf89..3395ea7 100644 (file)
@@ -35,22 +35,17 @@ When the processing is done, you get the choice of immediately deploying the pol
 
 Proceed with testing your new policy as described in the specific tutorials:
 
-• vCPE - Tutorial: Testing the vCPE use case in a standalone PDP-D
-• vDNS - Tutorial: Testing the vDNS Use Case in a standalone PDP-D
-• vFW - Tutorial: Testing the vFW flow in a standalone PDP-D
-• VoLTE - Tutorial: Testing the VOLTE Use Case in a standalone PDP-D
-
-If you would like to deploy a control loop in Eclipse from the control loop archetype template:
-
-• Modifying the Amsterdam release template
+• vCPE - `Tutorial: Testing the vCPE use case in a standalone PDP-D <tutorial_vCPE.html>`_
+• vDNS - `Tutorial: Testing the vDNS Use Case in a standalone PDP-D <tutorial_vDNS.html>`_
+• vFW - `Tutorial: Testing the vFW flow in a standalone PDP-D <tutorial_vFW.html>`_
+• VoLTE - `Tutorial: Testing the VOLTE Use Case in a standalone PDP-D <tutorial_VOLTE.html>`_
 
 
+.. seealso:: To deploy a control loop in Eclipse from the control loop archetype template, refer to `Modifying the Release Template  <modAmsterTemplate.html>`_.
 
 
 End of Document
 
 
-
-
 .. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Tutorial%3A+Generating+and+Testing+your+own+Control+Loop+Operational+Policy+in+a+standalone+PDP-D