aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java2
-rw-r--r--BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java34
-rw-r--r--BRMSGateway/src/test/resources/META-INF/persistenceBRMStest.xml1
-rw-r--r--BRMSGateway/src/test/resources/config.properties2
4 files changed, 36 insertions, 3 deletions
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
index 033c78df7..4466afe3c 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
@@ -120,7 +120,7 @@ public class BrmsPush {
private static final String[] GOALS = { "clean", "deploy" };
private static final String DEFAULT_VERSION = "1.4.0-SNAPSHOT";
private static final String DEPENDENCY_FILE = "dependency.json";
- private static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml";
+ public static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml";
private static Map<String, String> modifiedGroups = new HashMap<>();
private static IntegrityMonitor im;
diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java
index 4a1b4f8d4..de1a7d6eb 100644
--- a/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java
+++ b/BRMSGateway/src/test/java/org/onap/policy/brms/BrmsPushTest.java
@@ -28,16 +28,48 @@ import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
-
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.PolicyException;
import org.onap.policy.brms.api.BrmsHandler;
+import org.onap.policy.brms.api.BrmsPush;
public class BrmsPushTest {
private static final String VALID_FILE = "src/test/resources/config.properties";
private static final String INVALID_FILE = "src/test/resources/failure.properties";
+ private static EntityManagerFactory emf;
+
+ /**
+ * Creates the test DB and keeps it open until all tests complete.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Properties props = new Properties();
+ try (FileInputStream inp = new FileInputStream(VALID_FILE)) {
+ props.load(inp);
+ }
+ props.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML,
+ props.getProperty(BrmsPush.BRMSPERSISTENCE));
+
+ emf = Persistence.createEntityManagerFactory("BRMSGW", props);
+ }
+
+ /**
+ * Closes the test DB.
+ */
+ @AfterClass
+ public static void tearDownAfterClass() {
+ emf.close();
+ }
+
@Test(expected = PolicyException.class)
public void brmsHandlerFailTest() throws PolicyException {
new BrmsHandler(null);
diff --git a/BRMSGateway/src/test/resources/META-INF/persistenceBRMStest.xml b/BRMSGateway/src/test/resources/META-INF/persistenceBRMStest.xml
index 62ae4d058..3843c427d 100644
--- a/BRMSGateway/src/test/resources/META-INF/persistenceBRMStest.xml
+++ b/BRMSGateway/src/test/resources/META-INF/persistenceBRMStest.xml
@@ -26,6 +26,7 @@
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.onap.policy.brms.entity.BrmsGroupInfo</class>
<class>org.onap.policy.brms.entity.BrmsPolicyInfo</class>
+ <class>org.onap.policy.jpa.BackUpMonitorEntity</class>
<property name="javax.persistence.schema-generation.scripts.action"
value="drop-and-create" />
<property name="javax.persistence.schema-generation.scripts.create-target"
diff --git a/BRMSGateway/src/test/resources/config.properties b/BRMSGateway/src/test/resources/config.properties
index a46357276..08fd8be40 100644
--- a/BRMSGateway/src/test/resources/config.properties
+++ b/BRMSGateway/src/test/resources/config.properties
@@ -59,7 +59,7 @@ vDNS.artifactID= policy-vDNS-rules
#database driver for Integrity Monitor
javax.persistence.jdbc.driver=org.h2.Driver
#database URL for Integrity Monitor
-javax.persistence.jdbc.url=jdbc:h2:file:./sql/xacmlTest
+javax.persistence.jdbc.url=jdbc:h2:mem:xacmlTest
#database username for Integrity Monitor
javax.persistence.jdbc.user=sa
#database password for Integrity Monitor