aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java11
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java15
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java17
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java7
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java16
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java15
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java15
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java15
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java17
9 files changed, 56 insertions, 72 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 863eda146..74d06369a 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
@@ -33,6 +33,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.Test;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
@@ -53,10 +54,12 @@ public class EntityTest {
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", "");
+ // @formatter:off
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "sa");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "");
+ // @formatter:on
daoParameters.setJdbcProperties(jdbcProperties);
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
index 3b3716846..ee9c76b98 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -76,16 +77,12 @@ public class PdpProviderTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
- jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
+ jdbcProperties.setProperty(PersistenceUnitProperties.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");
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
daoParameters.setJdbcProperties(jdbcProperties );
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index 475e5769d..cd7b7f38e 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -29,6 +29,7 @@ import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.DaoParameters;
@@ -66,14 +67,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPfDao.class);
- // Constants for persistence properties
- // @formatter:off
- private static final String JAVAX_PERSISTENCE_JDBC_DRIVER = "javax.persistence.jdbc.driver";
- private static final String JAVAX_PERSISTENCE_JDBC_URL = "javax.persistence.jdbc.url";
- private static final String JAVAX_PERSISTENCE_JDBC_USER = "javax.persistence.jdbc.user";
- private static final String JAVAX_PERSISTENCE_JDBC_PWORD = "javax.persistence.jdbc.password";
- // @formatter:on
-
private final PolicyModelsProviderParameters parameters;
// Database connection and the DAO for reading and writing Policy Framework concepts
@@ -109,10 +102,10 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
// @formatter:off
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_DRIVER, parameters.getDatabaseDriver());
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_URL, parameters.getDatabaseUrl());
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_USER, parameters.getDatabaseUser());
- jdbcProperties.setProperty(JAVAX_PERSISTENCE_JDBC_PWORD, decodedPassword);
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, parameters.getDatabaseDriver());
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, parameters.getDatabaseUrl());
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, parameters.getDatabaseUser());
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, decodedPassword);
// @formatter:on
daoParameters.setJdbcProperties(jdbcProperties);
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 2f3f89c0a..51771ff9a 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
@@ -63,5 +63,12 @@ public class PolicyModelsProviderParametersTest {
pars.setPersistenceUnit("WileECoyote");
result = pars.validate();
assertTrue(result.isValid());
+
+ pars.setDatabaseDriver(null);
+ result = pars.validate();
+ assertFalse(result.isValid());
+ pars.setDatabaseDriver("MichaelsShumacher");
+ result = pars.validate();
+ assertTrue(result.isValid());
}
}
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 175ea2093..5ad314ae6 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
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -67,16 +68,12 @@ public class AuthorativeToscaProviderPolicyTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
- jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
+ jdbcProperties.setProperty(PersistenceUnitProperties.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");
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
daoParameters.setJdbcProperties(jdbcProperties );
@@ -95,7 +92,6 @@ public class AuthorativeToscaProviderPolicyTest {
@After
public void teardown() throws Exception {
pfDao.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 ec1b34778..6a925bcf3 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
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.ObjectUtils;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -87,16 +88,12 @@ public class AuthorativeToscaProviderPolicyTypeTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
- jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
+ jdbcProperties.setProperty(PersistenceUnitProperties.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");
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
daoParameters.setJdbcProperties(jdbcProperties );
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 076064c91..71254ec6f 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
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.Map;
import java.util.Properties;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -63,16 +64,12 @@ public class LegacyProvider4LegacyGuardTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
- jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
+ jdbcProperties.setProperty(PersistenceUnitProperties.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");
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
daoParameters.setJdbcProperties(jdbcProperties);
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 cc1f51566..c018aae7b 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
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.Properties;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -59,16 +60,12 @@ public class LegacyProvider4LegacyOperationalTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
- jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
+ jdbcProperties.setProperty(PersistenceUnitProperties.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");
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
daoParameters.setJdbcProperties(jdbcProperties );
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 4ed4c5cf7..1f582cf84 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
@@ -28,6 +28,7 @@ import static org.junit.Assert.fail;
import java.util.Properties;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -66,18 +67,14 @@ public class SimpleToscaProviderTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
- jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // H2
- jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
- jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+ // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.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 );
+ daoParameters.setJdbcProperties(jdbcProperties);
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);