aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java4
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java2
-rw-r--r--models-dao/src/test/resources/META-INF/persistence.xml3
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java10
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java10
-rw-r--r--models-pdp/src/test/resources/META-INF/persistence.xml3
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java86
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java12
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java13
-rw-r--r--models-provider/src/test/resources/META-INF/persistence.xml3
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java12
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java10
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java10
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java10
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java12
-rw-r--r--models-tosca/src/test/resources/META-INF/persistence.xml3
16 files changed, 169 insertions, 34 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
index 1a29c8b01..8be1126af 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
@@ -50,7 +50,7 @@ public class PfReferenceTimestampKey extends PfKey {
private static final String TIMESTAMP_TOKEN = "timeStamp";
- @Column(name = TIMESTAMP_TOKEN)
+ @Column(name = TIMESTAMP_TOKEN, precision = 3)
@Temporal(TemporalType.TIMESTAMP)
@NotNull
private Date timeStamp;
@@ -214,6 +214,7 @@ public class PfReferenceTimestampKey extends PfKey {
*
* @return the pfReferenceTimestamp key
*/
+ @Override
public PfReferenceTimestampKey getKey() {
return this;
}
@@ -222,6 +223,7 @@ public class PfReferenceTimestampKey extends PfKey {
* Get the key as a string.
* @return pfReferenceTimestamp key.
*/
+ @Override
public String getId() {
return getReferenceKey().getId() + ':' + getTimeStamp().getTime();
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
index 6e2271846..1f5dc654a 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
@@ -51,7 +51,7 @@ public class PfTimestampKey extends PfKeyImpl {
@Pattern(regexp = VERSION_REGEXP)
private String version;
- @Column(name = TIMESTAMP_TOKEN)
+ @Column(name = TIMESTAMP_TOKEN, precision = 3)
@Temporal(TemporalType.TIMESTAMP)
@NonNull
private Date timeStamp;
diff --git a/models-dao/src/test/resources/META-INF/persistence.xml b/models-dao/src/test/resources/META-INF/persistence.xml
index 04b2c5b44..3d1f4ff27 100644
--- a/models-dao/src/test/resources/META-INF/persistence.xml
+++ b/models-dao/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2020 Nordix Foundation.
+ Copyright (C) 2019-2021 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
<class>org.onap.policy.models.dao.DummyTimestampEntity</class>
<properties>
+ <property name="eclipselink.target-database" value="MySQL" />
<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" />
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 aadaf3500..f6fe90d49 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
@@ -98,9 +98,13 @@ public class PdpProviderTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
+ }
daoParameters.setJdbcProperties(jdbcProperties);
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java
index a418f81cf..724bb3c56 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java
@@ -74,9 +74,13 @@ public class PdpStatisticsProviderTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
+ }
daoParameters.setJdbcProperties(jdbcProperties);
diff --git a/models-pdp/src/test/resources/META-INF/persistence.xml b/models-pdp/src/test/resources/META-INF/persistence.xml
index 878998422..65380642a 100644
--- a/models-pdp/src/test/resources/META-INF/persistence.xml
+++ b/models-pdp/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019 Nordix Foundation.
+ Copyright (C) 2019, 2021 Nordix Foundation.
Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,6 +38,7 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
<properties>
+ <property name="eclipselink.target-database" value="MySQL" />
<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" />
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java
new file mode 100644
index 000000000..160eeabb0
--- /dev/null
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.provider.impl;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import java.time.Instant;
+import java.util.Arrays;
+import org.junit.Test;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+
+/**
+ * Test persistence of PDP statistics to and from the database.
+ */
+public class PolicyStatisticsPersistenceTest {
+
+ @Test
+ public void testPdpStatiscticsPersistence() throws PfModelException {
+ // Try the test on three providers
+ for (int i = 0; i < 3; i++) {
+ PolicyModelsProvider databaseProvider = setupProvider();
+ testPdpStatiscticsPersistenceOneProvider(databaseProvider);
+ databaseProvider.close();
+ }
+ }
+
+ public void testPdpStatiscticsPersistenceOneProvider(PolicyModelsProvider databaseProvider) {
+ PdpStatistics pdpStatistics = new PdpStatistics();
+ pdpStatistics.setPdpInstanceId("TheInstance");
+ pdpStatistics.setTimeStamp(Instant.now());
+
+ // Try creating three identical statistics instances
+ for (int i = 0; i < 3; i++) {
+ assertThatCode(() -> databaseProvider.createPdpStatistics(Arrays.asList(pdpStatistics)))
+ .doesNotThrowAnyException();
+ }
+
+ // Try creating three statistics instances with timestams incremented
+ for (int i = 0; i < 3; i++) {
+ pdpStatistics.setTimeStamp(pdpStatistics.getTimeStamp().plusSeconds(1));
+
+ assertThatCode(() -> databaseProvider.createPdpStatistics(Arrays.asList(pdpStatistics)))
+ .doesNotThrowAnyException();
+ }
+ }
+
+ private PolicyModelsProvider setupProvider() throws PfModelException {
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+
+ if (System.getProperty("USE-MARIADB") != null) {
+ parameters.setDatabaseDriver("org.mariadb.jdbc.Driver");
+ parameters.setDatabaseUrl("jdbc:mariadb://localhost:3306/policy");
+ } else {
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ }
+
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword("P01icY");
+ parameters.setPersistenceUnit("ToscaConceptTest");
+
+ return new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ }
+}
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 ac62569b3..2c07091c7 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
@@ -76,12 +76,20 @@ public class PolicyToscaPersistenceTest {
// H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseDriver("org.h2.Driver");
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+
+ if (System.getProperty("USE-MARIADB") != null) {
+ parameters.setDatabaseDriver("org.mariadb.jdbc.Driver");
+ parameters.setDatabaseUrl("jdbc:mariadb://localhost:3306/policy");
+ } else {
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ }
+
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword("P01icY");
parameters.setPersistenceUnit("ToscaConceptTest");
+
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
createPolicyTypes();
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 61bf13ac6..2a7d83438 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,8 +61,15 @@ public class PolicyTypePersistenceTest {
// H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseDriver("org.h2.Driver");
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+
+ if (System.getProperty("USE-MARIADB") != null) {
+ parameters.setDatabaseDriver("org.mariadb.jdbc.Driver");
+ parameters.setDatabaseUrl("jdbc:mariadb://localhost:3306/policy");
+ } else {
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ }
+
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword("P01icY");
parameters.setPersistenceUnit("ToscaConceptTest");
diff --git a/models-provider/src/test/resources/META-INF/persistence.xml b/models-provider/src/test/resources/META-INF/persistence.xml
index d9e1b5fbf..249b29aae 100644
--- a/models-provider/src/test/resources/META-INF/persistence.xml
+++ b/models-provider/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2020 Nordix Foundation.
+ Copyright (C) 2019-2021 Nordix Foundation.
Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -57,6 +57,7 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
<properties>
+ <property name="eclipselink.target-database" value="MySQL" />
<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" />
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java
index dc0115486..9ca6ee8bb 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,9 +88,13 @@ public class AuthorativeToscaProviderGenericTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ 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/authorative/provider/AuthorativeToscaProviderPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
index 0f9adf89a..8cfa1617b 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
@@ -81,9 +81,13 @@ public class AuthorativeToscaProviderPolicyTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ 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/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
index 088e8e847..6cf1765f6 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
@@ -92,9 +92,13 @@ public class AuthorativeToscaProviderPolicyTypeTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ 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 07624aeee..2e8015834 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
@@ -87,9 +87,13 @@ public class SimpleToscaProviderTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ 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/SimpleToscaServiceTemplateProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java
index 9157e6643..be1c15c60 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,9 +69,13 @@ public class SimpleToscaServiceTemplateProviderTest {
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
- // 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");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ 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/resources/META-INF/persistence.xml b/models-tosca/src/test/resources/META-INF/persistence.xml
index d6ebf4eb5..5c65fc59b 100644
--- a/models-tosca/src/test/resources/META-INF/persistence.xml
+++ b/models-tosca/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2020 Nordix Foundation.
+ Copyright (C) 2019-2021 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -51,6 +51,7 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
<properties>
+ <property name="eclipselink.target-database" value="MySQL" />
<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" />