summaryrefslogtreecommitdiffstats
path: root/models-dao/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-11 15:59:47 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-11 15:59:47 +0000
commitd010fb918de5215fd5ff9219041ea11c77a4059a (patch)
tree12c8d44b160788fc07d6d921de116504823b4ff9 /models-dao/src
parent891bffd9f13177d96ad26acdfa7148d09e1d682a (diff)
Fix database properties
Issue-ID: POLICY-1095 Change-Id: I3edd70898836d3bd978643857d1ba29599b1cf6c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-dao/src')
-rw-r--r--models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java33
-rw-r--r--models-dao/src/test/resources/META-INF/persistence.xml4
2 files changed, 18 insertions, 19 deletions
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 @@
<class>org.onap.policy.models.dao.DummyReferenceEntity</class>
<properties>
- <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
- <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
- <property name="javax.persistence.jdbc.user" value="sa" />
- <property name="javax.persistence.jdbc.password" value="" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />