summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/examples-aadm/pom.xml6
-rw-r--r--examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java15
-rw-r--r--examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java15
-rw-r--r--examples/examples-aadm/src/test/resources/META-INF/persistence.xml6
-rw-r--r--examples/examples-adaptive/pom.xml6
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java15
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java15
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java15
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java15
-rw-r--r--examples/examples-adaptive/src/test/resources/META-INF/persistence.xml6
-rw-r--r--examples/examples-myfirstpolicy/pom.xml6
-rw-r--r--examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java20
-rw-r--r--examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml6
-rw-r--r--examples/examples-pcvs/pom.xml6
-rw-r--r--examples/examples-servlet/pom.xml5
-rw-r--r--examples/pom.xml9
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java18
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java17
-rw-r--r--model/basic-model/src/test/resources/META-INF/persistence.xml6
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java19
-rw-r--r--model/context-model/src/test/resources/META-INF/persistence.xml6
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java23
-rw-r--r--model/engine-model/src/test/resources/META-INF/persistence.xml6
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java17
-rw-r--r--model/event-model/src/test/resources/META-INF/persistence.xml6
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java12
-rw-r--r--model/model-api/src/test/resources/META-INF/persistence.xml8
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java23
-rw-r--r--model/policy-model/src/test/resources/META-INF/persistence.xml6
-rw-r--r--model/pom.xml17
-rw-r--r--packages/apex-pdp-package-full/pom.xml10
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml6
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml6
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java16
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java257
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java260
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java24
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml4
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/pom.xml5
-rw-r--r--pom.xml1
-rw-r--r--services/services-engine/pom.xml6
-rw-r--r--services/services-onappf/pom.xml9
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java25
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterConstants.java4
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java12
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java11
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java19
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java12
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java22
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java49
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java2
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/RestServerParameters.java52
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterAafFilter.java39
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterRestServer.java150
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java58
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckRestControllerV1.java86
-rw-r--r--services/services-onappf/src/main/resources/config/OnapPfConfig.json7
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java15
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java8
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java29
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java22
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java286
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/TestHealthCheckRestControllerV1.java62
-rw-r--r--services/services-onappf/src/test/resources/ApexStarterConfigParameters.json9
-rw-r--r--services/services-onappf/src/test/resources/TestConfigParameters.json16
-rw-r--r--services/services-onappf/src/test/resources/ssl/policy-keystorebin0 -> 4311 bytes
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextBooleanItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextByteItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateLocaleItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateTzItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDoubleItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextFloatItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextIntItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextLongItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextLongObjectItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextStringItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextTreeMapItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextTreeSetItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestExternalContextItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestGlobalContextItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestPolicyContextItem.java)2
-rw-r--r--testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java (renamed from testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/package-info.java)2
-rw-r--r--testsuites/integration/integration-context-test/pom.xml6
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java32
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java6
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java (renamed from plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java)16
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java (renamed from plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java)16
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java22
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java12
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java2
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java2
-rw-r--r--testsuites/integration/integration-executor-test/pom.xml12
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java22
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java24
-rw-r--r--testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml6
-rw-r--r--testsuites/integration/integration-uservice-test/pom.xml6
-rw-r--r--testsuites/integration/pom.xml8
-rw-r--r--testsuites/performance/performance-benchmark-test/pom.xml6
106 files changed, 1645 insertions, 554 deletions
diff --git a/examples/examples-aadm/pom.xml b/examples/examples-aadm/pom.xml
index d1a8223b5..f478119f8 100644
--- a/examples/examples-aadm/pom.xml
+++ b/examples/examples-aadm/pom.xml
@@ -53,12 +53,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java
index 1cc379938..58987533a 100644
--- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java
+++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java
@@ -20,11 +20,6 @@
package org.onap.policy.apex.examples.aadm;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
@@ -32,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AadmDbWriteTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -41,18 +35,9 @@ public class AadmDbWriteTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java
index b0aa23949..a44a4cc1a 100644
--- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java
+++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.aadm;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -35,7 +30,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AadmModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -44,18 +38,9 @@ public class AadmModelTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/examples/examples-aadm/src/test/resources/META-INF/persistence.xml b/examples/examples-aadm/src/test/resources/META-INF/persistence.xml
index eb28ad809..10a720dd7 100644
--- a/examples/examples-aadm/src/test/resources/META-INF/persistence.xml
+++ b/examples/examples-aadm/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/examples/examples-adaptive/pom.xml b/examples/examples-adaptive/pom.xml
index 1104ca932..cff709239 100644
--- a/examples/examples-adaptive/pom.xml
+++ b/examples/examples-adaptive/pom.xml
@@ -63,12 +63,6 @@
<artifactId>commons-math3</artifactId>
<version>3.2</version>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java
index 885704497..3004bccb3 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java
@@ -20,11 +20,6 @@
package org.onap.policy.apex.examples.adaptive;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
@@ -32,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AnomalyDetectionDbWriteTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -41,18 +35,9 @@ public class AnomalyDetectionDbWriteTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
index 552ca2f37..5a36d4070 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.adaptive;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -35,7 +30,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AnomalyDetectionModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -44,18 +38,9 @@ public class AnomalyDetectionModelTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java
index 828a56133..b72514f49 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java
@@ -20,11 +20,6 @@
package org.onap.policy.apex.examples.adaptive;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
@@ -32,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AutoLearnDbWriteTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -41,18 +35,9 @@ public class AutoLearnDbWriteTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAutoLearnModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
index f4cddc580..1823f9871 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.adaptive;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -35,7 +30,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AutoLearnModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -44,18 +38,9 @@ public class AutoLearnModelTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAutoLearnModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml b/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml
index 4dcd879b6..1e70abc6d 100644
--- a/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml
+++ b/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/examples/examples-myfirstpolicy/pom.xml b/examples/examples-myfirstpolicy/pom.xml
index 8ce34c027..e56a5b12b 100644
--- a/examples/examples-myfirstpolicy/pom.xml
+++ b/examples/examples-myfirstpolicy/pom.xml
@@ -69,12 +69,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java
index d6ec2bb8d..1bd67f961 100644
--- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java
+++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.myfirstpolicy;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -39,8 +34,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
* @author John Keeney (john.keeney@ericsson.com)
*/
public class MfpModelTest {
-
- private static Connection connection;
private static TestApexModel<AxPolicyModel> testApexModel1;
private static TestApexModel<AxPolicyModel> testApexModel2;
@@ -51,24 +44,11 @@ public class MfpModelTest {
*/
@BeforeClass
public static void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
testApexModel1 = new TestApexModel<>(AxPolicyModel.class, new TestMfpModelCreator.TestMfp1ModelCreator());
testApexModel2 = new TestApexModel<>(AxPolicyModel.class, new TestMfpModelCreator.TestMfp2ModelCreator());
}
/**
- * Teardown.
- *
- * @throws Exception if there is an error
- */
- @AfterClass
- public static void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
- /**
* Test model is valid.
*
* @throws Exception if there is an error
diff --git a/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml b/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml
index 7acc7a0e9..909f413eb 100644
--- a/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml
+++ b/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/examples/examples-pcvs/pom.xml b/examples/examples-pcvs/pom.xml
index 5cc65e6a1..7b5b92c77 100644
--- a/examples/examples-pcvs/pom.xml
+++ b/examples/examples-pcvs/pom.xml
@@ -71,12 +71,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-servlet/pom.xml b/examples/examples-servlet/pom.xml
index d1bd0a28c..fcf773022 100644
--- a/examples/examples-servlet/pom.xml
+++ b/examples/examples-servlet/pom.xml
@@ -56,11 +56,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>integration-common</artifactId>
<version>${project.version}</version>
diff --git a/examples/pom.xml b/examples/pom.xml
index a8dca24b2..acba94098 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -32,7 +32,6 @@
<name>${project.artifactId}</name>
<description>Specific source code and other artifacts for Apex example applications.</description>
-
<modules>
<module>examples-myfirstpolicy</module>
<module>examples-aadm</module>
@@ -44,6 +43,14 @@
<module>examples-servlet</module>
</modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<profiles>
<profile>
<id>apexSite</id>
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
index 0258b9305..36b18d783 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
@@ -26,17 +26,12 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -48,21 +43,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.DummyEntity;
* JUnit test class.
*/
public class EntityTest {
- private Connection connection;
private ApexDao apexDao;
- @Before
- public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
- }
-
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testEntityTestSanity() throws ApexException {
final DaoParameters daoParameters = new DaoParameters();
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
index a89be5477..375d15ae8 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
@@ -23,11 +23,6 @@ package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
@@ -37,28 +32,18 @@ import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
public class SupportApexBasicModelTester {
- private Connection connection;
TestApexModel<AxModel> testApexModel;
/**
* Set up the test.
- *
+ *
* @throws Exception any exception thrown by the test
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxModel>(AxModel.class, new DummyApexBasicModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/model/basic-model/src/test/resources/META-INF/persistence.xml b/model/basic-model/src/test/resources/META-INF/persistence.xml
index 68f03e8e5..01a8989bb 100644
--- a/model/basic-model/src/test/resources/META-INF/persistence.xml
+++ b/model/basic-model/src/test/resources/META-INF/persistence.xml
@@ -33,10 +33,8 @@
<class>org.onap.policy.apex.model.basicmodel.concepts.DummyEntity</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
index 948c2024c..f41c39fd2 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.model.contextmodel.handling;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -36,33 +31,23 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
/**
* Apex context model tests.
- *
+ *
* @author liam
*
*/
public class ApexContextModelTest {
- private Connection connection;
TestApexModel<AxContextModel> testApexModel;
/**
* Set up tests.
- *
+ *
* @throws Exception a testing exception
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxContextModel>(AxContextModel.class, new TestApexContextModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/model/context-model/src/test/resources/META-INF/persistence.xml b/model/context-model/src/test/resources/META-INF/persistence.xml
index b7911caa2..b4ba68a38 100644
--- a/model/context-model/src/test/resources/META-INF/persistence.xml
+++ b/model/context-model/src/test/resources/META-INF/persistence.xml
@@ -38,10 +38,8 @@
<class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
index d0b8f3e78..770c29a93 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -22,11 +22,6 @@ package org.onap.policy.apex.model.enginemodel.handling;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -35,28 +30,18 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
public class ApexEngineModelTest {
- private Connection connection;
TestApexModel<AxEngineModel> testApexModel;
/**
* Set up the test.
- *
+ *
* @throws Exception errors from test setup
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxEngineModel>(AxEngineModel.class, new DummyTestApexEngineModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/model/engine-model/src/test/resources/META-INF/persistence.xml b/model/engine-model/src/test/resources/META-INF/persistence.xml
index a157cf34f..42048d85d 100644
--- a/model/engine-model/src/test/resources/META-INF/persistence.xml
+++ b/model/engine-model/src/test/resources/META-INF/persistence.xml
@@ -59,10 +59,8 @@
<class>org.onap.policy.apex.model.enginemodel.concepts.AxEngineStats</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
index 88736d1f0..db752a61b 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.model.eventmodel.handling;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -35,28 +30,18 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.eventmodel.concepts.AxEventModel;
public class ApexEventModelTest {
- private Connection connection;
TestApexModel<AxEventModel> testApexModel;
/**
* Set up the test.
- *
+ *
* @throws Exception exceptions from the test
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxEventModel>(AxEventModel.class, new DummyTestApexEventModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/model/event-model/src/test/resources/META-INF/persistence.xml b/model/event-model/src/test/resources/META-INF/persistence.xml
index 9e61cbd73..0184cada6 100644
--- a/model/event-model/src/test/resources/META-INF/persistence.xml
+++ b/model/event-model/src/test/resources/META-INF/persistence.xml
@@ -44,10 +44,8 @@
<class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
index 462b1cd8b..df5e54ca9 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -48,14 +48,14 @@ public class ApexModelApiTest {
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
+ // Hold the h2 database up for entire tests
+ connection = DriverManager.getConnection("jdbc:h2:mem:testdb");
}
@After
public void teardown() throws Exception {
+ // Close the h2 database after tests
connection.close();
- new File("derby.log").delete();
}
@Test
diff --git a/model/model-api/src/test/resources/META-INF/persistence.xml b/model/model-api/src/test/resources/META-INF/persistence.xml
index f834e0f49..2603d5496 100644
--- a/model/model-api/src/test/resources/META-INF/persistence.xml
+++ b/model/model-api/src/test/resources/META-INF/persistence.xml
@@ -57,11 +57,9 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
- <property name="eclipselink.ddl-generation" value="create-tables" />
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />
</properties>
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index 7a240e18b..a521272ae 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -23,11 +23,6 @@ package org.onap.policy.apex.model.policymodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -36,28 +31,18 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class ApexPolicyModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
* Set up the policy model tests.
- *
+ *
* @throws Exception on setup errors
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new SupportApexPolicyModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/model/policy-model/src/test/resources/META-INF/persistence.xml b/model/policy-model/src/test/resources/META-INF/persistence.xml
index cd9a420d0..0eee729a1 100644
--- a/model/policy-model/src/test/resources/META-INF/persistence.xml
+++ b/model/policy-model/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/model/pom.xml b/model/pom.xml
index 187a043da..2ff6aa110 100644
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -32,15 +32,6 @@
<name>${project.artifactId}</name>
<description>The model for Apex, it comtains definitions of all Apex concepts and also has handling for Apex models.</description>
- <dependencies>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
<modules>
<module>utilities</module>
<module>basic-model</module>
@@ -51,6 +42,14 @@
<module>model-api</module>
</modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<profiles>
<profile>
<id>apexSite</id>
diff --git a/packages/apex-pdp-package-full/pom.xml b/packages/apex-pdp-package-full/pom.xml
index 078088bad..4897cbe8d 100644
--- a/packages/apex-pdp-package-full/pom.xml
+++ b/packages/apex-pdp-package-full/pom.xml
@@ -135,11 +135,6 @@
<artifactId>plugins-persistence-jpa-eclipselink</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence.plugins-persistence-jpa</groupId>
- <artifactId>plugins-persistence-jpa-hibernate</artifactId>
- <version>${project.version}</version>
- </dependency>
<!-- Plugins for event carrier technologies -->
<dependency>
@@ -213,11 +208,6 @@
<!-- Test Data used by examples -->
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>integration-common</artifactId>
<version>${project.version}</version>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml
index 28b822553..582ef1c71 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/pom.xml
@@ -35,12 +35,6 @@
<artifactId>hazelcast</artifactId>
<version>${version.hazelcast}</version>
</dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml
index 5cfdc2e18..b01b955c4 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/pom.xml
@@ -41,12 +41,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
index 0459cd75c..6aa42291f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/pom.xml
@@ -53,12 +53,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<scope>test</scope>
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java
index 21b58f878..311af8257 100644
--- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -32,16 +32,16 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.apex.context.test.entities.ArtifactKeyTestEntity;
-import org.onap.policy.apex.context.test.entities.ReferenceKeyTestEntity;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
+import org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ArtifactKeyTestEntity;
+import org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ReferenceKeyTestEntity;
/**
* Junit tests for class EclipselinkApexDao.
- *
+ *
* @author Dinh Danh Le (dinh.danh.le@ericsson.com)
*
*/
@@ -57,7 +57,7 @@ public class EclipselinkApexDaoTest {
/**
* Setup the tests.
- *
+ *
* @throws ApexException Exceptions from test setup
*/
@Before
@@ -192,7 +192,7 @@ public class EclipselinkApexDaoTest {
new AxReferenceKey(owner0Key, "Entity02"),
new AxReferenceKey(owner0Key, "Entity03")
});
-
+
// prepare 2 more AxReferenceKeys corresponding to owner1Key
final AxReferenceKey refKey11 = new AxReferenceKey(owner1Key, "Entity11");
final AxReferenceKey refKey12 = new AxReferenceKey(owner1Key, "Entity12");
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java
new file mode 100644
index 000000000..cd0d7d16d
--- /dev/null
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java
@@ -0,0 +1,257 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.plugins.persistence.jpa.eclipselink.entities;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+
+/**
+ * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
+ */
+@Entity
+@Table(name = "ArtifactKeyTestEntity")
+public class ArtifactKeyTestEntity extends AxConcept {
+ private static final long serialVersionUID = -2962570563281067896L;
+
+ @EmbeddedId()
+ @XmlElement(name = "key", required = true)
+ protected AxArtifactKey key;
+
+ private double doubleValue;
+
+ /**
+ * Instantiates a new artifact key test entity.
+ */
+ public ArtifactKeyTestEntity() {
+ this.key = new AxArtifactKey();
+ this.doubleValue = 0;
+ }
+
+ /**
+ * Instantiates a new artifact key test entity.
+ *
+ * @param doubleValue the double value
+ */
+ public ArtifactKeyTestEntity(final Double doubleValue) {
+ this.key = new AxArtifactKey();
+ this.doubleValue = doubleValue;
+ }
+
+ /**
+ * Instantiates a new artifact key test entity.
+ *
+ * @param key the key
+ * @param doubleValue the double value
+ */
+ public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) {
+ this.key = key;
+ this.doubleValue = doubleValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
+ */
+ @Override
+ public AxArtifactKey getKey() {
+ return key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ */
+ @Override
+ public List<AxKey> getKeys() {
+ return Arrays.asList((AxKey) getKey());
+ }
+
+ /**
+ * Sets the key.
+ *
+ * @param key the new key
+ */
+ public void setKey(final AxArtifactKey key) {
+ this.key = key;
+ }
+
+ /**
+ * Check set key.
+ *
+ * @return true, if successful
+ */
+ public boolean checkSetKey() {
+ return (this.key != null);
+ }
+
+ /**
+ * Gets the double value.
+ *
+ * @return the double value
+ */
+ public double getDoubleValue() {
+ return doubleValue;
+ }
+
+ /**
+ * Sets the double value.
+ *
+ * @param doubleValue the new double value
+ */
+ public void setDoubleValue(final double doubleValue) {
+ this.doubleValue = doubleValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
+ */
+ @Override
+ public AxValidationResult validate(final AxValidationResult result) {
+ return key.validate(result);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
+ */
+ @Override
+ public void clean() {
+ key.clean();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
+ */
+ @Override
+ public String toString() {
+ return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public AxConcept copyTo(final AxConcept target) {
+ final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
+ if (copyObject instanceof ArtifactKeyTestEntity) {
+ final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
+ if (this.checkSetKey()) {
+ copy.setKey(new AxArtifactKey(key));
+ } else {
+ copy.key = null;
+ }
+ copy.doubleValue = doubleValue;
+ return copy;
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
+ if (key == null) {
+ if (other.key != null) {
+ return false;
+ }
+ } else if (!key.equals(other.key)) {
+ return false;
+ }
+ return (Double.compare(doubleValue, other.doubleValue) == 0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(final AxConcept otherObj) {
+ if (otherObj == null) {
+ return -1;
+ }
+ if (this == otherObj) {
+ return 0;
+ }
+ if (getClass() != otherObj.getClass()) {
+ return -1;
+ }
+ final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
+ if (key == null) {
+ if (other.key != null) {
+ return 1;
+ }
+ } else if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+ return Double.compare(doubleValue, other.doubleValue);
+ }
+}
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java
new file mode 100644
index 000000000..eb5db7145
--- /dev/null
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java
@@ -0,0 +1,260 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.plugins.persistence.jpa.eclipselink.entities;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
+
+/**
+ * The Class ReferenceKeyTestEntity provides a reference key test concept.
+ */
+@Entity
+@Table(name = "ReferenceKeyTestEntity")
+public class ReferenceKeyTestEntity extends AxConcept {
+ private static final long serialVersionUID = -2962570563281067895L;
+
+ @EmbeddedId()
+ @XmlElement(name = "key", required = true)
+ @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
+ protected AxReferenceKey key;
+
+ private double doubleValue;
+
+ /**
+ * Instantiates a new reference key test entity.
+ */
+ public ReferenceKeyTestEntity() {
+ this.key = new AxReferenceKey();
+ this.doubleValue = 0;
+ }
+
+ /**
+ * Instantiates a new reference key test entity.
+ *
+ * @param doubleValue the double value
+ */
+ public ReferenceKeyTestEntity(final Double doubleValue) {
+ this.key = new AxReferenceKey();
+ this.doubleValue = doubleValue;
+ }
+
+ /**
+ * Instantiates a new reference key test entity.
+ *
+ * @param key the key
+ * @param doubleValue the double value
+ */
+ public ReferenceKeyTestEntity(final AxReferenceKey key, final Double doubleValue) {
+ this.key = key;
+ this.doubleValue = doubleValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
+ */
+ @Override
+ public AxReferenceKey getKey() {
+ return key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ */
+ @Override
+ public List<AxKey> getKeys() {
+ return Arrays.asList((AxKey) getKey());
+ }
+
+ /**
+ * Sets the key.
+ *
+ * @param key the new key
+ */
+ public void setKey(final AxReferenceKey key) {
+ this.key = key;
+ }
+
+ /**
+ * Check set key.
+ *
+ * @return true, if successful
+ */
+ public boolean checkSetKey() {
+ return (this.key != null);
+ }
+
+ /**
+ * Gets the double value.
+ *
+ * @return the double value
+ */
+ public double getDoubleValue() {
+ return doubleValue;
+ }
+
+ /**
+ * Sets the double value.
+ *
+ * @param doubleValue the new double value
+ */
+ public void setDoubleValue(final double doubleValue) {
+ this.doubleValue = doubleValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
+ */
+ @Override
+ public AxValidationResult validate(final AxValidationResult result) {
+ return key.validate(result);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
+ */
+ @Override
+ public void clean() {
+ key.clean();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
+ */
+ @Override
+ public String toString() {
+ return "ReferenceKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public AxConcept copyTo(final AxConcept target) {
+ final Object copyObject = ((target == null) ? new ReferenceKeyTestEntity() : target);
+ if (copyObject instanceof ReferenceKeyTestEntity) {
+ final ReferenceKeyTestEntity copy = ((ReferenceKeyTestEntity) copyObject);
+ if (this.checkSetKey()) {
+ copy.setKey(new AxReferenceKey(key));
+ } else {
+ copy.key = null;
+ }
+ copy.doubleValue = doubleValue;
+ return copy;
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) obj;
+ if (key == null) {
+ if (other.key != null) {
+ return false;
+ }
+ } else if (!key.equals(other.key)) {
+ return false;
+ }
+ return (Double.compare(doubleValue, other.doubleValue) == 0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(final AxConcept otherObj) {
+ if (otherObj == null) {
+ return -1;
+ }
+ if (this == otherObj) {
+ return 0;
+ }
+ if (getClass() != otherObj.getClass()) {
+ return -1;
+ }
+ final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj;
+ if (key == null) {
+ if (other.key != null) {
+ return 1;
+ }
+ } else if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+ return Double.compare(doubleValue, other.doubleValue);
+ }
+}
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java
new file mode 100644
index 000000000..b30d40559
--- /dev/null
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java
@@ -0,0 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+/**
+ * Contains common test entities.
+ */
+package org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities;
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml
index 130079dd9..3f8be58e4 100644
--- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml
@@ -24,8 +24,8 @@
<persistence-unit name="DAOTest" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.policy.apex.context.test.entities.ReferenceKeyTestEntity</class>
- <class>org.onap.policy.apex.context.test.entities.ArtifactKeyTestEntity</class>
+ <class>org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ReferenceKeyTestEntity</class>
+ <class>org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ArtifactKeyTestEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml b/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml
index 8425af3ee..b43cc4d71 100644
--- a/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml
@@ -39,11 +39,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
diff --git a/pom.xml b/pom.xml
index 95c11235d..f464f2c22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,6 @@
<properties>
<encoding>UTF-8</encoding>
<file.encoding>UTF-8</file.encoding>
- <version.derby>10.13.1.1</version.derby>
<version.commons-cli>1.4</version.commons-cli>
<version.kafka>1.1.1</version.kafka>
<version.jersey>2.26</version.jersey>
diff --git a/services/services-engine/pom.xml b/services/services-engine/pom.xml
index 2b68f2731..24872d536 100644
--- a/services/services-engine/pom.xml
+++ b/services/services-engine/pom.xml
@@ -55,12 +55,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
diff --git a/services/services-onappf/pom.xml b/services/services-onappf/pom.xml
index 81df89483..92f07bfac 100644
--- a/services/services-onappf/pom.xml
+++ b/services/services-onappf/pom.xml
@@ -70,6 +70,10 @@
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </exclusion>
</exclusions>
<version>${version.policy.common}</version>
</dependency>
@@ -79,6 +83,11 @@
<version>${version.jersey}</version>
</dependency>
<dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId>
+ <artifactId>plugins-event-carrier-restserver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils-test</artifactId>
<version>${version.policy.common}</version>
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
index 0da554d75..e08b5b344 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
@@ -33,6 +33,7 @@ import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
import org.onap.policy.apex.services.onappf.exception.ApexStarterRunTimeException;
import org.onap.policy.apex.services.onappf.handler.PdpMessageHandler;
import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
+import org.onap.policy.apex.services.onappf.rest.ApexStarterRestServer;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -56,6 +57,7 @@ public class ApexStarterActivator {
private List<TopicSink> topicSinks;// topics to which apex-pdp sends pdp status
private List<TopicSource> topicSources; // topics to which apex-pdp listens to for messages from pap.
private static final String[] MSG_TYPE_NAMES = { "messageName" };
+
/**
* Listens for messages on the topic, decodes them into a message, and then dispatches them.
*/
@@ -66,10 +68,21 @@ public class ApexStarterActivator {
*/
private ServiceManager manager;
+ /**
+ * The ApexStarter REST API server.
+ */
+ private ApexStarterRestServer restServer;
+
@Getter
@Setter(lombok.AccessLevel.PRIVATE)
private volatile boolean alive = false;
+ /**
+ * Instantiate the activator for onappf PDP-A.
+ *
+ * @param apexStarterParameterGroup the parameters for the onappf PDP-A service
+ * @param topicProperties properties used to configure the topics
+ */
public ApexStarterActivator(final ApexStarterParameterGroup apexStarterParameterGroup,
final Properties topicProperties) {
@@ -118,7 +131,15 @@ public class ApexStarterActivator {
() -> msgDispatcher.unregister(PdpMessageType.PDP_STATE_CHANGE.name()))
.addAction("Message Dispatcher",
() -> registerMsgDispatcher(),
- () -> unregisterMsgDispatcher());
+ () -> unregisterMsgDispatcher())
+ .addAction("Create REST server",
+ () -> restServer =
+ new ApexStarterRestServer(apexStarterParameterGroup.getRestServerParameters()),
+ () -> restServer = null)
+ .addAction("Rest Server",
+ () -> restServer.start(),
+ () -> restServer.stop());
+
// @formatter:on
}
@@ -177,7 +198,7 @@ public class ApexStarterActivator {
/**
* Get the parameters used by the activator.
*
- * @return the parameters of the activator
+ * @return apexStarterParameterGroup the parameters of the activator
*/
public ApexStarterParameterGroup getParameterGroup() {
return apexStarterParameterGroup;
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterConstants.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterConstants.java
index c6dbf5fe3..2481f4ef7 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterConstants.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterConstants.java
@@ -31,4 +31,8 @@ public class ApexStarterConstants {
public static final String REG_PDP_STATUS_PUBLISHER = "object:pdp/status/publisher";
public static final String REG_APEX_PDP_TOPIC_SINKS = "object:apex/pdp/topic/sinks";
public static final String REG_APEX_ENGINE_HANDLER = "object:engine/apex/handler";
+
+ private ApexStarterConstants() {
+ super();
+ }
}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
index 22611c51b..4813eb356 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
@@ -38,6 +38,8 @@ import org.slf4j.LoggerFactory;
*/
public class ApexStarterMain {
+ private static final String APEX_STARTER_FAIL_MSG = "start of services-onappf failed";
+
private static final Logger LOGGER = LoggerFactory.getLogger(ApexStarterMain.class);
private ApexStarterActivator activator;
@@ -48,7 +50,7 @@ public class ApexStarterMain {
*
* @param args the command line arguments
*/
- ApexStarterMain(final String[] args) {
+ public ApexStarterMain(final String[] args) {
LOGGER.info("In ApexStarter with parameters " + Arrays.toString(args));
// Check the arguments
@@ -63,7 +65,7 @@ public class ApexStarterMain {
// Validate that the arguments are sane
arguments.validate();
} catch (final ApexStarterException e) {
- LOGGER.error("start of ApexStarter failed", e);
+ LOGGER.error(APEX_STARTER_FAIL_MSG, e);
return;
}
@@ -71,7 +73,7 @@ public class ApexStarterMain {
try {
parameterGroup = new ApexStarterParameterHandler().getParameters(arguments);
} catch (final Exception e) {
- LOGGER.error("start of ApexStarter failed", e);
+ LOGGER.error(APEX_STARTER_FAIL_MSG, e);
return;
}
@@ -83,7 +85,7 @@ public class ApexStarterMain {
topicProperties.load(stream);
}
} catch (final Exception e) {
- LOGGER.error("start of ApexStarter failed", e);
+ LOGGER.error(APEX_STARTER_FAIL_MSG, e);
return;
}
@@ -108,7 +110,7 @@ public class ApexStarterMain {
/**
* Get the parameters specified in JSON.
*
- * @return the parameters
+ * @return parameterGroup the parameters
*/
public ApexStarterParameterGroup getParameters() {
return parameterGroup;
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
index 211fe1316..9a61084ca 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
@@ -45,11 +45,10 @@ public class PdpStatusPublisher extends TimerTask {
private long interval;
/**
- * Constructor for instantiating PdpStatusPublisher
+ * Constructor for instantiating PdpStatusPublisher.
*
- * @param pdpStatus
- * @param topicSinks
- * @param apexStarterParameterGroup
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send pdp status
*/
public PdpStatusPublisher(final List<TopicSink> topicSinks, final long interval) {
this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
@@ -76,7 +75,7 @@ public class PdpStatusPublisher extends TimerTask {
/**
* Get the current time interval used by the timer task.
*
- * @return interval
+ * @return interval the current time interval
*/
public long getInterval() {
return interval;
@@ -84,6 +83,8 @@ public class PdpStatusPublisher extends TimerTask {
/**
* Method to send pdp status message to pap on demand.
+ *
+ * @param pdpStatus the pdp status
*/
public void send(final PdpStatus pdpStatus) {
topicSinkClient.send(pdpStatus);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
index 83e1b77c6..85d666c2b 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
@@ -49,9 +49,8 @@ public class ApexEngineHandler {
/**
* Constructs the object. Extracts the apex config and model files and instantiates the apex engine.
*
- * @param properties
- * @return ApexEngineHandler
- * @throws ApexStarterException
+ * @param properties the properties which contains the policies and configurations received from pap
+ * @throws ApexStarterException if the apex engine instantiation failed using the properties passed
*/
public ApexEngineHandler(final String properties) throws ApexStarterException {
@@ -76,11 +75,11 @@ public class ApexEngineHandler {
}
/**
- * Method to create the policy model file
+ * Method to create the policy model file.
*
- * @param policyModel
- * @param modelFilePath
- * @throws ApexStarterException
+ * @param fileContent the content of the file
+ * @param fileName the name of the file
+ * @throws ApexStarterException if the file creation failed
*/
private String createFile(final String fileContent, final String fileName) throws ApexStarterException {
try {
@@ -94,10 +93,16 @@ public class ApexEngineHandler {
}
}
+ /**
+ * Method to check whether the apex engine is running or not.
+ */
public boolean isApexEngineRunning() {
return null != apexMain;
}
+ /**
+ * Method to shut down the apex engine.
+ */
public void shutdown() throws ApexStarterException {
try {
LOGGER.debug("Shutting down apex engine.");
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
index e3f0c04a1..b72ef805f 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
@@ -44,12 +44,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
public class PdpMessageHandler {
/**
- * Method to create PdpStatus message from the parameters which will be saved to the context
+ * Method to create PdpStatus message from the parameters which will be saved to the context.
*
* @param instanceId instance id of apex pdp
* @param pdpStatusParameters pdp status parameters read from the configuration file
*
- * @return PdpStatus the pdp status message
+ * @return pdpStatus the pdp status message
*/
public PdpStatus createPdpStatusFromParameters(final String instanceId,
final PdpStatusParameters pdpStatusParameters) {
@@ -66,8 +66,8 @@ public class PdpMessageHandler {
/**
* Method to get supported policy types from the parameters.
*
- * @param pdpStatusParameters
- * @return list of PolicyTypeIdent
+ * @param pdpStatusParameters pdp status parameters
+ * @return supportedPolicyTypes list of PolicyTypeIdent
*/
private List<ToscaPolicyTypeIdentifier> getSupportedPolicyTypesFromParameters(
final PdpStatusParameters pdpStatusParameters) {
@@ -104,9 +104,7 @@ public class PdpMessageHandler {
/**
* Method to get a final pdp status when the apex started is shutting down.
*
- * @param policies list of ToscaPolicy
- *
- * @return PdpStatus
+ * @return PdpStatus the pdp status message
*/
public PdpStatus getTerminatedPdpStatus() {
final PdpStatus pdpStatusInContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
index 3a186aed6..d2c7786ca 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
@@ -32,6 +32,8 @@ import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class supports the handling of pdp state change messages.
@@ -40,6 +42,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
*/
public class PdpStateChangeMessageHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PdpStateChangeMessageHandler.class);
+
/**
* Method which handles a pdp state change event from PAP.
*
@@ -72,10 +76,10 @@ public class PdpStateChangeMessageHandler {
/**
* Method to handle when the new state from pap is active.
*
- * @param pdpStateChangeMsg
- * @param pdpStatusContext
- * @param pdpMessageHandler
- * @return pdpResponseDetails
+ * @param pdpStateChangeMsg pdp state change message
+ * @param pdpStatusContext pdp status object in memory
+ * @param pdpMessageHandler the pdp message handler
+ * @return pdpResponseDetails pdp response
*/
private PdpResponseDetails handleActiveState(final PdpStateChange pdpStateChangeMsg,
final PdpStatus pdpStatusContext, final PdpMessageHandler pdpMessageHandler) {
@@ -98,6 +102,7 @@ public class PdpStateChangeMessageHandler {
PdpResponseStatus.SUCCESS, "Apex engine started. State changed to active.");
pdpStatusContext.setState(PdpState.ACTIVE);
} catch (final ApexStarterException e) {
+ LOGGER.error("Pdp update failed as the policies couldn't be undeployed.", e);
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
PdpResponseStatus.FAIL, "Apex engine service running failed. " + e.getMessage());
}
@@ -109,10 +114,10 @@ public class PdpStateChangeMessageHandler {
/**
* Method to handle when the new state from pap is passive.
*
- * @param pdpStateChangeMsg
- * @param pdpStatusContext
- * @param pdpMessageHandler
- * @return pdpResponseDetails
+ * @param pdpStateChangeMsg pdp state change message
+ * @param pdpStatusContext pdp status object in memory
+ * @param pdpMessageHandler the pdp message handler
+ * @return pdpResponseDetails pdp response
*/
private PdpResponseDetails handlePassiveState(final PdpStateChange pdpStateChangeMsg,
final PdpStatus pdpStatusContext, final PdpMessageHandler pdpMessageHandler) {
@@ -128,6 +133,7 @@ public class PdpStateChangeMessageHandler {
PdpResponseStatus.SUCCESS, "Apex pdp state changed from Active to Passive.");
pdpStatusContext.setState(PdpState.PASSIVE);
} catch (final Exception e) {
+ LOGGER.error("Stopping apex engine failed. State cannot be changed to Passive.", e);
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
PdpResponseStatus.FAIL,
"Stopping apex engine failed. State cannot be changed to Passive." + e.getMessage());
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
index 3ad5477cd..599de8625 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
@@ -32,6 +32,8 @@ import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class supports the handling of pdp update messages.
@@ -40,6 +42,8 @@ import org.onap.policy.models.pdp.enums.PdpState;
*/
public class PdpUpdateMessageHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PdpUpdateMessageHandler.class);
+
/**
* Method which handles a pdp update event from PAP.
*
@@ -52,7 +56,7 @@ public class PdpUpdateMessageHandler {
if (pdpUpdateMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
pdpStatusContext.getPdpSubgroup())) {
final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
- if (checkIfAlreadyHandled(pdpUpdateMsg, pdpStatusContext, pdpStatusPublisher.getInterval())) {
+ if (checkIfAlreadyHandled(pdpUpdateMsg, pdpStatusContext)) {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.SUCCESS, "Pdp already updated");
} else {
@@ -65,8 +69,7 @@ public class PdpUpdateMessageHandler {
pdpStatusContext
.setPolicies(new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies()));
if (pdpStatusContext.getState().equals(PdpState.ACTIVE)) {
- pdpResponseDetails =
- startOrStopApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler, pdpStatusContext);
+ pdpResponseDetails = startOrStopApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler);
}
Registry.registerOrReplace(ApexStarterConstants.REG_APEX_TOSCA_POLICY_LIST, pdpUpdateMsg.getPolicies());
if (null == pdpResponseDetails) {
@@ -88,13 +91,13 @@ public class PdpUpdateMessageHandler {
* active, if PAP sends PdpUpdate with empty policies list, stop apex engine, or, if there is a change in policies,
* stop the current running policies and the deploy the new ones.
*
- * @param pdpUpdateMsg
- * @param pdpMessageHandler
- * @param pdpStatusContext
- * @return pdpResponseDetails
+ * @param pdpUpdateMsg the pdp update message from pap
+ * @param pdpMessageHandler pdp message handler
+ * @param pdpStatusContext the pdp status object in memory
+ * @return pdpResponseDetails the pdp response
*/
private PdpResponseDetails startOrStopApexEngineBasedOnPolicies(final PdpUpdate pdpUpdateMsg,
- final PdpMessageHandler pdpMessageHandler, final PdpStatus pdpStatusContext) {
+ final PdpMessageHandler pdpMessageHandler) {
PdpResponseDetails pdpResponseDetails = null;
if (pdpUpdateMsg.getPolicies().isEmpty()) {
final ApexEngineHandler apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER);
@@ -102,6 +105,7 @@ public class PdpUpdateMessageHandler {
try {
apexEngineHandler.shutdown();
} catch (final ApexStarterException e) {
+ LOGGER.error("Pdp update failed as the policies couldn't be undeployed.", e);
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.FAIL, "Pdp update failed as the policies couldn't be undeployed.");
}
@@ -118,6 +122,7 @@ public class PdpUpdateMessageHandler {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.SUCCESS, "Apex engine started and policies are running.");
} catch (final ApexStarterException e) {
+ LOGGER.error("Apex engine service running failed. ", e);
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.FAIL, "Apex engine service running failed. " + e.getMessage());
}
@@ -126,26 +131,24 @@ public class PdpUpdateMessageHandler {
}
/**
- * Method checks of the Pdp update message is already handled by checking the values in the context.
+ * Method checks if the Pdp update message is already handled by checking the values in the context.
*
* @param pdpUpdateMsg pdp update message received from pap
* @param pdpStatusContext values saved in context memory
- * @param interval the current interval in which the pdp status publisher is sending the heartbeats
* @return boolean flag which tells if the information is same or not
*/
- private boolean checkIfAlreadyHandled(final PdpUpdate pdpUpdateMsg, final PdpStatus pdpStatusContext,
- final long interval) {
- return null != pdpStatusContext.getPdpGroup()
- && pdpStatusContext.getPdpGroup().equals(pdpUpdateMsg.getPdpGroup())
- && null != pdpStatusContext.getPdpSubgroup()
- && pdpStatusContext.getPdpSubgroup().equals(pdpUpdateMsg.getPdpSubgroup())
- && null != pdpStatusContext.getPolicies()
- && new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies())
- .equals(pdpStatusContext.getPolicies())
- && (null == pdpUpdateMsg.getPdpHeartbeatIntervalMs()
- || (null != pdpUpdateMsg.getPdpHeartbeatIntervalMs()
- && pdpUpdateMsg.getPdpHeartbeatIntervalMs() > 0
- && interval == pdpUpdateMsg.getPdpHeartbeatIntervalMs()));
+ private boolean checkIfAlreadyHandled(final PdpUpdate pdpUpdateMsg, final PdpStatus pdpStatusContext) {
+
+ if (null != pdpStatusContext.getPdpGroup()
+ && pdpStatusContext.getPdpGroup().equals(pdpUpdateMsg.getPdpGroup())) {
+ return true;
+ } else if (null != pdpStatusContext.getPdpSubgroup()
+ && pdpStatusContext.getPdpSubgroup().equals(pdpUpdateMsg.getPdpSubgroup())) {
+ return true;
+ } else {
+ return null != pdpStatusContext.getPolicies() && new PdpMessageHandler()
+ .getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies()).equals(pdpStatusContext.getPolicies());
+ }
}
/**
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java
index 523e37337..db51803be 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterGroup.java
@@ -35,7 +35,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotBlank
@Getter
public class ApexStarterParameterGroup extends ParameterGroupImpl {
-
+ private RestServerParameters restServerParameters;
private PdpStatusParameters pdpStatusParameters;
/**
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/RestServerParameters.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/RestServerParameters.java
new file mode 100644
index 000000000..fafca0c9e
--- /dev/null
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/RestServerParameters.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.parameters;
+
+import lombok.Getter;
+
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.Min;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+
+/**
+ * Class to hold all parameters needed for services-onappf rest server.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+@NotNull
+@NotBlank
+@Getter
+public class RestServerParameters extends ParameterGroupImpl {
+ private String host;
+
+ @Min(value = 1)
+ private int port;
+
+ private String userName;
+ private String password;
+ private boolean https;
+ private boolean aaf;
+
+ public RestServerParameters() {
+ super("RestServerParameters");
+ }
+}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterAafFilter.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterAafFilter.java
new file mode 100644
index 000000000..2745a79f9
--- /dev/null
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterAafFilter.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.rest;
+
+import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
+
+/**
+ * Class to manage aaf filters for services-onappf component.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+public class ApexStarterAafFilter extends AafGranularAuthFilter {
+
+ public static final String AAF_NODETYPE = "policy-apex-pdp";
+ public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE;
+
+ @Override
+ public String getPermissionTypeRoot() {
+ return AAF_ROOT_PERMISSION;
+ }
+}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterRestServer.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterRestServer.java
new file mode 100644
index 000000000..02e1fcf70
--- /dev/null
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/ApexStarterRestServer.java
@@ -0,0 +1,150 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.onap.policy.apex.services.onappf.parameters.RestServerParameters;
+import org.onap.policy.common.capabilities.Startable;
+import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to manage life cycle of services-onappf rest server.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+public class ApexStarterRestServer implements Startable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexStarterRestServer.class);
+
+ private List<HttpServletServer> servers = new ArrayList<>();
+
+ private RestServerParameters restServerParameters;
+
+ /**
+ * Constructor for instantiating ApexStarterRestServer.
+ *
+ * @param restServerParameters the rest server parameters
+ */
+ public ApexStarterRestServer(final RestServerParameters restServerParameters) {
+ this.restServerParameters = restServerParameters;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public boolean start() {
+ try {
+ servers = HttpServletServer.factory.build(getServerProperties());
+ for (final HttpServletServer server : servers) {
+ if (server.isAaf()) {
+ server.addFilterClass(null, ApexStarterAafFilter.class.getCanonicalName());
+ }
+ server.start();
+ }
+ } catch (final Exception exp) {
+ LOGGER.error("Failed to start services-onappf http server", exp);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Creates the server properties object using restServerParameters.
+ *
+ * @return the properties object
+ */
+ private Properties getServerProperties() {
+ final Properties props = new Properties();
+ props.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES, restServerParameters.getName());
+
+ final String svcpfx =
+ PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + restServerParameters.getName();
+
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_HOST_SUFFIX, restServerParameters.getHost());
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX,
+ Integer.toString(restServerParameters.getPort()));
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX,
+ HealthCheckRestControllerV1.class.getCanonicalName());
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "false");
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SWAGGER_SUFFIX, "true");
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
+ restServerParameters.getUserName());
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX,
+ restServerParameters.getPassword());
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX,
+ String.valueOf(restServerParameters.isHttps()));
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_AAF_SUFFIX,
+ String.valueOf(restServerParameters.isAaf()));
+ props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
+ GsonMessageBodyHandler.class.getName());
+ return props;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public boolean stop() {
+ for (final HttpServletServer server : servers) {
+ try {
+ server.stop();
+ } catch (final Exception exp) {
+ LOGGER.error("Failed to stop services-onappf http server", exp);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void shutdown() {
+ stop();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public boolean isAlive() {
+ return !servers.isEmpty();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("ApexStarterRestServer [servers=");
+ builder.append(servers);
+ builder.append("]");
+ return builder.toString();
+ }
+}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
new file mode 100644
index 000000000..12a34ef57
--- /dev/null
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.rest;
+
+import org.onap.policy.apex.services.onappf.ApexStarterActivator;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.utils.services.Registry;
+
+/**
+ * Class to fetch health check of ApexStarter service.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+public class HealthCheckProvider {
+
+ private static final String NOT_ALIVE = "not alive";
+ private static final String ALIVE = "alive";
+ private static final String URL = "self";
+ private static final String NAME = "Policy PDP-A";
+
+ /**
+ * Performs the health check of PAP service.
+ *
+ * @return Report containing health check status
+ */
+ public HealthCheckReport performHealthCheck() {
+ final HealthCheckReport report = new HealthCheckReport();
+ report.setName(NAME);
+ report.setUrl(URL);
+
+ final boolean alive =
+ Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class).isAlive();
+
+ report.setHealthy(alive);
+ report.setCode(alive ? 200 : 500);
+ report.setMessage(alive ? ALIVE : NOT_ALIVE);
+ return report;
+ }
+}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckRestControllerV1.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckRestControllerV1.java
new file mode 100644
index 000000000..53efa5940
--- /dev/null
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckRestControllerV1.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.BasicAuthDefinition;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SecurityDefinition;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+
+import java.net.HttpURLConnection;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+
+/**
+ * Class to provide REST endpoints for services-onappf component health check.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+//@formatter:off
+@Path("/policy/apex-pdp/v1")
+@Api(value = "PDP-A API")
+@Produces(MediaType.APPLICATION_JSON)
+@SwaggerDefinition(
+ info = @Info(description =
+ "PDP-A is responsible for making policy decisions and for managing the administrative"
+ + " state of the PDPs as directed by PolicyAdministration", version = "v1.0",
+ title = "PDP-A"),
+ consumes = {MediaType.APPLICATION_JSON},
+ produces = {MediaType.APPLICATION_JSON},
+ schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
+ tags = {@Tag(name = "PDP-A", description = "PDP-A Operations")},
+ securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
+//@formatter:on
+public class HealthCheckRestControllerV1 {
+
+ public static final String AUTHORIZATION_TYPE = "basicAuth";
+
+ public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED;
+ public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN;
+ public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR;
+
+ public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
+ public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
+ public static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
+
+ @GET
+ @Path("healthcheck")
+ @ApiOperation(value = "Perform healthcheck", notes = "Returns healthy status of the PDP-A component",
+ response = HealthCheckReport.class, authorizations = @Authorization(value = AUTHORIZATION_TYPE))
+ @ApiResponses(value = { @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) })
+ public Response healthcheck() {
+ return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
+ }
+}
diff --git a/services/services-onappf/src/main/resources/config/OnapPfConfig.json b/services/services-onappf/src/main/resources/config/OnapPfConfig.json
index 5684f1d4e..3efaa8cff 100644
--- a/services/services-onappf/src/main/resources/config/OnapPfConfig.json
+++ b/services/services-onappf/src/main/resources/config/OnapPfConfig.json
@@ -1,5 +1,12 @@
{
"name":"OnapPfParameterGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": true
+ },
"pdpStatusParameters":{
"timeIntervalMs": 120000,
"pdpType":"apex",
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
index 34025a1ad..c6ed44556 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
@@ -40,8 +40,6 @@ import org.junit.Test;
import org.onap.policy.apex.services.onappf.ApexStarterActivator;
import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
import org.onap.policy.apex.services.onappf.ApexStarterConstants;
-import org.onap.policy.apex.services.onappf.comm.PdpStateChangeListener;
-import org.onap.policy.apex.services.onappf.comm.PdpUpdateListener;
import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler;
@@ -65,6 +63,13 @@ public class TestPdpStateChangeListener {
private static final String TOPIC = "my-topic";
private ApexStarterActivator activator;
+ /**
+ * Method for setup before each test.
+ *
+ * @throws ApexStarterException if some error occurs while starting up the apex starter
+ * @throws FileNotFoundException if the file is missing
+ * @throws IOException if IO exception occurs
+ */
@Before
public void setUp() throws ApexStarterException, FileNotFoundException, IOException {
pdpUpdateMessageListener = new PdpUpdateListener();
@@ -112,8 +117,10 @@ public class TestPdpStateChangeListener {
}
/**
- * @param instance
- * @return
+ * Method to initiate a PdpUpdate.
+ *
+ * @param instance the instance id
+ * @return PdpUpdate the pdp update message
*/
private PdpUpdate performPdpUpdate(final String instance) {
final PdpUpdate pdpUpdateMsg = new PdpUpdate();
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
index 921cfd283..ebe0fc957 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
@@ -40,7 +40,6 @@ import org.junit.Test;
import org.onap.policy.apex.services.onappf.ApexStarterActivator;
import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
import org.onap.policy.apex.services.onappf.ApexStarterConstants;
-import org.onap.policy.apex.services.onappf.comm.PdpUpdateListener;
import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
import org.onap.policy.apex.services.onappf.handler.PdpMessageHandler;
import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup;
@@ -62,6 +61,13 @@ public class TestPdpUpdateListener {
private static final String TOPIC = "my-topic";
private ApexStarterActivator activator;
+ /**
+ * Method for setup before each test.
+ *
+ * @throws ApexStarterException if some error occurs while starting up the apex starter
+ * @throws FileNotFoundException if the file is missing
+ * @throws IOException if IO exception occurs
+ */
@Before
public void setUp() throws ApexStarterException, FileNotFoundException, IOException {
Registry.newRegistry();
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java
index e4946dd2b..7e668e9b2 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/CommonTestData.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.onap.policy.apex.services.onappf.parameters.ToscaPolicyTypeIdentifierParameters;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -48,6 +47,12 @@ public class CommonTestData {
public static final String POLICY_VERSION = "0.0.1";
public static final List<ToscaPolicyTypeIdentifierParameters> SUPPORTED_POLICY_TYPES =
Arrays.asList(getSupportedPolicyTypes(POLICY_NAME, POLICY_VERSION));
+ private static final String REST_SERVER_PASSWORD = "zb!XztG34";
+ private static final String REST_SERVER_USER = "healthcheck";
+ private static final int REST_SERVER_PORT = 6969;
+ private static final String REST_SERVER_HOST = "0.0.0.0";
+ private static final boolean REST_SERVER_HTTPS = true;
+ private static final boolean REST_SERVER_AAF = false;
public static final Coder coder = new StandardCoder();
@@ -90,12 +95,34 @@ public class CommonTestData {
final Map<String, Object> map = new TreeMap<>();
map.put("name", name);
+ map.put("restServerParameters", getRestServerParametersMap(false));
map.put("pdpStatusParameters", getPdpStatusParametersMap(false));
return map;
}
/**
+ * Returns a property map for a RestServerParameters map for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return a property map suitable for constructing an object
+ */
+ public Map<String, Object> getRestServerParametersMap(final boolean isEmpty) {
+ final Map<String, Object> map = new TreeMap<>();
+ map.put("https", REST_SERVER_HTTPS);
+ map.put("aaf", REST_SERVER_AAF);
+
+ if (!isEmpty) {
+ map.put("host", REST_SERVER_HOST);
+ map.put("port", REST_SERVER_PORT);
+ map.put("userName", REST_SERVER_USER);
+ map.put("password", REST_SERVER_PASSWORD);
+ }
+
+ return map;
+ }
+
+ /**
* Returns a property map for a PdpStatusParameters map for test cases.
*
* @param isEmpty boolean value to represent that object created should be empty or not
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java
index c843c6787..dd9e83f52 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/TestApexStarterParameterGroup.java
@@ -48,6 +48,7 @@ public class TestApexStarterParameterGroup {
final ApexStarterParameterGroup apexStarterParameters = commonTestData.toObject(
commonTestData.getApexStarterParameterGroupMap(CommonTestData.APEX_STARTER_GROUP_NAME),
ApexStarterParameterGroup.class);
+ final RestServerParameters restServerParameters = apexStarterParameters.getRestServerParameters();
final PdpStatusParameters pdpStatusParameters = apexStarterParameters.getPdpStatusParameters();
final GroupValidationResult validationResult = apexStarterParameters.validate();
assertTrue(validationResult.isValid());
@@ -56,6 +57,12 @@ public class TestApexStarterParameterGroup {
assertEquals(CommonTestData.PDP_TYPE, pdpStatusParameters.getPdpType());
assertEquals(CommonTestData.DESCRIPTION, pdpStatusParameters.getDescription());
assertEquals(CommonTestData.SUPPORTED_POLICY_TYPES, pdpStatusParameters.getSupportedPolicyTypes());
+ assertEquals(restServerParameters.getHost(), apexStarterParameters.getRestServerParameters().getHost());
+ assertEquals(restServerParameters.getPort(), apexStarterParameters.getRestServerParameters().getPort());
+ assertEquals(restServerParameters.getUserName(), apexStarterParameters.getRestServerParameters().getUserName());
+ assertEquals(restServerParameters.getPassword(), apexStarterParameters.getRestServerParameters().getPassword());
+ assertTrue(apexStarterParameters.getRestServerParameters().isHttps());
+ assertFalse(apexStarterParameters.getRestServerParameters().isAaf());
}
@Test
@@ -103,4 +110,19 @@ public class TestApexStarterParameterGroup {
.contains("\"org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup\" INVALID, "
+ "parameter group has status INVALID"));
}
+
+ @Test
+ public void testApexStarterParameterGroupp_EmptyRestServerParameters() {
+ final Map<String, Object> map =
+ commonTestData.getApexStarterParameterGroupMap(CommonTestData.APEX_STARTER_GROUP_NAME);
+ map.put("restServerParameters", commonTestData.getRestServerParametersMap(true));
+
+ final ApexStarterParameterGroup apexStarterParameters =
+ commonTestData.toObject(map, ApexStarterParameterGroup.class);
+ final GroupValidationResult validationResult = apexStarterParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertTrue(validationResult.getResult()
+ .contains("\"org.onap.policy.apex.services.onappf.parameters.RestServerParameters\" INVALID, "
+ + "parameter group has status INVALID"));
+ }
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java
new file mode 100644
index 000000000..72db6e091
--- /dev/null
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java
@@ -0,0 +1,286 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.security.SecureRandom;
+import java.util.Map;
+import java.util.Properties;
+import java.util.function.Function;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.client.ClientProperties;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.onap.policy.apex.services.onappf.ApexStarterActivator;
+import org.onap.policy.apex.services.onappf.ApexStarterConstants;
+import org.onap.policy.apex.services.onappf.ApexStarterMain;
+import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
+import org.onap.policy.apex.services.onappf.parameters.CommonTestData;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.services.Registry;
+import org.powermock.reflect.Whitebox;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to perform unit test of {@link ApexStarterRestServer}.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+public class CommonApexStarterRestServer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommonApexStarterRestServer.class);
+
+ private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
+
+ private static Coder coder = new StandardCoder();
+
+ public static final String NOT_ALIVE = "not alive";
+ public static final String ALIVE = "alive";
+ public static final String SELF = "self";
+ public static final String NAME = "Policy PDP-A";
+ public static final String ENDPOINT_PREFIX = "policy/apex-pdp/v1/";
+
+ private static int port;
+ protected static String httpsPrefix;
+
+ private static ApexStarterMain main;
+
+ private boolean activatorWasAlive;
+
+ /**
+ * Allocates a port for the server, writes a config file, and then starts Main.
+ *
+ * @throws Exception if an error occurs
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ port = NetworkUtil.allocPort();
+
+ httpsPrefix = "https://localhost:" + port + "/";
+
+ makeConfigFile();
+
+ startMain();
+ }
+
+ /**
+ * Stops Main.
+ */
+ @AfterClass
+ public static void teardownAfterClass() {
+ try {
+ stopMain();
+
+ } catch (final ApexStarterException exp) {
+ LOGGER.error("cannot stop main", exp);
+ }
+ }
+
+ /**
+ * Set up.
+ *
+ * @throws Exception if an error occurs
+ */
+ @Before
+ public void setUp() throws Exception {
+ // restart, if not currently running
+ if (main == null) {
+ startMain();
+ }
+
+ activatorWasAlive =
+ Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class).isAlive();
+ }
+
+ /**
+ * Restores the activator's "alive" state.
+ */
+ @After
+ public void tearDown() {
+ markActivator(activatorWasAlive);
+ }
+
+ /**
+ * Verifies that an endpoint appears within the swagger response.
+ *
+ * @param endpoint the endpoint of interest
+ * @throws Exception if an error occurs
+ */
+ protected void testSwagger(final String endpoint) throws Exception {
+ final Invocation.Builder invocationBuilder = sendFqeRequest(httpsPrefix + "swagger.yaml", true);
+ final String resp = invocationBuilder.get(String.class);
+
+ assertTrue(resp.contains(ENDPOINT_PREFIX + endpoint + ":"));
+ }
+
+ /**
+ * Makes a parameter configuration file.
+ *
+ * @throws Exception if an error occurs
+ */
+ private static void makeConfigFile() throws Exception {
+ final Map<String, Object> config =
+ new CommonTestData().getApexStarterParameterGroupMap("ApexStarterParameterGroup");
+
+ @SuppressWarnings("unchecked")
+ final Map<String, Object> restParams = (Map<String, Object>) config.get("restServerParameters");
+ restParams.put("port", port);
+
+ final File file = new File("src/test/resources/TestConfigParams.json");
+ file.deleteOnExit();
+
+ coder.encode(file, config);
+ }
+
+ /**
+ * Starts the "Main".
+ *
+ * @throws Exception if an error occurs
+ */
+ private static void startMain() throws Exception {
+ Registry.newRegistry();
+
+ // make sure port is available
+ if (NetworkUtil.isTcpPortOpen("localhost", port, 1, 1L)) {
+ throw new IllegalStateException("port " + port + " is still in use");
+ }
+
+ final Properties systemProps = System.getProperties();
+ systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
+ systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
+ System.setProperties(systemProps);
+
+ // @formatter:off
+ final String[] apexStarterConfigParameters = {
+ "-c", "src/test/resources/TestConfigParams.json",
+ "-p", "src/test/resources/topic.properties"
+ };
+ // @formatter:on
+
+ main = new ApexStarterMain(apexStarterConfigParameters);
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", port, 6, 10000L)) {
+ throw new IllegalStateException("server is not listening on port " + port);
+ }
+ }
+
+ /**
+ * Stops the "Main".
+ *
+ * @throws Exception if an error occurs
+ */
+ private static void stopMain() throws ApexStarterException {
+ if (main != null) {
+ final ApexStarterMain main2 = main;
+ main = null;
+
+ main2.shutdown();
+ }
+ }
+
+ private void markActivator(final boolean wasAlive) {
+ final Object manager = Whitebox.getInternalState(
+ Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class), "manager");
+ Whitebox.setInternalState(manager, "running", wasAlive);
+ }
+
+ /**
+ * Verifies that unauthorized requests fail.
+ *
+ * @param endpoint the target end point
+ * @param sender function that sends the requests to the target
+ * @throws Exception if an error occurs
+ */
+ protected void checkUnauthRequest(final String endpoint, final Function<Invocation.Builder, Response> sender)
+ throws Exception {
+ assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(),
+ sender.apply(sendNoAuthRequest(endpoint)).getStatus());
+ }
+
+ /**
+ * Sends a request to an endpoint.
+ *
+ * @param endpoint the target endpoint
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendRequest(final String endpoint) throws Exception {
+ return sendFqeRequest(httpsPrefix + ENDPOINT_PREFIX + endpoint, true);
+ }
+
+ /**
+ * Sends a request to an endpoint, without any authorization header.
+ *
+ * @param endpoint the target endpoint
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendNoAuthRequest(final String endpoint) throws Exception {
+ return sendFqeRequest(httpsPrefix + ENDPOINT_PREFIX + endpoint, false);
+ }
+
+ /**
+ * Sends a request to a fully qualified endpoint.
+ *
+ * @param fullyQualifiedEndpoint the fully qualified target endpoint
+ * @param includeAuth if authorization header should be included
+ * @return a request builder
+ * @throws Exception if an error occurs
+ */
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, final boolean includeAuth)
+ throws Exception {
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ sc.init(null, NetworkUtil.getAlwaysTrustingManager(), new SecureRandom());
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
+ final Client client = clientBuilder.build();
+
+ client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
+ client.register(GsonMessageBodyHandler.class);
+
+ if (includeAuth) {
+ final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ client.register(feature);
+ }
+
+ final WebTarget webTarget = client.target(fullyQualifiedEndpoint);
+
+ return webTarget.request(MediaType.APPLICATION_JSON);
+ }
+}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/TestHealthCheckRestControllerV1.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/TestHealthCheckRestControllerV1.java
new file mode 100644
index 000000000..cd625c8dd
--- /dev/null
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/TestHealthCheckRestControllerV1.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.apex.services.onappf.rest;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.client.Invocation;
+
+import org.junit.Test;
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+
+/**
+ * Class to perform unit test of {@link ApexStarterRestServer}.
+ *
+ * @author Ajith Sreekumar (ajith.sreekumar@est.tech)
+ */
+public class TestHealthCheckRestControllerV1 extends CommonApexStarterRestServer {
+
+ private static final String HEALTHCHECK_ENDPOINT = "healthcheck";
+
+ @Test
+ public void testSwagger() throws Exception {
+ super.testSwagger(HEALTHCHECK_ENDPOINT);
+ }
+
+ @Test
+ public void testHealthCheckSuccess() throws Exception {
+ final Invocation.Builder invocationBuilder = sendRequest(HEALTHCHECK_ENDPOINT);
+ final HealthCheckReport report = invocationBuilder.get(HealthCheckReport.class);
+ validateHealthCheckReport(NAME, SELF, true, 200, ALIVE, report);
+
+ // verify it fails when no authorization info is included
+ checkUnauthRequest(HEALTHCHECK_ENDPOINT, req -> req.get());
+ }
+
+ private void validateHealthCheckReport(final String name, final String url, final boolean healthy, final int code,
+ final String message, final HealthCheckReport report) {
+ assertEquals(name, report.getName());
+ assertEquals(url, report.getUrl());
+ assertEquals(healthy, report.isHealthy());
+ assertEquals(code, report.getCode());
+ assertEquals(message, report.getMessage());
+ }
+}
diff --git a/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json b/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json
index b1ea14de7..d38031d41 100644
--- a/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json
+++ b/services/services-onappf/src/test/resources/ApexStarterConfigParameters.json
@@ -1,9 +1,16 @@
{
"name":"ApexStarterParameterGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": true
+ },
"pdpStatusParameters":{
"timeIntervalMs": 120000,
"pdpType":"apex",
- "description":"Pdp status for HealthCheck",
+ "description":"Pdp Heartbeat",
"supportedPolicyTypes":[{"name":"onap.policies.controlloop.Operational","version":"1.0.0"}]
}
} \ No newline at end of file
diff --git a/services/services-onappf/src/test/resources/TestConfigParameters.json b/services/services-onappf/src/test/resources/TestConfigParameters.json
new file mode 100644
index 000000000..d9f095f21
--- /dev/null
+++ b/services/services-onappf/src/test/resources/TestConfigParameters.json
@@ -0,0 +1,16 @@
+{
+ "name":"ApexStarterParameterGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": true
+ },
+ "pdpStatusParameters":{
+ "timeIntervalMs": 120000,
+ "pdpType":"apex",
+ "description":"Pdp heartbeat",
+ "supportedPolicyTypes":[{"name":"onap.policies.controlloop.Operational","version":"1.0.0"}]
+ }
+} \ No newline at end of file
diff --git a/services/services-onappf/src/test/resources/ssl/policy-keystore b/services/services-onappf/src/test/resources/ssl/policy-keystore
new file mode 100644
index 000000000..7d2b1ecce
--- /dev/null
+++ b/services/services-onappf/src/test/resources/ssl/policy-keystore
Binary files differ
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextBooleanItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
index 24193848b..84d896c8a 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextBooleanItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextByteItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
index a6d4b1a1e..87d9bc678 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextByteItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
index 9cd3c6e81..c6cc4a781 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
import java.util.Calendar;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateLocaleItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
index 28c3e9ee3..84024578d 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateLocaleItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
import java.util.Locale;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateTzItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
index b081cd55f..90f108ce2 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDateTzItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateTzItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
import java.util.TimeZone;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDoubleItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
index 19f756051..99bde4a5c 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextDoubleItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextFloatItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
index 0883c1d8f..b7545653e 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextFloatItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextIntItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
index 5932769b3..e2b68f78b 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextIntItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextLongItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
index 8ab1c2bd0..6c9571f4d 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextLongItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextLongObjectItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
index 56b027279..73d47c414 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextLongObjectItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextStringItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
index bbf3167ad..b1b27e7d3 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextStringItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextStringItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextTreeMapItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
index 0d5741a8e..9111109fe 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextTreeMapItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
import java.util.Map;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextTreeSetItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
index 80cd3b179..7172fa478 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestContextTreeSetItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
import java.util.Arrays;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestExternalContextItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
index fbf5e6c80..77f86d226 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestExternalContextItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestExternalContextItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestGlobalContextItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
index c139d7469..5cd6a437d 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestGlobalContextItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestGlobalContextItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestPolicyContextItem.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
index 39a0408a8..f52d60228 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/TestPolicyContextItem.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/TestPolicyContextItem.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
import java.io.Serializable;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/package-info.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
index e897dda2a..547d23878 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/concepts/package-info.java
+++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/context/test/concepts/package-info.java
@@ -25,4 +25,4 @@
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.policy.apex.testsuites.integration.context.concepts;
+package org.onap.policy.apex.context.test.concepts;
diff --git a/testsuites/integration/integration-context-test/pom.xml b/testsuites/integration/integration-context-test/pom.xml
index f8a96fd12..361d20a98 100644
--- a/testsuites/integration/integration-context-test/pom.xml
+++ b/testsuites/integration/integration-context-test/pom.xml
@@ -45,6 +45,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
+ <artifactId>integration-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
<artifactId>plugins-context-distribution-hazelcast</artifactId>
<version>${project.version}</version>
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java
index aa806b5e8..0759b7eeb 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java
@@ -45,6 +45,7 @@ import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.core.infrastructure.messaging.util.MessagingUtils;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -54,7 +55,6 @@ import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDi
import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManager;
import org.onap.policy.apex.plugins.context.locking.curator.CuratorLockManagerParameters;
import org.onap.policy.apex.plugins.context.locking.hazelcast.HazelcastLockManager;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
import org.onap.policy.apex.testsuites.integration.context.lock.modifier.LockType;
import org.onap.policy.apex.testsuites.integration.context.locking.ConcurrentContext;
import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java
index 186df673b..502ccc17c 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextInstantiation.java
@@ -62,25 +62,25 @@ import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextBooleanItem;
+import org.onap.policy.apex.context.test.concepts.TestContextByteItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateTzItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDoubleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextFloatItem;
+import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
+import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeSetItem;
+import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextBooleanItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextByteItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateLocaleItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateTzItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDoubleItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextFloatItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextIntItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongObjectItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextStringItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextTreeMapItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextTreeSetItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestExternalContextItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestGlobalContextItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestPolicyContextItem;
import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
import org.onap.policy.apex.testsuites.integration.context.utils.Constants;
import org.slf4j.ext.XLogger;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java
index 0ed036992..24c63a12b 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java
@@ -45,12 +45,12 @@ import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateLocaleItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextTreeMapItem;
import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java
index 9d7f003ee..9e6002565 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/HazelcastContextDistributorTest.java
@@ -5,20 +5,20 @@
* 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.apex.plugins.context.distribution.hazelcast;
+package org.onap.policy.apex.testsuites.integration.context.distribution;
import java.io.IOException;
@@ -29,11 +29,9 @@ import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
-import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
-import org.onap.policy.apex.context.test.distribution.ContextUpdate;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor;
import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -67,7 +65,7 @@ public class HazelcastContextDistributorTest {
ParameterService.register(contextParameters.getDistributorParameters());
ParameterService.register(contextParameters.getLockManagerParameters());
ParameterService.register(contextParameters.getPersistorParameters());
-
+
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
@@ -87,7 +85,7 @@ public class HazelcastContextDistributorTest {
ParameterService.deregister(contextParameters.getPersistorParameters());
ParameterService.deregister(contextParameters);
}
-
+
/**
* Test context album update hazelcast.
*
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java
index 3da1cf509..b8cc597ef 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/InfinispanContextDistributorTest.java
@@ -5,20 +5,20 @@
* 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.apex.plugins.context.distribution.infinispan;
+package org.onap.policy.apex.testsuites.integration.context.distribution;
import java.io.IOException;
@@ -29,12 +29,10 @@ import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
-import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
-import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
-import org.onap.policy.apex.context.test.distribution.ContextUpdate;
-import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor;
+import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -69,7 +67,7 @@ public class InfinispanContextDistributorTest {
ParameterService.register(contextParameters.getDistributorParameters());
ParameterService.register(contextParameters.getLockManagerParameters());
ParameterService.register(contextParameters.getPersistorParameters());
-
+
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java
index 4c9339514..12f7f373f 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/SequentialContextInstantiation.java
@@ -52,18 +52,18 @@ import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextBooleanItem;
+import org.onap.policy.apex.context.test.concepts.TestContextByteItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDateTzItem;
+import org.onap.policy.apex.context.test.concepts.TestContextDoubleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextFloatItem;
+import org.onap.policy.apex.context.test.concepts.TestContextIntItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongObjectItem;
+import org.onap.policy.apex.context.test.concepts.TestContextStringItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextBooleanItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextByteItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateLocaleItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateTzItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDoubleItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextFloatItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextIntItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongObjectItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextStringItem;
import org.onap.policy.apex.testsuites.integration.context.utils.Constants;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java
index 2efa80154..f8c1f597c 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java
@@ -29,6 +29,12 @@ import static org.onap.policy.apex.testsuites.integration.context.utils.Constant
import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.POLICY_CONTEXT_ALBUM;
import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.VERSION;
+import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem;
+import org.onap.policy.apex.context.test.concepts.TestExternalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestGlobalContextItem;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
@@ -36,12 +42,6 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextDateLocaleItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextTreeMapItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestExternalContextItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestGlobalContextItem;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestPolicyContextItem;
/**
* The Class TestContextAlbumFactory creates test context albums.
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java
index 26f54e08c..e541aada7 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/NoLockAlbumModifier.java
@@ -24,7 +24,7 @@ package org.onap.policy.apex.testsuites.integration.context.lock.modifier;
import java.util.Random;
import org.onap.policy.apex.context.ContextAlbum;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java
index f5d22ed87..e9c435af5 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/ReadLockAlbumModifier.java
@@ -25,7 +25,7 @@ import java.util.Random;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java
index b54fe166f..ad38b03b5 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/SingleValueWriteLockAlbumModifier.java
@@ -25,7 +25,7 @@ import static org.onap.policy.apex.testsuites.integration.context.utils.Constant
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java
index 87214fb47..552365e92 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/lock/modifier/WriteLockAlbumModifier.java
@@ -25,7 +25,7 @@ import java.util.Random;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java
index 4326d5adb..2bcb38fec 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/locking/ConcurrentContext.java
@@ -34,8 +34,8 @@ import java.util.concurrent.TimeUnit;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
import org.onap.policy.apex.testsuites.integration.context.utils.ConfigrationProvider;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java
index fa5b564b8..0a9a195e9 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java
@@ -31,9 +31,9 @@ import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
+import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestContextLongItem;
import org.onap.policy.apex.testsuites.integration.context.factory.TestContextAlbumFactory;
import org.onap.policy.apex.testsuites.integration.context.lock.modifier.AlbumModifier;
import org.onap.policy.apex.testsuites.integration.context.lock.modifier.LockType;
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java
index ea80d4e7d..6fdcf6121 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java
@@ -23,8 +23,8 @@ package org.onap.policy.apex.testsuites.integration.context.utils;
import java.util.TimeZone;
+import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.testsuites.integration.context.concepts.TestPolicyContextItem;
/**
* The Class Constants provides constants for context tests.
diff --git a/testsuites/integration/integration-executor-test/pom.xml b/testsuites/integration/integration-executor-test/pom.xml
index 1a106eeeb..f50b84460 100644
--- a/testsuites/integration/integration-executor-test/pom.xml
+++ b/testsuites/integration/integration-executor-test/pom.xml
@@ -38,12 +38,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>integration-common</artifactId>
<version>${project.version}</version>
@@ -78,12 +72,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java
index e863a990a..426db8328 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -23,7 +23,6 @@ package org.onap.policy.apex.testsuites.integration.executor.handling;
import java.sql.Connection;
import java.sql.DriverManager;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
@@ -35,7 +34,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
* The Class TestApexSamplePolicyDbWrite.
*/
public class TestApexSamplePolicyDbWrite {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -45,23 +43,11 @@ public class TestApexSamplePolicyDbWrite {
*/
@Before
public void setup() throws Exception {
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("MVEL");
testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
}
/**
- * Teardown.
- *
- * @throws Exception the exception
- */
- @After
- public void teardown() throws Exception {
- connection.close();
- }
-
- /**
* Test model write read jpa.
*
* @throws Exception the exception
@@ -72,6 +58,8 @@ public class TestApexSamplePolicyDbWrite {
DaoParameters.setPluginClass(DefaultApexDao.class.getCanonicalName());
DaoParameters.setPersistenceUnit("SampleModelTest");
+ Connection connection = DriverManager.getConnection("jdbc:h2:mem:testdb");
testApexModel.testApexModelWriteReadJpa(DaoParameters);
+ connection.close();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java
index 1e7daad03..a5800956d 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
import java.sql.Connection;
import java.sql.DriverManager;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -39,7 +38,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
*/
public class TestApexSamplePolicyModel {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
- private Connection connection;
private TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -49,23 +47,11 @@ public class TestApexSamplePolicyModel {
*/
@Before
public void setup() throws Exception {
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel =
new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL"));
}
/**
- * Teardown.
- *
- * @throws Exception the exception
- */
- @After
- public void teardown() throws Exception {
- connection.close();
- }
-
- /**
* Test model valid.
*
* @throws Exception the exception
@@ -107,8 +93,10 @@ public class TestApexSamplePolicyModel {
DaoParameters.setPluginClass(DefaultApexDao.class.getCanonicalName());
DaoParameters.setPersistenceUnit("SampleModelTest");
+ Connection connection = DriverManager.getConnection("jdbc:h2:mem:testdb");
testApexModel.testApexModelWriteReadJpa(DaoParameters);
+ connection.close();
}
-
+
}
diff --git a/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml
index 40773a4d4..b2d6a96ed 100644
--- a/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml
+++ b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<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/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml
index 8772db0dd..1d48bf449 100644
--- a/testsuites/integration/integration-uservice-test/pom.xml
+++ b/testsuites/integration/integration-uservice-test/pom.xml
@@ -50,12 +50,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-schema</groupId>
<artifactId>plugins-context-schema-avro</artifactId>
<version>${project.version}</version>
diff --git a/testsuites/integration/pom.xml b/testsuites/integration/pom.xml
index c5b89a71c..17798d6ee 100644
--- a/testsuites/integration/pom.xml
+++ b/testsuites/integration/pom.xml
@@ -37,6 +37,14 @@
<module>integration-uservice-test</module>
</modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<profiles>
<profile>
<id>apexAll</id>
diff --git a/testsuites/performance/performance-benchmark-test/pom.xml b/testsuites/performance/performance-benchmark-test/pom.xml
index 6f6a978b1..747c3ddef 100644
--- a/testsuites/performance/performance-benchmark-test/pom.xml
+++ b/testsuites/performance/performance-benchmark-test/pom.xml
@@ -104,12 +104,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>