Fix centos build issue 30/90730/2
authorJim Hahn <jrh3@att.com>
Mon, 1 Jul 2019 14:11:35 +0000 (10:11 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 1 Jul 2019 14:20:46 +0000 (14:20 +0000)
Seeing this when trying to build in centos:
  10:04:12 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0,
    Time elapsed: 0.459 s - in
    org.onap.policy.pap.ia.DbAuditCompareEntriesTest
  10:04:12 [INFO]
  10:04:12 [INFO] Results:
  10:04:12 [INFO]
  10:04:12 [ERROR] Failures:
  10:04:12 [ERROR]   XACMLPAPTest.testDummy:907
  10:04:12 [ERROR] Errors:
  10:04:12 [ERROR]   XACMLPAPTest.getDictionary:886 ยป NullPointer
...

Modified the junit test(s) to create the JPA entities needed
by integrity audit, which is what was causing the above issues.

Change-Id: I405798a1946d377770529a99210a1cc57390667f
Issue-ID: POLICY-1737
Signed-off-by: Jim Hahn <jrh3@att.com>
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java

index aa1e569..e4da430 100644 (file)
@@ -30,6 +30,9 @@ import java.nio.file.Paths;
 import java.util.Date;
 import java.util.List;
 import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
 import javax.persistence.PersistenceException;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@@ -101,6 +104,8 @@ public class PolicyDBDaoTest {
     }
 
     public static SessionFactory setupH2DbDaoImpl(String dbName) {
+        setUpAuditDb();
+
         System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pap.properties");
         BasicDataSource dataSource = new BasicDataSource();
         dataSource.setDriverClassName("org.h2.Driver");
@@ -152,6 +157,17 @@ public class PolicyDBDaoTest {
     }
 
 
+    private static void setUpAuditDb() {
+        Properties properties = new Properties();
+        properties.put(XACMLRestProperties.PROP_PAP_DB_DRIVER,"org.h2.Driver");
+        properties.put(XACMLRestProperties.PROP_PAP_DB_URL, "jdbc:h2:file:./sql/xacmlTest");
+        properties.put(XACMLRestProperties.PROP_PAP_DB_USER, "sa");
+        properties.put(XACMLRestProperties.PROP_PAP_DB_PASSWORD, "");
+
+        // create the DB and then close it
+        Persistence.createEntityManagerFactory("testPapPU", properties).close();
+    }
+
     @Test
     public void testGetConfigFile() {
         PolicyRestAdapter pra = new PolicyRestAdapter();

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use