aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider/src/test
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-provider/src/test
parent891bffd9f13177d96ad26acdfa7148d09e1d682a (diff)
Fix database properties
Issue-ID: POLICY-1095 Change-Id: I3edd70898836d3bd978643857d1ba29599b1cf6c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider/src/test')
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java1
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java26
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java1
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java1
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java1
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java1
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java1
-rw-r--r--models-provider/src/test/resources/META-INF/persistence.xml29
8 files changed, 13 insertions, 48 deletions
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
index 626d2bf5d..2f3f89c0a 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
@@ -36,6 +36,7 @@ public class PolicyModelsProviderParametersTest {
@Test
public void testParameters() {
PolicyModelsProviderParameters pars = new PolicyModelsProviderParameters();
+ pars.setDatabaseDriver("MichaelsShumacher");
pars.setDatabaseUrl("jdbc://www.acmecorp/roadrunner");
pars.setPersistenceUnit("WileECoyote");
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 99358c4c6..ff8dfe322 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -66,11 +66,11 @@ public class DatabasePolicyModelsProviderTest {
@Before
public void setupParameters() {
parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
parameters.setPersistenceUnit("ToscaConceptTest");
-
}
@Test
@@ -84,27 +84,21 @@ public class DatabasePolicyModelsProviderTest {
parameters.setDatabaseUrl("jdbc://www.acmecorp.nonexist");
- assertThatThrownBy(() -> {
- databaseProvider.close();
- databaseProvider.init();
- }).hasMessage("could not connect to database with URL \"jdbc://www.acmecorp.nonexist\"");
-
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
-
try {
- databaseProvider.init();
databaseProvider.close();
+ databaseProvider.init();
} catch (Exception pfme) {
fail("test shold not throw an exception here");
}
+ databaseProvider.close();
+
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setPersistenceUnit("WileECoyote");
- String errorMessage = "could not create Data Access Object (DAO) using url "
- + "\"jdbc:h2:mem:testdb\" and persistence unit \"WileECoyote\"";
assertThatThrownBy(() -> {
databaseProvider.init();
- }).hasMessage(errorMessage);
+ }).hasMessageContaining("could not create Data Access Object (DAO)");
parameters.setPersistenceUnit("ToscaConceptTest");
@@ -112,6 +106,7 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.init();
databaseProvider.close();
} catch (Exception pfme) {
+ pfme.printStackTrace();
fail("test shold not throw an exception here");
}
@@ -131,13 +126,6 @@ public class DatabasePolicyModelsProviderTest {
} catch (Exception pfme) {
fail("test shold not throw an exception here");
}
-
- assertThatThrownBy(() -> {
- DatabasePolicyModelsProviderImpl databaseProviderImpl = (DatabasePolicyModelsProviderImpl) databaseProvider;
- databaseProvider.init();
- databaseProviderImpl.setConnection(new DummyConnection());
- databaseProvider.close();
- }).hasMessage("could not close connection to database with URL \"jdbc:h2:mem:testdb\"");
}
@Test
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java
index 5ebb44814..741ae8998 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java
@@ -76,6 +76,7 @@ public class PolicyLegacyGuardPersistenceTest {
@Before
public void setupParameters() throws PfModelException {
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java
index af6c4a4cc..2e33a11a0 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java
@@ -76,6 +76,7 @@ public class PolicyLegacyOperationalPersistenceTest {
@Before
public void setupParameters() throws PfModelException {
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
index 81795dbda..668f63497 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyPersistenceTest.java
@@ -85,6 +85,7 @@ public class PolicyPersistenceTest {
@Before
public void setupParameters() throws PfModelException {
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
index 8f05244b9..613c5a2c6 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
@@ -83,6 +83,7 @@ public class PolicyToscaPersistenceTest {
@Before
public void setupParameters() throws PfModelException {
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
index 528395efc..7b541e128 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
@@ -84,6 +84,7 @@ public class PolicyTypePersistenceTest {
@Before
public void setupParameters() throws PfModelException {
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
diff --git a/models-provider/src/test/resources/META-INF/persistence.xml b/models-provider/src/test/resources/META-INF/persistence.xml
index c7d6d1e4b..7b5bc14b9 100644
--- a/models-provider/src/test/resources/META-INF/persistence.xml
+++ b/models-provider/src/test/resources/META-INF/persistence.xml
@@ -33,34 +33,9 @@
<class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</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.JpaToscaPolicyType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</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" />
@@ -72,10 +47,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>