summaryrefslogtreecommitdiffstats
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/concepts/JpaPdpGroupTest.java59
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java39
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java38
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java15
-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-sim/models-sim-dmaap/src/main/resources/etc/ssl/policy-keystorebin4431 -> 0 bytes
-rw-r--r--models-sim/packages/models-simulator-tarball/src/main/resources/ssl/policy-keystorebin4431 -> 0 bytes
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/resources/ssl/policy-keystorebin4431 -> 0 bytes
-rw-r--r--models-sim/policy-models-simulators/src/main/resources/ssl/policy-keystorebin4431 -> 0 bytes
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java15
-rw-r--r--models-sim/policy-models-simulators/src/test/resources/keystore-testbin3895 -> 0 bytes
-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
25 files changed, 306 insertions, 53 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/concepts/JpaPdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java
index a4bf25209..060f650fb 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -95,21 +95,17 @@ public class JpaPdpGroupTest {
assertNotNull(new JpaPdpGroup((new PfConceptKey())));
assertNotNull(new JpaPdpGroup((new JpaPdpGroup())));
+ }
+ @Test
+ public void testPdpGroupSet() {
PdpGroup testPdpGroup = new PdpGroup();
testPdpGroup.setName(PDP_GROUP0);
testPdpGroup.setPdpSubgroups(new ArrayList<>());
- JpaPdpGroup testJpaPdpGroup = new JpaPdpGroup();
- testJpaPdpGroup.setKey(null);
- testJpaPdpGroup.setKey(new PfConceptKey());
-
- testPdpGroup.setVersion(VERSION);
- testJpaPdpGroup.fromAuthorative(testPdpGroup);
+ JpaPdpGroup testJpaPdpGroup = setUpSmallJpaPdpGroup();
assertEquals(PDP_GROUP0, testJpaPdpGroup.getKey().getName());
- testJpaPdpGroup.setKey(PfConceptKey.getNullKey());
- testJpaPdpGroup.fromAuthorative(testPdpGroup);
assertThatThrownBy(() -> {
testJpaPdpGroup.fromAuthorative(null);
@@ -126,6 +122,11 @@ public class JpaPdpGroupTest {
testJpaPdpGroup.clean();
assertEquals(PDP_GROUP0, testJpaPdpGroup.getKey().getName());
+ }
+
+ @Test
+ public void testPdpGroupValidation() {
+ JpaPdpGroup testJpaPdpGroup = setUpSmallJpaPdpGroup();
assertThatThrownBy(() -> {
testJpaPdpGroup.validate(null);
@@ -158,6 +159,11 @@ public class JpaPdpGroupTest {
assertFalse(testJpaPdpGroup.validate("").isValid());
testJpaPdpGroup.getProperties().remove("NullKey");
assertTrue(testJpaPdpGroup.validate("").isValid());
+ }
+
+ @Test
+ public void testPdpSubgroups() {
+ JpaPdpGroup testJpaPdpGroup = setUpJpaPdpGroup();
List<JpaPdpSubGroup> jpaPdpSubgroups = testJpaPdpGroup.getPdpSubGroups();
assertNotNull(jpaPdpSubgroups);
@@ -212,8 +218,12 @@ public class JpaPdpGroupTest {
psg = testJpaPdpGroup.toAuthorative();
assertNull(psg.getProperties());
testJpaPdpGroup.setProperties(new LinkedHashMap<>());
+ }
+
+ @Test
+ public void testPdpGroupsProperties() {
+ JpaPdpGroup testJpaPdpGroup = setUpJpaPdpGroup();
- testJpaPdpGroup.clean();
testJpaPdpGroup.getProperties().put(" PropKey ", " Prop Value ");
testJpaPdpGroup.clean();
assertEquals("PropKey", testJpaPdpGroup.getProperties().keySet().iterator().next());
@@ -222,6 +232,9 @@ public class JpaPdpGroupTest {
testJpaPdpGroup.clean();
assertEquals("A Description", testJpaPdpGroup.getDescription());
+ JpaPdpSubGroup anotherPdpSubgroup =
+ new JpaPdpSubGroup(new PfReferenceKey(testJpaPdpGroup.getKey(), "AnotherPdpSubgroup"));
+
assertEquals(1, testJpaPdpGroup.getKeys().size());
testJpaPdpGroup.getPdpSubGroups().add(anotherPdpSubgroup);
assertEquals(2, testJpaPdpGroup.getKeys().size());
@@ -230,4 +243,30 @@ public class JpaPdpGroupTest {
assertEquals(testJpaPdpGroup, new JpaPdpGroup(testJpaPdpGroup));
}
+
+ private JpaPdpGroup setUpSmallJpaPdpGroup() {
+ PdpGroup testPdpGroup = new PdpGroup();
+ testPdpGroup.setName(PDP_GROUP0);
+ testPdpGroup.setPdpSubgroups(new ArrayList<>());
+ testPdpGroup.setVersion(VERSION);
+
+ JpaPdpGroup testJpaPdpGroup = new JpaPdpGroup();
+ testJpaPdpGroup.setKey(new PfConceptKey(PDP_GROUP0, VERSION));
+ testJpaPdpGroup.fromAuthorative(testPdpGroup);
+ testJpaPdpGroup.clean();
+
+ return testJpaPdpGroup;
+ }
+
+ private JpaPdpGroup setUpJpaPdpGroup() {
+ JpaPdpGroup testJpaPdpGroup = setUpSmallJpaPdpGroup();
+
+ testJpaPdpGroup.setKey(new PfConceptKey("PdpGroup0", VERSION));
+ testJpaPdpGroup.setDescription(null);
+ testJpaPdpGroup.setPdpGroupState(PdpState.PASSIVE);
+ testJpaPdpGroup.setProperties(new LinkedHashMap<>());
+ testJpaPdpGroup.clean();
+
+ return testJpaPdpGroup;
+ }
}
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
index 969b59c6d..566de0d98 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,7 +52,7 @@ public class JpaPdpSubGroupTest {
private static final String PDP_A = "PDP-A";
@Test
- public void testJpaPdpSubGroup() {
+ public void testJpaPdpSubGroupErrors() {
assertThatThrownBy(() -> {
new JpaPdpSubGroup((JpaPdpSubGroup) null);
}).hasMessageMatching("copyConcept is marked .*ull but is null");
@@ -114,7 +114,10 @@ public class JpaPdpSubGroupTest {
}).hasMessageMatching(NULL_KEY_ERROR);
assertNotNull(new JpaPdpSubGroup((new PfReferenceKey())));
+ }
+ @Test
+ public void testJpaPdpSubGroup() {
PdpSubGroup testPdpSubgroup = new PdpSubGroup();
testPdpSubgroup.setPdpType(PDP_A);
JpaPdpSubGroup testJpaPdpSubGroup = new JpaPdpSubGroup();
@@ -154,6 +157,11 @@ public class JpaPdpSubGroupTest {
testJpaPdpSubGroup.setSupportedPolicyTypes(new ArrayList<>());
testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfSearchableKey("APolicyType:1.0.0"));
assertTrue(testJpaPdpSubGroup.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaPdpSubGroupSavedKey() {
+ JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup();
PfReferenceKey savedKey = testJpaPdpSubGroup.getKey();
testJpaPdpSubGroup.setKey(PfReferenceKey.getNullKey());
@@ -185,6 +193,11 @@ public class JpaPdpSubGroupTest {
assertTrue(testJpaPdpSubGroup.validate("").isValid());
testJpaPdpSubGroup.setProperties(null);
assertTrue(testJpaPdpSubGroup.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaPdpSubGroupPolicyTypes() {
+ JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup();
List<PfSearchableKey> supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes();
assertNotNull(supportedPolicyTypes);
@@ -212,6 +225,11 @@ public class JpaPdpSubGroupTest {
assertTrue(testJpaPdpSubGroup.validate("").isValid());
testJpaPdpSubGroup.setPdpInstances(pdpInstances);
assertTrue(testJpaPdpSubGroup.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaPdpSubGroupKeys() {
+ JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup();
JpaPdpSubGroup otherJpaPdpSubGroup = new JpaPdpSubGroup(testJpaPdpSubGroup);
assertEquals(0, testJpaPdpSubGroup.compareTo(otherJpaPdpSubGroup));
@@ -278,4 +296,21 @@ public class JpaPdpSubGroupTest {
assertEquals(testJpaPdpSubGroup, new JpaPdpSubGroup(testJpaPdpSubGroup));
}
+
+ private JpaPdpSubGroup setUpJpaPdpSubGroup() {
+ PdpSubGroup testPdpSubgroup = new PdpSubGroup();
+ testPdpSubgroup.setPdpType(PDP_A);
+ JpaPdpSubGroup testJpaPdpSubGroup = new JpaPdpSubGroup();
+ testJpaPdpSubGroup.setKey(PfReferenceKey.getNullKey());
+ testJpaPdpSubGroup.fromAuthorative(testPdpSubgroup);
+ testJpaPdpSubGroup.getKey().setParentConceptKey(new PfConceptKey("Parent:1.0.0"));
+ testJpaPdpSubGroup.setProperties(new LinkedHashMap<>());
+ testJpaPdpSubGroup.setDesiredInstanceCount(0);
+ testJpaPdpSubGroup.setCurrentInstanceCount(0);
+ testJpaPdpSubGroup.setProperties(null);
+ testJpaPdpSubGroup.setSupportedPolicyTypes(new ArrayList<>());
+ testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfSearchableKey("APolicyType:1.0.0"));
+ testJpaPdpSubGroup.clean();
+ return testJpaPdpSubGroup;
+ }
}
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java
index 3102c5098..b5b29d30b 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -87,7 +87,10 @@ public class JpaPdpTest {
}).hasMessageMatching("authorativeConcept is marked .*ull but is null");
assertNotNull(new JpaPdp((new PfReferenceKey())));
+ }
+ @Test
+ public void testJpaPdpInstace() {
Pdp testPdp = new Pdp();
testPdp.setInstanceId(PDP1);
JpaPdp testJpaPdp = new JpaPdp();
@@ -113,6 +116,15 @@ public class JpaPdpTest {
testJpaPdp.setMessage(" A Message ");
testJpaPdp.clean();
assertEquals("A Message", testJpaPdp.getMessage());
+ }
+
+ @Test
+ public void testJpaPdpValidation() {
+ Pdp testPdp = new Pdp();
+ testPdp.setInstanceId(PDP1);
+ JpaPdp testJpaPdp = new JpaPdp();
+ testJpaPdp.setKey(PfReferenceKey.getNullKey());
+ testJpaPdp.fromAuthorative(testPdp);
assertThatThrownBy(() -> {
testJpaPdp.validate(null);
@@ -142,6 +154,11 @@ public class JpaPdpTest {
testJpaPdp.setHealthy(PdpHealthStatus.HEALTHY);
assertTrue(testJpaPdp.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaPdpValidationSwapKey() {
+ JpaPdp testJpaPdp = setUpJpaPdp();
PfReferenceKey savedKey = testJpaPdp.getKey();
testJpaPdp.setKey(PfReferenceKey.getNullKey());
@@ -155,6 +172,11 @@ public class JpaPdpTest {
assertFalse(testJpaPdp.validate("").isValid());
testJpaPdp.setMessage("Valid Message");
assertTrue(testJpaPdp.validate("").isValid());
+ }
+
+ @Test
+ public void testJpaPdpCompare() {
+ JpaPdp testJpaPdp = setUpJpaPdp();
JpaPdp otherJpaPdp = new JpaPdp(testJpaPdp);
assertEquals(0, testJpaPdp.compareTo(otherJpaPdp));
@@ -184,4 +206,18 @@ public class JpaPdpTest {
assertEquals(testJpaPdp, new JpaPdp(testJpaPdp));
}
+
+ private JpaPdp setUpJpaPdp() {
+ Pdp testPdp = new Pdp();
+ testPdp.setInstanceId(PDP1);
+ JpaPdp testJpaPdp = new JpaPdp();
+ testJpaPdp.setKey(PfReferenceKey.getNullKey());
+ testJpaPdp.fromAuthorative(testPdp);
+ testJpaPdp.getKey().setParentConceptKey(new PfConceptKey("Parent:1.0.0"));
+ testJpaPdp.getKey().setParentLocalName("ParentLocal");
+ testJpaPdp.setPdpState(PdpState.ACTIVE);
+ testJpaPdp.setHealthy(PdpHealthStatus.HEALTHY);
+ testJpaPdp.setMessage("Valid Message");
+ return testJpaPdp;
+ }
}
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..63f46816d 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);
@@ -519,7 +523,7 @@ public class PdpProviderTest {
}
@Test
- public void testUpdatePdpStatistics() throws PfModelException {
+ public void testUpdatePdpStatisticsDao() throws PfModelException {
assertThatThrownBy(() -> {
new PdpProvider().updatePdpStatistics(null, null, null, null, null);
}).hasMessageMatching(DAO_IS_NULL);
@@ -583,7 +587,10 @@ public class PdpProviderTest {
assertThatThrownBy(() -> {
new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", new PdpStatistics());
}).hasMessageMatching(DAO_IS_NULL);
+ }
+ @Test
+ public void testUpdatePdpStatisticsGroup() throws PfModelException {
assertThatThrownBy(() -> {
new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null);
}).hasMessageMatching(GROUP_IS_NULL);
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-sim/models-sim-dmaap/src/main/resources/etc/ssl/policy-keystore b/models-sim/models-sim-dmaap/src/main/resources/etc/ssl/policy-keystore
deleted file mode 100644
index b95e01031..000000000
--- a/models-sim/models-sim-dmaap/src/main/resources/etc/ssl/policy-keystore
+++ /dev/null
Binary files differ
diff --git a/models-sim/packages/models-simulator-tarball/src/main/resources/ssl/policy-keystore b/models-sim/packages/models-simulator-tarball/src/main/resources/ssl/policy-keystore
deleted file mode 100644
index b95e01031..000000000
--- a/models-sim/packages/models-simulator-tarball/src/main/resources/ssl/policy-keystore
+++ /dev/null
Binary files differ
diff --git a/models-sim/policy-models-sim-pdp/src/main/resources/ssl/policy-keystore b/models-sim/policy-models-sim-pdp/src/main/resources/ssl/policy-keystore
deleted file mode 100644
index b95e01031..000000000
--- a/models-sim/policy-models-sim-pdp/src/main/resources/ssl/policy-keystore
+++ /dev/null
Binary files differ
diff --git a/models-sim/policy-models-simulators/src/main/resources/ssl/policy-keystore b/models-sim/policy-models-simulators/src/main/resources/ssl/policy-keystore
deleted file mode 100644
index b95e01031..000000000
--- a/models-sim/policy-models-simulators/src/main/resources/ssl/policy-keystore
+++ /dev/null
Binary files differ
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
index bb4fa7c5a..e1517f3a8 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -52,6 +53,7 @@ import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.security.SelfSignedKeyStore;
public class MainTest {
private static final String PARAMETER_FILE = "simParameters.json";
@@ -64,7 +66,7 @@ public class MainTest {
* Saves system properties.
*/
@BeforeClass
- public static void setUpBeforeClass() {
+ public static void setUpBeforeClass() throws IOException, InterruptedException {
savedValues = new HashMap<>();
for (String prop : List.of(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
@@ -75,11 +77,14 @@ public class MainTest {
savedValues.put(prop, System.getProperty(prop));
}
- System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
- System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, "kstest");
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, new SelfSignedKeyStore().getKeystoreName());
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
+ SelfSignedKeyStore.KEYSTORE_PASSWORD);
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, "kstest");
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME,
+ "src/main/resources/ssl/policy-truststore");
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME,
+ SelfSignedKeyStore.KEYSTORE_PASSWORD);
}
/**
diff --git a/models-sim/policy-models-simulators/src/test/resources/keystore-test b/models-sim/policy-models-simulators/src/test/resources/keystore-test
deleted file mode 100644
index 5820e0f0c..000000000
--- a/models-sim/policy-models-simulators/src/test/resources/keystore-test
+++ /dev/null
Binary files differ
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 a322e0610..d537c0685 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 69c1839c8..6e39dc872 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" />