diff options
Diffstat (limited to 'models-tosca/src/test/java/org')
5 files changed, 76 insertions, 50 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 |