diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-04-11 17:42:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-11 17:42:48 +0000 |
commit | ad2f809ab6e723a79d633aacc2239b17e010e843 (patch) | |
tree | f3d70551ca7ee36eb1961bc44ab571b1afb3b3c6 /models-dao/src | |
parent | a265448dd211ea6ff1e2f7f51574f0c1c0c078ed (diff) | |
parent | d010fb918de5215fd5ff9219041ea11c77a4059a (diff) |
Merge "Fix database properties"
Diffstat (limited to 'models-dao/src')
-rw-r--r-- | models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java | 33 | ||||
-rw-r--r-- | models-dao/src/test/resources/META-INF/persistence.xml | 4 |
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" /> |