summaryrefslogtreecommitdiffstats
path: root/models-dao/src/test/java/org
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/test/java/org
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/test/java/org')
-rw-r--r--models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java33
1 files changed, 18 insertions, 15 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);