summaryrefslogtreecommitdiffstats
path: root/models-tosca
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-11 17:42:48 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-11 17:42:48 +0000
commitad2f809ab6e723a79d633aacc2239b17e010e843 (patch)
treef3d70551ca7ee36eb1961bc44ab571b1afb3b3c6 /models-tosca
parenta265448dd211ea6ff1e2f7f51574f0c1c0c078ed (diff)
parentd010fb918de5215fd5ff9219041ea11c77a4059a (diff)
Merge "Fix database properties"
Diffstat (limited to 'models-tosca')
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java26
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java25
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java25
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java25
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java25
-rw-r--r--models-tosca/src/test/resources/META-INF/persistence.xml27
6 files changed, 77 insertions, 76 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
index a7d016bf3..175ea2093 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
@@ -25,10 +25,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.sql.Connection;
-import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
@@ -52,7 +51,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
* @author Liam Fallon (liam.fallon@est.tech)
*/
public class AuthorativeToscaProviderPolicyTest {
- private Connection connection;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -63,17 +61,25 @@ public class AuthorativeToscaProviderPolicyTest {
*/
@Before
public void setupDao() throws Exception {
- // Use the JDBC UI "jdbc:h2:mem:testdb" to test towards the h2 database
- // Use the JDBC UI "jdbc:mariadb://localhost:3306/policy" to test towards a locally installed mariadb instance
- connection = DriverManager.getConnection("jdbc:h2:mem:testdb", "policy", "P01icY");
-
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
- // Use the persistence unit ToscaConceptTest to test towards the h2 database
- // Use the persistence unit ToscaConceptMariaDBTest to test towards a locally installed mariadb instance
daoParameters.setPersistenceUnit("ToscaConceptTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+
+ // H2
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+
+ // MariaDB
+ //jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ //jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+
+ daoParameters.setJdbcProperties(jdbcProperties );
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
}
@@ -89,7 +95,7 @@ public class AuthorativeToscaProviderPolicyTest {
@After
public void teardown() throws Exception {
pfDao.close();
- connection.close();
+ //connection.close();
}
@Test
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
index 7dc4a9497..ec1b34778 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
@@ -26,10 +26,9 @@ import static org.junit.Assert.assertNotNull;
import com.google.gson.GsonBuilder;
-import java.sql.Connection;
-import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.apache.commons.lang3.ObjectUtils;
import org.junit.After;
@@ -57,7 +56,6 @@ import org.yaml.snakeyaml.Yaml;
*/
public class AuthorativeToscaProviderPolicyTypeTest {
private static String yamlAsJsonString;
- private Connection connection;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -83,17 +81,25 @@ public class AuthorativeToscaProviderPolicyTypeTest {
*/
@Before
public void setupDao() throws Exception {
- // Use the JDBC UI "jdbc:h2:mem:testdb" to test towards the h2 database
- // Use the JDBC UI "jdbc:mariadb://localhost:3306/policy" to test towards a locally installed mariadb instance
- connection = DriverManager.getConnection("jdbc:h2:mem:testdb", "policy", "P01icY");
-
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
- // Use the persistence unit ToscaConceptTest to test towards the h2 database
- // Use the persistence unit ToscaConceptMariaDBTest to test towards a locally installed mariadb instance
daoParameters.setPersistenceUnit("ToscaConceptTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+
+ // H2
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+
+ // MariaDB
+ //jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ //jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+
+ daoParameters.setJdbcProperties(jdbcProperties );
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
}
@@ -109,7 +115,6 @@ public class AuthorativeToscaProviderPolicyTypeTest {
@After
public void teardown() throws Exception {
pfDao.close();
- connection.close();
}
@Test
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java
index 2fdc3aae7..076064c91 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java
@@ -24,9 +24,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.sql.Connection;
-import java.sql.DriverManager;
import java.util.Map;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
@@ -47,7 +46,6 @@ import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
* @author Liam Fallon (liam.fallon@est.tech)
*/
public class LegacyProvider4LegacyGuardTest {
- private Connection connection;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -59,17 +57,25 @@ public class LegacyProvider4LegacyGuardTest {
*/
@Before
public void setupDao() throws Exception {
- // Use the JDBC UI "jdbc:h2:mem:testdb" to test towards the h2 database
- // Use the JDBC UI "jdbc:mariadb://localhost:3306/policy" to test towards a locally installed mariadb instance
- connection = DriverManager.getConnection("jdbc:h2:mem:testdb", "policy", "P01icY");
-
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
- // Use the persistence unit ToscaConceptTest to test towards the h2 database
- // Use the persistence unit ToscaConceptMariaDBTest to test towards a locally installed mariadb instance
daoParameters.setPersistenceUnit("ToscaConceptTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+
+ // H2
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+
+ // MariaDB
+ //jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ //jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+
+ daoParameters.setJdbcProperties(jdbcProperties);
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
}
@@ -85,7 +91,6 @@ public class LegacyProvider4LegacyGuardTest {
@After
public void teardown() throws Exception {
pfDao.close();
- connection.close();
}
@Test
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java
index d198bd4f5..cc1f51566 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java
@@ -24,8 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.sql.Connection;
-import java.sql.DriverManager;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
@@ -44,7 +43,6 @@ import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
* @author Liam Fallon (liam.fallon@est.tech)
*/
public class LegacyProvider4LegacyOperationalTest {
- private Connection connection;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -55,17 +53,25 @@ public class LegacyProvider4LegacyOperationalTest {
*/
@Before
public void setupDao() throws Exception {
- // Use the JDBC UI "jdbc:h2:mem:testdb" to test towards the h2 database
- // Use the JDBC UI "jdbc:mariadb://localhost:3306/policy" to test towards a locally installed mariadb instance
- connection = DriverManager.getConnection("jdbc:h2:mem:testdb", "policy", "P01icY");
-
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
- // Use the persistence unit ToscaConceptTest to test towards the h2 database
- // Use the persistence unit ToscaConceptMariaDBTest to test towards a locally installed mariadb instance
daoParameters.setPersistenceUnit("ToscaConceptTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+
+ // H2
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+
+ // MariaDB
+ //jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ //jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+
+ daoParameters.setJdbcProperties(jdbcProperties );
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
}
@@ -81,7 +87,6 @@ public class LegacyProvider4LegacyOperationalTest {
@After
public void teardown() throws Exception {
pfDao.close();
- connection.close();
}
@Test
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
index ddfb5676a..4ed4c5cf7 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
@@ -26,8 +26,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.sql.Connection;
-import java.sql.DriverManager;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
@@ -51,7 +50,6 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate;
* @author Liam Fallon (liam.fallon@est.tech)
*/
public class SimpleToscaProviderTest {
- private Connection connection;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -62,17 +60,25 @@ public class SimpleToscaProviderTest {
*/
@Before
public void setupDao() throws Exception {
- // Use the JDBC UI "jdbc:h2:mem:testdb" to test towards the h2 database
- // Use the JDBC UI "jdbc:mariadb://localhost:3306/policy" to test towards a locally installed mariadb instance
- connection = DriverManager.getConnection("jdbc:h2:mem:testdb", "policy", "P01icY");
-
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
- // Use the persistence unit ToscaConceptTest to test towards the h2 database
- // Use the persistence unit ToscaConceptMariaDBTest to test towards a locally installed mariadb instance
daoParameters.setPersistenceUnit("ToscaConceptTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+
+ // H2
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+
+ // MariaDB
+ //jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ //jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+
+ daoParameters.setJdbcProperties(jdbcProperties );
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
}
@@ -88,7 +94,6 @@ public class SimpleToscaProviderTest {
@After
public void teardown() throws Exception {
pfDao.close();
- connection.close();
}
@Test
diff --git a/models-tosca/src/test/resources/META-INF/persistence.xml b/models-tosca/src/test/resources/META-INF/persistence.xml
index 23e8567f1..936e5a11c 100644
--- a/models-tosca/src/test/resources/META-INF/persistence.xml
+++ b/models-tosca/src/test/resources/META-INF/persistence.xml
@@ -26,34 +26,13 @@
<class>org.onap.policy.models.dao.converters.CDataConditioner</class>
<class>org.onap.policy.models.dao.converters.Uuid2String</class>
<class>org.onap.policy.models.base.PfConceptKey</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</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="policy" />
- <property name="javax.persistence.jdbc.password" value="P01icY" />
<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" />
- </properties>
- </persistence-unit>
-
- <persistence-unit name="ToscaConceptMariaDBTest" transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
- <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
- <class>org.onap.policy.models.dao.converters.Uuid2String</class>
- <class>org.onap.policy.models.base.PfConceptKey</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
-
- <properties>
- <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
- <property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/policy" />
- <property name="javax.persistence.jdbc.user" value="policy" />
- <property name="javax.persistence.jdbc.password" value="P01icY" />
- <property name="javax.persistence.schema-generation.database.action" value="create" />
<!-- property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.logging.level.jpa" value="ALL" />
@@ -65,10 +44,6 @@
<property name="eclipselink.logging.level.server" value="ALL" />
<property name="eclipselink.logging.level.query" value="ALL" />
<property name="eclipselink.logging.level.properties" value="ALL" /-->
-
- <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" />
</properties>
</persistence-unit>
</persistence>