From 86554962a34c4e7c16821f91a12242a4ffb36368 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 1 Jul 2019 10:11:35 -0400 Subject: [PATCH] Fix centos build issue MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../pap/xacml/rest/components/PolicyDBDaoTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java index aa1e56988..e4da430a5 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java @@ -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(); -- 2.16.6