From d010fb918de5215fd5ff9219041ea11c77a4059a Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 11 Apr 2019 15:59:47 +0000 Subject: Fix database properties Issue-ID: POLICY-1095 Change-Id: I3edd70898836d3bd978643857d1ba29599b1cf6c Signed-off-by: liamfallon --- .../org/onap/policy/models/dao/EntityTest.java | 33 ++++++++++++---------- .../src/test/resources/META-INF/persistence.xml | 4 --- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'models-dao') diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java index 4bf39a059..863eda146 100644 --- a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java +++ b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java @@ -26,16 +26,13 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.sql.Connection; -import java.sql.DriverManager; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.UUID; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; @@ -49,23 +46,20 @@ import org.onap.policy.models.dao.impl.DefaultPfDao; * JUnit test class. */ public class EntityTest { - private Connection connection; private PfDao pfDao; - @Before - public void setup() throws Exception { - connection = DriverManager.getConnection("jdbc:h2:mem:test"); - } - - @After - public void teardown() throws Exception { - connection.close(); - } - @Test public void testEntityTestSanity() throws PfModelException { final DaoParameters daoParameters = new DaoParameters(); + Properties jdbcProperties = new Properties(); + jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver"); + jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb"); + jdbcProperties.setProperty("javax.persistence.jdbc.user", "sa"); + jdbcProperties.setProperty("javax.persistence.jdbc.password", ""); + + daoParameters.setJdbcProperties(jdbcProperties); + pfDao = new PfDaoFactory().createPfDao(daoParameters); try { @@ -101,10 +95,19 @@ public class EntityTest { @Test public void testEntityTestAllOpsJpa() throws PfModelException { + final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName()); daoParameters.setPersistenceUnit("DaoTest"); + Properties jdbcProperties = new Properties(); + jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver"); + jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb"); + jdbcProperties.setProperty("javax.persistence.jdbc.user", "sa"); + jdbcProperties.setProperty("javax.persistence.jdbc.password", ""); + + daoParameters.setJdbcProperties(jdbcProperties); + pfDao = new PfDaoFactory().createPfDao(daoParameters); pfDao.init(daoParameters); diff --git a/models-dao/src/test/resources/META-INF/persistence.xml b/models-dao/src/test/resources/META-INF/persistence.xml index 25858caba..5314ebbdb 100644 --- a/models-dao/src/test/resources/META-INF/persistence.xml +++ b/models-dao/src/test/resources/META-INF/persistence.xml @@ -30,10 +30,6 @@ org.onap.policy.models.dao.DummyReferenceEntity - - - - -- cgit 1.2.3-korg