aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-06-18 09:52:22 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-06-18 10:02:26 +0100
commitfeca4bf2915858cef4f82c9822104a7b85732d2c (patch)
tree37c1ec6843548d2cc7643ab119d564cd9c26994b
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- testsuites module Issue-ID: POLICY-5041 Change-Id: I1d9984651f34f1dca253094c26da1dd593128966 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
-rw-r--r--pom.xml2
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java21
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java27
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java15
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java38
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java10
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java11
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java30
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java30
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java29
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java31
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java30
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java36
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java24
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java16
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java10
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java21
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java40
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java51
-rw-r--r--testsuites/integration/integration-uservice-test/pom.xml5
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/EventGenerator.java454
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java42
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java27
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java36
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java26
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java4
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java28
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java65
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestInitialContextFactory.java4
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java51
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java54
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java56
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java95
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java72
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java108
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java49
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java83
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java196
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java18
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventProducer.java21
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/TestExecutionProperties.java30
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java34
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java14
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java12
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java41
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java167
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java13
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java13
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java38
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java12
-rw-r--r--testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java12
59 files changed, 943 insertions, 1553 deletions
diff --git a/pom.xml b/pom.xml
index 67db076e3..4418b4c0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,7 +68,7 @@
<version.jruby-extras-bytelist>1.0.15</version.jruby-extras-bytelist>
<version.jython-standalone>2.7.3</version.jython-standalone>
<version.kafka-avro-serializer>7.5.1</version.kafka-avro-serializer>
- <version.kafka-junit4>3.2.5</version.kafka-junit4>
+ <version.kafka-junit5>3.2.5</version.kafka-junit5>
<version.rhino>1.7.14</version.rhino>
<version.websocket.jakarta>2.1.1</version.websocket.jakarta>
<version.zookeeper>3.9.1</version.zookeeper>
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java
index 5149c8675..8471a65c5 100644
--- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java
@@ -1,44 +1,45 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.testsuites.integration.common.model;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
/**
* Test the evaluation domain model factory.
*/
-public class EvalDomainModelFactoryTest {
+class EvalDomainModelFactoryTest {
@Test
- public void testEvalDomainModelFactory() {
+ void testEvalDomainModelFactory() {
EvalDomainModelFactory edmf = new EvalDomainModelFactory();
assertNotNull(edmf);
-
+
AxPolicyModel ecaPolicyModel = edmf.getEcaPolicyModel();
assertEquals("EvaluationPolicyModel_ECA:0.0.1", ecaPolicyModel.getId());
-
+
AxPolicyModel oodaPolicyModel = edmf.getOodaPolicyModel();
assertEquals("EvaluationPolicyModel_OODA:0.0.1", oodaPolicyModel.getId());
}
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java
index 406bec11f..01219fdd0 100644
--- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java
@@ -1,53 +1,54 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.testsuites.integration.common.model;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
/**
* Test the evaluation domain model factory.
*/
-public class SampleDomainModelFactoryTest {
+class SampleDomainModelFactoryTest {
@Test
- public void testSampleDomainModelFactory() {
+ void testSampleDomainModelFactory() {
SampleDomainModelFactory sdmf = new SampleDomainModelFactory();
assertNotNull(sdmf);
-
+
AxPolicyModel samplePolicyModel = sdmf.getSamplePolicyModel("JAVASCRIPT");
assertEquals("SamplePolicyModelJAVASCRIPT:0.0.1", samplePolicyModel.getId());
-
+
samplePolicyModel = sdmf.getSamplePolicyModel("JAVA");
assertEquals("SamplePolicyModelJAVA:0.0.1", samplePolicyModel.getId());
-
+
samplePolicyModel = sdmf.getSamplePolicyModel("JYTHON");
assertEquals("SamplePolicyModelJYTHON:0.0.1", samplePolicyModel.getId());
-
+
samplePolicyModel = sdmf.getSamplePolicyModel("JRUBY");
assertEquals("SamplePolicyModelJRUBY:0.0.1", samplePolicyModel.getId());
-
+
samplePolicyModel = sdmf.getSamplePolicyModel("MVEL");
assertEquals("SamplePolicyModelMVEL:0.0.1", samplePolicyModel.getId());
}
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java
index eaf223373..e266ee1ae 100644
--- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,24 +22,25 @@
package org.onap.policy.apex.testsuites.integration.common.model;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
-import org.junit.Test;
+import java.util.Objects;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
/**
* Test the sample domain model saver.
*/
-public class SampleDomainModelSaverTest {
+class SampleDomainModelSaverTest {
@Test
- public void testSampleDomainModelSaver() throws IOException, ApexException {
+ void testSampleDomainModelSaver() throws IOException, ApexException {
assertThatThrownBy(() -> SampleDomainModelSaver.main(null)).isInstanceOf(NullPointerException.class);
String[] args0 =
@@ -55,7 +56,7 @@ public class SampleDomainModelSaverTest {
File tempDir = new File(tempDirectory.toString());
assertTrue(tempDir.isDirectory());
- assertEquals(5, tempDir.listFiles().length);
+ assertEquals(5, Objects.requireNonNull(tempDir.listFiles()).length);
Files.walk(tempDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java
index 92f86f434..ea8ec812d 100644
--- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,17 +22,17 @@
package org.onap.policy.apex.testsuites.integration.common.testclasses;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
/**
* Test the ping test class.
*/
-public class TestPingClassTest {
+class TestPingClassTest {
@Test
- public void testPingClass() throws ApexException {
+ void testPingClass() throws ApexException {
PingTestClass ptc = new PingTestClass();
ptc.setName("Hello");
@@ -46,47 +46,45 @@ public class TestPingClassTest {
ptc.setPongTime(-1);
assertEquals(-1, ptc.getPongTime());
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, name does not start with \"Rose\"");
ptc.setName(null);
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, name length null or less than 4");
ptc.setName("Ros");
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, name length null or less than 4");
ptc.setName("Rose");
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, description length null or less than 44");
ptc.setDescription(null);
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, description length null or less than 44");
ptc.setDescription("A rose by any other name would smell as swee");
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, description length null or less than 44");
ptc.setDescription("A rose by any other name would smell as swell");
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
- .hasMessageContaining("TestPing is not valid, description is incorrect");
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
+ .hasMessageContaining("TestPing is not valid, description is incorrect");
ptc.setDescription("A rose by any other name would smell as sweet");
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
.hasMessageContaining("TestPing is not valid, pong time -1 is less than ping time 0");
ptc.setPongTime(-2);
- assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
- .hasMessageContaining("TestPing is not valid, pong time -2 is less than ping time 0");
+ assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class)
+ .hasMessageContaining("TestPing is not valid, pong time -2 is less than ping time 0");
ptc.setPongTime(1);
ptc.verify();
- assertEquals(
- "PingTestClass(id=0, name=Rose, "
- + "description=A rose by any other name would smell as sweet, pingTime=0, pongTime=1)",
- ptc.toString());
+ assertEquals("PingTestClass(id=0, name=Rose, description=A rose by any other name would smell as sweet, "
+ + "pingTime=0, pongTime=1)", ptc.toString());
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java
index da9036103..67c86090f 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +42,7 @@ import org.slf4j.ext.XLoggerFactory;
public class TestApexActionListener implements EnEventListener {
private static final XLogger logger = XLoggerFactory.getXLogger(TestApexActionListener.class);
- private List<EnEvent> resultEvents = new ArrayList<>();
+ private final List<EnEvent> resultEvents = new ArrayList<>();
@Getter
private final String id;
@@ -64,15 +65,12 @@ public class TestApexActionListener implements EnEventListener {
*/
public EnEvent getResult(final boolean allowNulls) {
EnEvent result = null;
- while (true) {
+ do {
while (resultEvents.isEmpty()) {
ThreadUtilities.sleep(100);
}
result = resultEvents.remove(0);
- if (result != null || allowNulls) {
- break;
- }
- }
+ } while (result == null && !allowNulls);
return result;
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java
index b9bfcaa4d..24cf4944b 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,12 +26,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
import org.onap.policy.apex.core.engine.event.EnEvent;
@@ -53,12 +51,9 @@ public class TestApexEngine {
*
* @param axLogicExecutorType the type of logic executor to use to construct the sample policy model for this test
* @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
- public TestApexEngine(final String axLogicExecutorType,
- final EngineParameters parameters) throws ApexException, InterruptedException, IOException {
- logger.debug("Running TestApexEngine test for + " + axLogicExecutorType + "logic . . .");
+ public TestApexEngine(final String axLogicExecutorType) throws ApexException {
+ logger.debug("Running TestApexEngine test for + {}logic . . .", axLogicExecutorType);
final AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel(axLogicExecutorType);
assertNotNull(apexPolicyModel);
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java
index f69893487..68455897c 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,23 +23,21 @@ package org.onap.policy.apex.testsuites.integration.executor.engine;
import static org.assertj.core.api.Assertions.assertThatCode;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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.core.engine.EngineParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters;
import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestApexEngineJRuby.
*/
-public class TestApexEngineJRuby {
+class TestApexEngineJRuby {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
private EngineParameters engineParameters;
@@ -47,8 +45,8 @@ public class TestApexEngineJRuby {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -76,8 +74,8 @@ public class TestApexEngineJRuby {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -90,15 +88,9 @@ public class TestApexEngineJRuby {
/**
* Test apex engine.
- *
- * @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testApexEngineJRuby() throws ApexException, InterruptedException, IOException {
- assertThatCode(() -> {
- new TestApexEngine("JRUBY", engineParameters);
- }).doesNotThrowAnyException();
+ void testApexEngineJRuby() {
+ assertThatCode(() -> new TestApexEngine("JRUBY")).doesNotThrowAnyException();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
index 937a89d9d..571b6bd37 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,16 +23,14 @@ package org.onap.policy.apex.testsuites.integration.executor.engine;
import static org.assertj.core.api.Assertions.assertThatCode;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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.core.engine.EngineParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
import org.onap.policy.common.parameters.ParameterService;
@@ -41,7 +39,7 @@ import org.onap.policy.common.parameters.ParameterService;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestApexEngineJava {
+class TestApexEngineJava {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
private EngineParameters engineParameters;
@@ -49,8 +47,8 @@ public class TestApexEngineJava {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -78,8 +76,8 @@ public class TestApexEngineJava {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -92,16 +90,12 @@ public class TestApexEngineJava {
/**
* Test apex engine.
- *
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws ApexException the apex exception
*/
@Test
- public void testApexEngineJava() {
+ void testApexEngineJava() {
assertThatCode(() -> {
- new TestApexEngine("JAVA", engineParameters);
- new TestApexEngine("JAVA", engineParameters);
+ new TestApexEngine("JAVA");
+ new TestApexEngine("JAVA");
}).doesNotThrowAnyException();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
index 108416bca..d5b4fd147 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,23 +23,21 @@ package org.onap.policy.apex.testsuites.integration.executor.engine;
import static org.assertj.core.api.Assertions.assertThatCode;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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.core.engine.EngineParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestApexEngineJavascript.
*/
-public class TestApexEngineJavascript {
+class TestApexEngineJavascript {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
private EngineParameters engineParameters;
@@ -47,8 +45,8 @@ public class TestApexEngineJavascript {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -76,8 +74,8 @@ public class TestApexEngineJavascript {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -91,15 +89,12 @@ public class TestApexEngineJavascript {
/**
* Test apex engine.
*
- * @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testApexEngineJavascript() throws ApexException, InterruptedException, IOException {
+ void testApexEngineJavascript() {
assertThatCode(() -> {
- new TestApexEngine("JAVASCRIPT", engineParameters);
- new TestApexEngine("JAVASCRIPT", engineParameters);
+ new TestApexEngine("JAVASCRIPT");
+ new TestApexEngine("JAVASCRIPT");
}).doesNotThrowAnyException();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
index 76b3835a1..9359900f6 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,16 +23,14 @@ package org.onap.policy.apex.testsuites.integration.executor.engine;
import static org.assertj.core.api.Assertions.assertThatCode;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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.core.engine.EngineParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
import org.onap.policy.common.parameters.ParameterService;
@@ -40,9 +38,8 @@ import org.onap.policy.common.parameters.ParameterService;
* The Class TestApexEngineJython should be the test class for the Jython interpreter.
*
* <p>It actually reruns the javascript tests as a placeholder until the Jython security issues are resolved.
- *
*/
-public class TestApexEngineJython {
+class TestApexEngineJython {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
private EngineParameters engineParameters;
@@ -50,8 +47,8 @@ public class TestApexEngineJython {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -79,8 +76,8 @@ public class TestApexEngineJython {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -93,16 +90,12 @@ public class TestApexEngineJython {
/**
* Test apex engine.
- *
- * @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testApexEngineJython() throws ApexException, InterruptedException, IOException {
+ void testApexEngineJython() {
assertThatCode(() -> {
- new TestApexEngine("JAVASCRIPT", engineParameters);
- new TestApexEngine("JAVASCRIPT", engineParameters);
+ new TestApexEngine("JAVASCRIPT");
+ new TestApexEngine("JAVASCRIPT");
}).doesNotThrowAnyException();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
index 499dc59d9..c0ee1425c 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,23 +23,21 @@ package org.onap.policy.apex.testsuites.integration.executor.engine;
import static org.assertj.core.api.Assertions.assertThatCode;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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.core.engine.EngineParameters;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters;
import org.onap.policy.common.parameters.ParameterService;
/**
* The Class TestApexEngineMvel.
*/
-public class TestApexEngineMvel {
+class TestApexEngineMvel {
private SchemaParameters schemaParameters;
private ContextParameters contextParameters;
private EngineParameters engineParameters;
@@ -47,8 +45,8 @@ public class TestApexEngineMvel {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -76,8 +74,8 @@ public class TestApexEngineMvel {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -90,16 +88,12 @@ public class TestApexEngineMvel {
/**
* Test apex engine.
- *
- * @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testApexEngineMvel() throws ApexException, InterruptedException, IOException {
+ void testApexEngineMvel() {
assertThatCode(() -> {
- new TestApexEngine("MVEL", engineParameters);
- new TestApexEngine("MVEL", engineParameters);
+ new TestApexEngine("MVEL");
+ new TestApexEngine("MVEL");
}).doesNotThrowAnyException();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java
index 75000883d..7f9a4326f 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,17 +22,16 @@
package org.onap.policy.apex.testsuites.integration.executor.event;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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;
@@ -43,7 +42,6 @@ import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
import org.onap.policy.apex.core.engine.event.EnEvent;
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.handling.ApexModelException;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters;
import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory;
@@ -56,7 +54,7 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestEventInstantiation {
+class TestEventInstantiation {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestEventInstantiation.class);
@@ -67,8 +65,8 @@ public class TestEventInstantiation {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -96,8 +94,8 @@ public class TestEventInstantiation {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -111,12 +109,10 @@ public class TestEventInstantiation {
/**
* Test event instantiation.
*
- * @throws ApexModelException on errors in handling Apex models
- * @throws IOException Signals that an I/O exception has occurred.
* @throws ApexException the apex exception
*/
@Test
- public void testEventInstantiation() throws ApexModelException, IOException, ApexException {
+ void testEventInstantiation() throws ApexException {
final String xmlFileName = "xml/ApexModel_MVEL.xml";
logger.debug("Running TestEventInstantiation test on file {} . . .", xmlFileName);
@@ -164,14 +160,14 @@ public class TestEventInstantiation {
assertEquals(temperature, temp1);
Object value = event.put("TestMatchCase", null);
+ assert value != null;
assertEquals(16, ((Byte) value).intValue());
value = event.get("TestMatchCase");
assertNull(value);
assertThatThrownBy(() -> event.put("TestMatchCase", "Hello"))
.hasMessage("Event0000:0.0.1:NULL:TestMatchCase: object \"Hello\" of class \"java.lang.String\" "
- + "not compatible with class \"java.lang.Byte\"");
- event.put("TestMatchCase", 123.45);
+ + "not compatible with class \"java.lang.Byte\"");
event.put("TestMatchCase", Byte.valueOf("16"));
@@ -196,7 +192,7 @@ public class TestEventInstantiation {
assertEquals(123.456789, temp3, 0);
final Date aDate = new Date(1433453067123L);
- final Map<String, Object> eventDataList = new HashMap<String, Object>();
+ final Map<String, Object> eventDataList = new HashMap<>();
eventDataList.put("TestSlogan", "This is a test slogan");
eventDataList.put("TestMatchCase", Byte.valueOf("123"));
eventDataList.put("TestTimestamp", aDate.getTime());
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java
index dc5c06f85..eb4d00f06 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,14 @@
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.handling.PolicyModelSplitter;
@@ -41,22 +40,21 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestApexModelExport {
+class TestApexModelExport {
private static final XLogger logger = XLoggerFactory.getXLogger(TestApexModelExport.class);
private AxPolicyModel model = null;
- @Before
- public void initApexModelSmall() throws ApexException {
+ @BeforeEach
+ void initApexModelSmall() {
model = new TestApexSamplePolicyModelCreator("MVEL").getModel();
}
@Test
- public void testApexModelExport() throws Exception {
+ void testApexModelExport() throws Exception {
logger.info("Starting test: testApexModelExport");
- final List<AxArtifactKey> exportPolicyList = new ArrayList<AxArtifactKey>();
- exportPolicyList.addAll(model.getPolicies().getPolicyMap().keySet());
+ final List<AxArtifactKey> exportPolicyList = new ArrayList<>(model.getPolicies().getPolicyMap().keySet());
final AxPolicyModel exportedModel0 = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList);
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java
index abcd22a47..ae8bc90d6 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java
@@ -1,35 +1,37 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.handling.PolicyAnalyser;
import org.onap.policy.apex.model.policymodel.handling.PolicyAnalysisResult;
-public class TestApexPolicyModelAnalysis {
+class TestApexPolicyModelAnalysis {
+
@Test
- public void testApexPolicyModelAnalysis() throws Exception {
+ void testApexPolicyModelAnalysis() {
final AxPolicyModel model = new TestApexSamplePolicyModelCreator("MVEL").getModel();
final PolicyAnalysisResult result = new PolicyAnalyser().analyse(model);
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java
index 2cc7a791f..1522ff90a 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2022 Nordix Foundation.
+ * Modifications Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,19 +24,19 @@ package org.onap.policy.apex.testsuites.integration.executor.handling;
import static org.assertj.core.api.Assertions.assertThatCode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-public class TestApexSamplePolicyCreateModelFiles {
+class TestApexSamplePolicyCreateModelFiles {
@Test
- public void testModelWriteRead() throws Exception {
+ void testModelWriteRead() {
String[] types = {"JAVA", "JAVASCRIPT", "JRUBY", "JYTHON", "MVEL"};
for (String type: types) {
final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator(type);
final TestApexModel<AxPolicyModel> testApexPolicyModel =
new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
- assertThatCode(() -> testApexPolicyModel.testApexModelWriteReadJson()).doesNotThrowAnyException();
+ assertThatCode(testApexPolicyModel::testApexModelWriteReadJson).doesNotThrowAnyException();
}
}
}
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 3cb7369fb..e1a16c586 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +21,10 @@
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -32,19 +32,18 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
/**
* The Class TestApexSamplePolicyModel.
*/
-public class TestApexSamplePolicyModel {
+class TestApexSamplePolicyModel {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
private TestApexModel<AxPolicyModel> testApexModel;
/**
* Setup.
*
- * @throws Exception the exception
*/
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ void setup() {
testApexModel =
- new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL"));
+ new TestApexModel<>(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL"));
}
/**
@@ -53,7 +52,7 @@ public class TestApexSamplePolicyModel {
* @throws Exception the exception
*/
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@@ -64,7 +63,7 @@ public class TestApexSamplePolicyModel {
* @throws Exception the exception
*/
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java
index 0a4b9a7d5..7b4f04add 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,12 @@
package org.onap.policy.apex.testsuites.integration.executor.handling;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -52,7 +51,7 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestContextUpdateDifferentModels {
+class TestContextUpdateDifferentModels {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateDifferentModels.class);
@@ -63,8 +62,8 @@ public class TestContextUpdateDifferentModels {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -92,8 +91,8 @@ public class TestContextUpdateDifferentModels {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -107,19 +106,17 @@ public class TestContextUpdateDifferentModels {
/**
* Test context update different models.
*
- * @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
*/
@Test
- public void testContextUpdateDifferentModels() throws ApexException, InterruptedException, IOException {
+ void testContextUpdateDifferentModels() throws ApexException {
logger.debug("Running test testContextUpdateDifferentModels . . .");
final AxPolicyModel apexModelSample = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
assertNotNull(apexModelSample);
final ApexEngineImpl apexEngine =
- (ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1"));
+ (ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1"));
final TestApexActionListener listener = new TestApexActionListener("Test");
apexEngine.addEventListener("listener", listener);
apexEngine.updateModel(apexModelSample, false);
@@ -133,18 +130,17 @@ public class TestContextUpdateDifferentModels {
assertThatThrownBy(() -> apexEngine.updateModel(null, false))
.hasMessage("updateModel()<-TestApexEngine:0.0.1, Apex model is not defined, it has a null value");
assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
- apexModelSample.getAlbums().getAlbumsMap().size());
+ apexModelSample.getAlbums().getAlbumsMap().size());
for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
assertEquals(
- contextAlbum.getAlbumDefinition(), apexModelSample.getAlbums().get(contextAlbum.getKey()));
+ contextAlbum.getAlbumDefinition(), apexModelSample.getAlbums().get(contextAlbum.getKey()));
}
apexEngine.updateModel(someSpuriousModel, false);
assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
- someSpuriousModel.getAlbums().getAlbumsMap().size());
+ someSpuriousModel.getAlbums().getAlbumsMap().size());
for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
- assertEquals(
- contextAlbum.getAlbumDefinition(), someSpuriousModel.getAlbums().get(contextAlbum.getKey()));
+ assertEquals(contextAlbum.getAlbumDefinition(), someSpuriousModel.getAlbums().get(contextAlbum.getKey()));
}
apexEngine.clear();
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java
index 21f129dde..5e2ccde90 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,18 +21,16 @@
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.context.ContextException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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;
@@ -56,7 +54,7 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TestContextUpdateModel {
+class TestContextUpdateModel {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateModel.class);
@@ -67,8 +65,8 @@ public class TestContextUpdateModel {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
schemaParameters = new SchemaParameters();
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
@@ -96,8 +94,8 @@ public class TestContextUpdateModel {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
ParameterService.deregister(engineParameters);
ParameterService.deregister(contextParameters.getDistributorParameters());
@@ -111,12 +109,10 @@ public class TestContextUpdateModel {
/**
* Test context update model.
*
- * @throws ApexException the apex exception
- * @throws InterruptedException the interrupted exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
*/
@Test
- public void testContextUpdateModel() throws ApexException, InterruptedException, IOException {
+ void testContextUpdateModel() throws ApexException {
final AxArtifactKey key = new AxArtifactKey("TestApexEngine", "0.0.1");
final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(key);
@@ -168,8 +164,8 @@ public class TestContextUpdateModel {
/**
* Test context update model after.
*/
- @After
- public void testContextUpdateModelAfter() {
+ @AfterEach
+ void testContextUpdateModelAfter() {
// Not used
}
@@ -177,15 +173,14 @@ public class TestContextUpdateModel {
* Send event.
*
* @param apexEngine the apex engine
- * @param listener the listener
- * @param eventName the event name
+ * @param listener the listener
+ * @param eventName the event name
* @param shouldWork the should work
- * @throws ContextException the context exception
*/
private void sendEvent(final ApexEngine apexEngine, final TestApexActionListener listener, final String eventName,
- final boolean shouldWork) throws ContextException {
+ final boolean shouldWork) {
final Date aDate = new Date(1433453067123L);
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ final Map<String, Object> eventDataMap = new HashMap<>();
eventDataMap.put("TestSlogan", "This is a test slogan");
eventDataMap.put("TestMatchCase", (byte) 123);
eventDataMap.put("TestTimestamp", aDate.getTime());
@@ -196,15 +191,15 @@ public class TestContextUpdateModel {
apexEngine.handleEvent(event0);
final EnEvent result = listener.getResult(true);
- logger.debug("result 1 is:" + result);
+ logger.debug("result 1 is:{}", result);
checkResult(result, shouldWork);
}
/**
* Check result.
*
- * @param result the result
- * @param shouldWork the should work
+ * @param result the result
+ * @param shouldWork should trigger a valid result
*/
private void checkResult(final EnEvent result, final boolean shouldWork) {
if (!shouldWork) {
diff --git a/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml
index 77c346a2b..9e80302dd 100644
--- a/testsuites/integration/integration-uservice-test/pom.xml
+++ b/testsuites/integration/integration-uservice-test/pom.xml
@@ -124,9 +124,8 @@
</dependency>
<dependency>
<groupId>com.salesforce.kafka.test</groupId>
- <artifactId>kafka-junit4</artifactId>
- <version>${version.kafka-junit4}</version>
- <scope>test</scope>
+ <artifactId>kafka-junit5</artifactId>
+ <version>${version.kafka-junit5}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/EventGenerator.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/EventGenerator.java
index 0417b7331..a015be072 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/EventGenerator.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/EventGenerator.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,27 +93,27 @@ public class EventGenerator {
builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
builder.append("<xmlApexEvent xmlns=\"http://www.onap.org/policy/apex-pdp/apexevent\">\n");
-
- builder.append(" <name>" + eventName + "</name>\n");
+ builder.append(" <name>").append(eventName).append("</name>\n");
builder.append(" <version>0.0.1</version>\n");
builder.append(" <nameSpace>org.onap.policy.apex.sample.events</nameSpace>\n");
builder.append(" <source>test</source>\n");
builder.append(" <target>apex</target>\n");
builder.append(" <data>\n");
builder.append(" <key>TestSlogan</key>\n");
- builder.append(" <value>Test slogan for External Event" + (nextEventNo++) + "</value>\n");
+ nextEventNo += 1;
+ builder.append(" <value>Test slogan for External Event").append(nextEventNo).append("</value>\n");
builder.append(" </data>\n");
builder.append(" <data>\n");
builder.append(" <key>TestMatchCase</key>\n");
- builder.append(" <value>" + nextMatchCase + "</value>\n");
+ builder.append(" <value>").append(nextMatchCase).append("</value>\n");
builder.append(" </data>\n");
builder.append(" <data>\n");
builder.append(" <key>TestTimestamp</key>\n");
- builder.append(" <value>" + System.currentTimeMillis() + "</value>\n");
+ builder.append(" <value>").append(System.currentTimeMillis()).append("</value>\n");
builder.append(" </data>\n");
builder.append(" <data>\n");
builder.append(" <key>TestTemperature</key>\n");
- builder.append(" <value>" + nextTestTemperature + "</value>\n");
+ builder.append(" <value>").append(nextTestTemperature).append("</value>\n");
builder.append(" </data>\n");
builder.append("</xmlApexEvent>");
@@ -136,441 +137,15 @@ public class EventGenerator {
builder.append("{\n");
builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no name.
- *
- * @return the string
- */
- public static String jsonEventNoName() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"namez\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event bad name.
- *
- * @return the string
- */
- public static String jsonEventBadName() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"%%%%\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no ex name.
- *
- * @return the string
- */
- public static String jsonEventNoExName() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"I_DONT_EXIST\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no version.
- *
- * @return the string
- */
- public static String jsonEventNoVersion() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"versiion\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event bad version.
- *
- * @return the string
- */
- public static String jsonEventBadVersion() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"#####\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no ex version.
- *
- * @return the string
- */
- public static String jsonEventNoExVersion() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"Event0000\",\n");
- builder.append(" \"version\": \"1.2.3\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no namespace.
- *
- * @return the string
- */
- public static String jsonEventNoNamespace() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpacee\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event bad namespace.
- *
- * @return the string
- */
- public static String jsonEventBadNamespace() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"hello.&&&&\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no ex namespace.
- *
- * @return the string
- */
- public static String jsonEventNoExNamespace() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"pie.in.the.sky\",\n");
- builder.append(" \"name\": \"Event0000\",\n");
+ builder.append(" \"name\": \"").append(eventName).append("\",\n");
builder.append(" \"version\": \"0.0.1\",\n");
builder.append(" \"source\": \"test\",\n");
builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no source.
- *
- * @return the string
- */
- public static String jsonEventNoSource() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"sourcee\": \"test\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event bad source.
- *
- * @return the string
- */
- public static String jsonEventBadSource() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"%!@**@!\",\n");
- builder.append(" \"target\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event no target.
- *
- * @return the string
- */
- public static String jsonEventNoTarget() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"targett\": \"apex\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event bad target.
- *
- * @return the string
- */
- public static String jsonEventBadTarget() {
- final Random rand = new Random();
-
- final StringBuilder builder = new StringBuilder();
-
- int nextEventNo = rand.nextInt(2);
- final String eventName = (nextEventNo == 0 ? "Event0000" : "Event0100");
- final int nextMatchCase = rand.nextInt(4);
- final float nextTestTemperature = rand.nextFloat() * 10000;
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"" + eventName + "\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"KNIO(*S)A(S)D\",\n");
- builder.append(" \"TestSlogan\": \"Test slogan for External Event" + (nextEventNo++) + "\",\n");
- builder.append(" \"TestMatchCase\": " + nextMatchCase + ",\n");
- builder.append(" \"TestTimestamp\": " + System.currentTimeMillis() + ",\n");
- builder.append(" \"TestTemperature\": " + nextTestTemperature + "\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event missing fields.
- *
- * @return the string
- */
- public static String jsonEventMissingFields() {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"Event0000\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"apex\"\n");
- builder.append("}");
-
- return builder.toString();
- }
-
- /**
- * Json event null fields.
- *
- * @return the string
- */
- public static String jsonEventNullFields() {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("{\n");
- builder.append(" \"nameSpace\": \"org.onap.policy.apex.sample.events\",\n");
- builder.append(" \"name\": \"Event0000\",\n");
- builder.append(" \"version\": \"0.0.1\",\n");
- builder.append(" \"source\": \"test\",\n");
- builder.append(" \"target\": \"Apex\",\n");
- builder.append(" \"TestSlogan\": null,\n");
- builder.append(" \"TestMatchCase\": -1,\n");
- builder.append(" \"TestTimestamp\": -1,\n");
- builder.append(" \"TestTemperature\": -1.0\n");
+ nextEventNo += 1;
+ builder.append(" \"TestSlogan\": \"Test slogan for External Event").append(nextEventNo).append("\",\n");
+ builder.append(" \"TestMatchCase\": ").append(nextMatchCase).append(",\n");
+ builder.append(" \"TestTimestamp\": ").append(System.currentTimeMillis()).append(",\n");
+ builder.append(" \"TestTemperature\": ").append(nextTestTemperature).append("\n");
builder.append("}");
return builder.toString();
@@ -587,7 +162,7 @@ public class EventGenerator {
return;
}
- int eventCount = 0;
+ int eventCount;
try {
eventCount = Integer.parseInt(args[0]);
} catch (final Exception e) {
@@ -602,7 +177,6 @@ public class EventGenerator {
LOGGER.info(jsonEvents(eventCount));
} else {
LOGGER.error("usage EventGenerator #events XML|JSON");
- return;
}
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java
index cf6efdd91..084d2511b 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-public class AsyncEventMimoTest extends TestEventBase {
+class AsyncEventMimoTest extends TestEventBase {
private final String[] outFilePaths = {
"target/examples/events/SampleDomain/EventsOutMulti0.json",
"target/examples/events/SampleDomain/EventsOutMulti1.json",
@@ -36,15 +38,15 @@ public class AsyncEventMimoTest extends TestEventBase {
/**
* Delete output files.
*/
- @After
- public void deleteOutputFiles() {
+ @AfterEach
+ void deleteOutputFiles() {
for (String filePath : outFilePaths) {
- new File(filePath).delete();
+ assertTrue(new File(filePath).delete());
}
}
@Test
- public void testJsonFileAsyncMimo() throws Exception {
+ void testJsonFileAsyncMimo() throws Exception {
final String[] args = {
"-rfr",
"target",
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java
index 2da4f5bd9..3dfcdd745 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-public class AsyncEventMisoTest extends TestEventBase {
+class AsyncEventMisoTest extends TestEventBase {
private final String[] outFilePaths = {
"target/examples/events/SampleDomain/EventsOutSingle.json"
};
@@ -34,15 +36,15 @@ public class AsyncEventMisoTest extends TestEventBase {
/**
* Delete output files.
*/
- @After
- public void deleteOutputFiles() {
+ @AfterEach
+ void deleteOutputFiles() {
for (String filePath : outFilePaths) {
- new File(filePath).delete();
+ assertTrue(new File(filePath).delete());
}
}
@Test
- public void testJsonFileAsyncMiso() throws Exception {
+ void testJsonFileAsyncMiso() throws Exception {
final String[] args = {
"-rfr",
"target",
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java
index 5e63b38ba..a73a27d66 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-public class AsyncEventSimoTest extends TestEventBase {
+class AsyncEventSimoTest extends TestEventBase {
private final String[] outFilePaths = {
"target/examples/events/SampleDomain/EventsOutMulti0.json",
"target/examples/events/SampleDomain/EventsOutMulti1.json",
@@ -36,15 +38,15 @@ public class AsyncEventSimoTest extends TestEventBase {
/**
* Delete output files.
*/
- @After
- public void deleteOutputFiles() {
+ @AfterEach
+ void deleteOutputFiles() {
for (String filePath : outFilePaths) {
- new File(filePath).delete();
+ assertTrue(new File(filePath).delete());
}
}
@Test
- public void testJsonFileAsyncSimo() throws Exception {
+ void testJsonFileAsyncSimo() throws Exception {
final String[] args = {
"-rfr",
"target",
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java
index 412d4be06..3b8b8f83c 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-public class AsyncEventSisoTest extends TestEventBase {
+class AsyncEventSisoTest extends TestEventBase {
private final String[] outFilePaths = {
"target/examples/events/SampleDomain/EventsOutSingle.json"
};
@@ -34,15 +36,15 @@ public class AsyncEventSisoTest extends TestEventBase {
/**
* Delete output files.
*/
- @After
- public void deleteOutputFiles() {
+ @AfterEach
+ void deleteOutputFiles() {
for (String filePath : outFilePaths) {
- new File(filePath).delete();
+ assertTrue(new File(filePath).delete());
}
}
@Test
- public void testJsonFileAsyncSiso() throws Exception {
+ void testJsonFileAsyncSiso() throws Exception {
final String[] args = {
"-rfr",
"target",
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java
index 482656071..7f87b37b7 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-public class SyncEventMimoTest extends TestEventBase {
+class SyncEventMimoTest extends TestEventBase {
private final String[] outFilePaths = {
"target/examples/events/SampleDomain/EventsOutMulti0.json",
"target/examples/events/SampleDomain/EventsOutMulti1.json",
@@ -36,15 +38,15 @@ public class SyncEventMimoTest extends TestEventBase {
/**
* Delete output files.
*/
- @After
- public void deleteOutputFiles() {
+ @AfterEach
+ void deleteOutputFiles() {
for (String filePath : outFilePaths) {
- new File(filePath).delete();
+ assertTrue(new File(filePath).delete());
}
}
@Test
- public void testJsonFileAsyncMimo() throws Exception {
+ void testJsonFileAsyncMimo() throws Exception {
final String[] args = {
"-rfr",
"target",
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java
index 596bcbc25..c7f0829d4 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.events.syncasync;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-public class SyncEventSisoTest extends TestEventBase {
+class SyncEventSisoTest extends TestEventBase {
private final String[] outFilePaths = {
"target/examples/events/SampleDomain/EventsOutSingle.json"
};
@@ -34,15 +36,15 @@ public class SyncEventSisoTest extends TestEventBase {
/**
* Delete output files.
*/
- @After
- public void deleteOutputFiles() {
+ @AfterEach
+ void deleteOutputFiles() {
for (String filePath : outFilePaths) {
- new File(filePath).delete();
+ assertTrue(new File(filePath).delete());
}
}
@Test
- public void testJsonFileAsyncSiso() throws Exception {
+ void testJsonFileAsyncSiso() throws Exception {
final String[] args = {
"-rfr",
"target",
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
index 57e3053a8..95232d8c3 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,68 +22,68 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.file;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class TestFile2File {
+class TestFile2File {
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
@Test
- public void testJsonFileEvents() throws MessagingException, ApexException, IOException {
+ void testJsonFileEvents() throws ApexException, IOException {
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/File2FileJsonEvent.json"};
- testFileEvents(args, "target/examples/events/SampleDomain/EventsOut.json", 44400);
+ testFileEvents(args);
}
- private void testFileEvents(final String[] args, final String outFilePath, final long expectedFileSize)
- throws MessagingException, ApexException, IOException {
+ private void testFileEvents(final String[] args) throws ApexException, IOException {
final ApexMain apexMain = new ApexMain(args);
- final File outFile = new File(outFilePath);
+ final File outFile = new File("target/examples/events/SampleDomain/EventsOut.json");
while (!outFile.exists()) {
ThreadUtilities.sleep(500);
}
// Wait for the file to be filled
- long outFileSize = 0;
+ long outFileSize;
while (true) {
- final String fileString = stripVariableLengthText(outFilePath);
+ final String fileString = stripVariableLengthText();
outFileSize = fileString.length();
- if (outFileSize > 0 && outFileSize >= expectedFileSize) {
+ if (outFileSize > 0 && outFileSize >= (long) 44400) {
break;
}
ThreadUtilities.sleep(500);
}
apexMain.shutdown();
- assertEquals(expectedFileSize, outFileSize);
+ assertEquals(44400, outFileSize);
}
/**
* Strip variable length text from file string.
*
- * @param outFile the file to read and strip
* @return the stripped string
* @throws IOException on out file read exceptions
*/
- private String stripVariableLengthText(final String outFile) throws IOException {
- return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,")
- .replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
+ private String stripVariableLengthText() throws IOException {
+ return TextFileUtils.getTextFileAsString("target/examples/events/SampleDomain/EventsOut.json")
+ .replaceAll("\\s+", "")
+ .replaceAll(":\\d*\\.?\\d*,", ":0,")
+ .replaceAll(":\\d*}", ":0}")
+ .replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
}
} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
index a03b97e55..f9ac03e45 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,29 +22,28 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.file;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class TestFile2FileFiltered {
+class TestFile2FileFiltered {
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
@Test
- public void testJsonFilteredFileInOutEvents() throws MessagingException, ApexException, IOException {
+ void testJsonFilteredFileInOutEvents() throws ApexException, IOException {
// @formatter:off
final String[] args =
{ "-rfr", "target", "-p", "target/examples/config/SampleDomain/File2FileFilteredInOutJsonEvent.json" };
@@ -61,7 +60,7 @@ public class TestFile2FileFiltered {
}
@Test
- public void testJsonFilteredFileOutEvents() throws MessagingException, ApexException, IOException {
+ void testJsonFilteredFileOutEvents() throws ApexException, IOException {
// @formatter:off
final String[] args =
{ "-rfr", "target", "-p", "target/examples/config/SampleDomain/File2FileFilteredOutJsonEvent.json" };
@@ -78,7 +77,7 @@ public class TestFile2FileFiltered {
}
@Test
- public void testJsonFilteredFileInEvents() throws MessagingException, ApexException, IOException {
+ void testJsonFilteredFileInEvents() throws ApexException, IOException {
// @formatter:off
final String[] args =
{ "-rfr", "target", "-p", "target/examples/config/SampleDomain/File2FileFilteredInJsonEvent.json" };
@@ -94,7 +93,7 @@ public class TestFile2FileFiltered {
}
private void testFilteredFileEvents(final String[] args, final String[] outFilePaths,
- final long[] expectedFileSizes) throws MessagingException, ApexException, IOException {
+ final long[] expectedFileSizes) throws ApexException, IOException {
final ApexMain apexMain = new ApexMain(args);
final File outFile0 = new File(outFilePaths[0]);
@@ -104,7 +103,7 @@ public class TestFile2FileFiltered {
}
// Wait for the file to be filled
- long outFile0Size = 0;
+ long outFile0Size;
for (int i = 0; i < 20; i++) {
final String fileString = stripVariableLengthText(outFilePaths[0]);
outFile0Size = fileString.length();
@@ -139,6 +138,6 @@ public class TestFile2FileFiltered {
*/
private String stripVariableLengthText(final String outFile) throws IOException {
return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,")
- .replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
+ .replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
}
} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java
index 1fc98d61b..de14b7f97 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileIgnore.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +22,10 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.file;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
@@ -43,42 +43,38 @@ public class TestFile2FileIgnore {
* The main method.
*
* @param args the arguments
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
* @throws IOException Signals that an I/O exception has occurred.
*/
- public static void main(final String[] args) throws MessagingException, ApexException, IOException {
+ public static void main(final String[] args) throws ApexException, IOException {
final String[] apexArgs = {"-rfr", "target", "-c", "examples/config/SampleDomain/File2FileJsonEvent.json"};
- testFileEvents(apexArgs, "target/EventsOut.json", 48656);
+ testFileEvents(apexArgs);
}
/**
* Test file events.
*
* @param args the args
- * @param outFilePath the out file path
- * @param expectedFileSize the expected file size
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
*/
- private static void testFileEvents(final String[] args, final String outFilePath, final long expectedFileSize)
- throws MessagingException, ApexException, IOException {
+ private static void testFileEvents(final String[] args)
+ throws ApexException, IOException {
final ApexMain apexMain = new ApexMain(args);
- final File outFile = new File(outFilePath);
+ final File outFile = new File("target/EventsOut.json");
while (!outFile.exists()) {
ThreadUtilities.sleep(500);
}
// Wait for the file to be filled
- long outFileSize = 0;
+ long outFileSize;
while (true) {
- final String fileString = stripVariableLengthText(outFilePath);
+ final String fileString = stripVariableLengthText();
outFileSize = fileString.length();
- if (outFileSize > 0 && outFileSize >= expectedFileSize) {
+ if (outFileSize > 0 && outFileSize >= (long) 48656) {
break;
}
ThreadUtilities.sleep(500);
@@ -88,19 +84,19 @@ public class TestFile2FileIgnore {
ThreadUtilities.sleep(100000000);
apexMain.shutdown();
- outFile.delete();
- assertEquals(outFileSize, expectedFileSize);
+ assertTrue(outFile.delete());
+ assertEquals(48656, outFileSize);
}
/**
* Strip variable length text from file string.
*
- * @param outFile the file to read and strip
* @return the stripped string
* @throws IOException on out file read exceptions
*/
- private static String stripVariableLengthText(final String outFile) throws IOException {
- return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,")
+ private static String stripVariableLengthText() throws IOException {
+ return TextFileUtils.getTextFileAsString("target/EventsOut.json")
+ .replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,")
.replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java
index 119b306b0..ea0547c83 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,18 +61,18 @@ public class JmsEventProducer implements Runnable {
/**
* Instantiates a new jms event producer.
*
- * @param topic the topic
+ * @param topic the topic
* @param connectionFactory the connection factory
- * @param username the username
- * @param password the password
- * @param eventCount the event count
- * @param sendObjects the send objects
- * @param eventInterval the event interval
+ * @param username the username
+ * @param password the password
+ * @param eventCount the event count
+ * @param sendObjects the send objects
+ * @param eventInterval the event interval
* @throws JMSException the JMS exception
*/
public JmsEventProducer(final String topic, final ConnectionFactory connectionFactory, final String username,
- final String password, final int eventCount, final boolean sendObjects,
- final long eventInterval) throws JMSException {
+ final String password, final int eventCount, final boolean sendObjects,
+ final long eventInterval) throws JMSException {
this.topic = topic;
this.eventCount = eventCount;
this.sendObjects = sendObjects;
@@ -91,7 +91,7 @@ public class JmsEventProducer implements Runnable {
public void run() {
final Topic jmsTopic = new ActiveMQTopic(topic);
try (final Session jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- final MessageProducer jmsProducer = jmsSession.createProducer(jmsTopic)) {
+ final MessageProducer jmsProducer = jmsSession.createProducer(jmsTopic)) {
while (producerThread.isAlive() && !stopFlag) {
ThreadUtilities.sleep(50);
@@ -117,7 +117,7 @@ public class JmsEventProducer implements Runnable {
/**
* Send events to topic.
*
- * @param jmsSession the jms session
+ * @param jmsSession the jms session
* @param jmsProducer the jms producer
* @throws JMSException the JMS exception
*/
@@ -128,7 +128,7 @@ public class JmsEventProducer implements Runnable {
for (int i = 0; i < eventCount; i++) {
ThreadUtilities.sleep(eventInterval);
- Message jmsMessage = null;
+ Message jmsMessage;
if (sendObjects) {
final PingTestClass pingTestClass = new PingTestClass();
pingTestClass.setId(i);
@@ -139,7 +139,7 @@ public class JmsEventProducer implements Runnable {
jmsProducer.send(jmsMessage);
eventsSentCount++;
}
- LOGGER.debug("{} : completed, number of events sent", this.getClass().getName(), eventsSentCount);
+ LOGGER.debug("{} : completed, number of events sent: {}", this.getClass().getName(), eventsSentCount);
}
/**
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java
index 7f0cd8751..46a3320ca 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -96,7 +96,7 @@ public class JmsEventSubscriber implements Runnable {
} else if (message instanceof TextMessage) {
((TextMessage) message).getText();
} else {
- throw new ApexEventException("unknowm message \"" + message + "\" of type \""
+ throw new ApexEventException("unknown message \"" + message + "\" of type \""
+ message.getClass().getName() + "\" received");
}
eventsReceivedCount++;
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java
index 02d913de4..4972823d9 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation.
+ * Copyright (C) 2022-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@ public class JmsServerRunner implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(JmsServerRunner.class);
// Embedded JMS server
- private EmbeddedActiveMQ embedded;
+ private final EmbeddedActiveMQ embedded;
// Thread to run the JMS server in
- private Thread jmsServerRunnerThread;
+ private final Thread jmsServerRunnerThread;
// Config fields
private final String serverName;
@@ -45,7 +45,7 @@ public class JmsServerRunner implements Runnable {
* Create the JMS Server.
*
* @param serverName Name of the server
- * @param serverUri URI for the server
+ * @param serverUri URI for the server
* @throws Exception on errors
*/
public JmsServerRunner(String serverName, String serverUri) throws Exception {
@@ -64,25 +64,25 @@ public class JmsServerRunner implements Runnable {
embedded = new EmbeddedActiveMQ();
embedded.setConfiguration(config);
- LOGGER.debug("starting JMS Server " + serverName + " on URI " + serverUri + " . . .");
+ LOGGER.debug("starting JMS Server {} on URI {} . . .", serverName, serverUri);
jmsServerRunnerThread = new Thread(this);
jmsServerRunnerThread.start();
- LOGGER.debug("requested start on JMS Server " + serverName + " on URI " + serverUri);
+ LOGGER.debug("requested start on JMS Server {} on URI {}", serverName, serverUri);
}
@Override
public void run() {
try {
- LOGGER.debug("starting JMS Server thread " + serverName + " on URI " + serverUri + " . . .");
+ LOGGER.debug("starting JMS Server thread {} on URI {} . . .", serverName, serverUri);
embedded.start();
await().atMost(30, TimeUnit.SECONDS).until(() -> embedded.getActiveMQServer().isActive());
- LOGGER.debug("started JMS Server thread " + serverName + " on URI " + serverUri);
+ LOGGER.debug("started JMS Server thread {} on URI {} ", serverName, serverUri);
} catch (Exception e) {
- LOGGER.warn("failed to start JMS Server thread " + serverName + " on URI " + serverUri, e);
+ LOGGER.warn("failed to start JMS Server thread {} on URI {}. {}", serverName, serverUri, e.getMessage());
}
}
@@ -92,20 +92,20 @@ public class JmsServerRunner implements Runnable {
* @throws Exception on stop errors
*/
public void stop() throws Exception {
- LOGGER.debug("stopping JMS Server " + serverName + " on URI " + serverUri + " . . .");
+ LOGGER.debug("stopping JMS Server {} on URI {} . . .", serverName, serverUri);
if (!embedded.getActiveMQServer().isActive()) {
- LOGGER.debug("JMS Server " + serverName + " already stopped on URI " + serverUri + " . . .");
+ LOGGER.debug("JMS Server {} already stopped on URI {} . . .", serverName, serverUri);
return;
}
embedded.stop();
- LOGGER.debug("waiting on JMS Server " + serverName + " to stop on URI " + serverUri + " . . .");
+ LOGGER.debug("waiting on JMS Server {} to stop on URI {} . . .", serverName, serverUri);
await().atMost(30, TimeUnit.SECONDS)
- .until(() -> !embedded.getActiveMQServer().isActive() && !jmsServerRunnerThread.isAlive());
+ .until(() -> !embedded.getActiveMQServer().isActive() && !jmsServerRunnerThread.isAlive());
- LOGGER.debug("stopping JMS Server " + serverName + " on URI " + serverUri + " . . .");
+ LOGGER.debug("stopping JMS Server {} on URI {} . . .", serverName, serverUri);
}
} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java
index f27162a65..58d5a8244 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,6 @@ import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
@@ -48,7 +47,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
*/
public class TestContext implements Context {
- private Properties testProperties;
+ private final Properties testProperties;
/**
* Instantiates a new test context.
@@ -57,7 +56,7 @@ public class TestContext implements Context {
try {
testProperties = new Properties();
- final Map<String, Object> params = new HashMap<String, Object>();
+ final Map<String, Object> params = new HashMap<>();
params.put("host", HOST);
params.put("port", PORT);
testProperties.put("ConnectionFactory", new ActiveMQConnectionFactory(TestJms2Jms.SERVER_URI));
@@ -73,7 +72,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Object lookup(final Name name) throws NamingException {
+ public Object lookup(final Name name) {
return null;
}
@@ -81,7 +80,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Object lookup(final String name) throws NamingException {
+ public Object lookup(final String name) {
return testProperties.get(name);
}
@@ -89,7 +88,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void bind(final Name name, final Object obj) throws NamingException {
+ public void bind(final Name name, final Object obj) {
// Not used here
}
@@ -97,7 +96,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void bind(final String name, final Object obj) throws NamingException {
+ public void bind(final String name, final Object obj) {
// Not used here
}
@@ -105,7 +104,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void rebind(final Name name, final Object obj) throws NamingException {
+ public void rebind(final Name name, final Object obj) {
// Not used here
}
@@ -113,7 +112,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void rebind(final String name, final Object obj) throws NamingException {
+ public void rebind(final String name, final Object obj) {
// Not used here
}
@@ -121,7 +120,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void unbind(final Name name) throws NamingException {
+ public void unbind(final Name name) {
// Not used here
}
@@ -129,7 +128,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void unbind(final String name) throws NamingException {
+ public void unbind(final String name) {
// Not used here
}
@@ -137,7 +136,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void rename(final Name oldName, final Name newName) throws NamingException {
+ public void rename(final Name oldName, final Name newName) {
// Not used here
}
@@ -145,7 +144,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void rename(final String oldName, final String newName) throws NamingException {
+ public void rename(final String oldName, final String newName) {
// Not used here
}
@@ -153,7 +152,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException {
+ public NamingEnumeration<NameClassPair> list(final Name name) {
return null;
}
@@ -161,7 +160,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public NamingEnumeration<NameClassPair> list(final String name) throws NamingException {
+ public NamingEnumeration<NameClassPair> list(final String name) {
return null;
}
@@ -169,7 +168,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException {
+ public NamingEnumeration<Binding> listBindings(final Name name) {
return null;
}
@@ -177,7 +176,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public NamingEnumeration<Binding> listBindings(final String name) throws NamingException {
+ public NamingEnumeration<Binding> listBindings(final String name) {
return null;
}
@@ -185,7 +184,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void destroySubcontext(final Name name) throws NamingException {
+ public void destroySubcontext(final Name name) {
// Not used here
}
@@ -193,7 +192,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void destroySubcontext(final String name) throws NamingException {
+ public void destroySubcontext(final String name) {
// Not used here
}
@@ -201,7 +200,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Context createSubcontext(final Name name) throws NamingException {
+ public Context createSubcontext(final Name name) {
return null;
}
@@ -209,7 +208,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Context createSubcontext(final String name) throws NamingException {
+ public Context createSubcontext(final String name) {
return null;
}
@@ -217,7 +216,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Object lookupLink(final Name name) throws NamingException {
+ public Object lookupLink(final Name name) {
return null;
}
@@ -225,7 +224,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Object lookupLink(final String name) throws NamingException {
+ public Object lookupLink(final String name) {
return null;
}
@@ -233,7 +232,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public NameParser getNameParser(final Name name) throws NamingException {
+ public NameParser getNameParser(final Name name) {
return null;
}
@@ -241,7 +240,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public NameParser getNameParser(final String name) throws NamingException {
+ public NameParser getNameParser(final String name) {
return null;
}
@@ -249,7 +248,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Name composeName(final Name name, final Name prefix) throws NamingException {
+ public Name composeName(final Name name, final Name prefix) {
return null;
}
@@ -257,7 +256,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public String composeName(final String name, final String prefix) throws NamingException {
+ public String composeName(final String name, final String prefix) {
return null;
}
@@ -265,7 +264,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Object addToEnvironment(final String propName, final Object propVal) throws NamingException {
+ public Object addToEnvironment(final String propName, final Object propVal) {
return null;
}
@@ -273,7 +272,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Object removeFromEnvironment(final String propName) throws NamingException {
+ public Object removeFromEnvironment(final String propName) {
return null;
}
@@ -281,7 +280,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public Hashtable<?, ?> getEnvironment() throws NamingException {
+ public Hashtable<?, ?> getEnvironment() {
return null;
}
@@ -289,7 +288,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public void close() throws NamingException {
+ public void close() {
// Not used here
}
@@ -297,7 +296,7 @@ public class TestContext implements Context {
* {@inheritDoc}.
*/
@Override
- public String getNameInNamespace() throws NamingException {
+ public String getNameInNamespace() {
return null;
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestInitialContextFactory.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestInitialContextFactory.java
index 071c4269a..ecda79709 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestInitialContextFactory.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestInitialContextFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,6 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms;
import java.util.Hashtable;
import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import lombok.NoArgsConstructor;
@@ -41,7 +41,7 @@ public class TestInitialContextFactory implements InitialContextFactory {
* {@inheritDoc}.
*/
@Override
- public Context getInitialContext(final Hashtable<?, ?> environment) throws NamingException {
+ public Context getInitialContext(final Hashtable<?, ?> environment) {
return context;
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java
index 91417a57a..8e4614c26 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,17 +23,16 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import jakarta.jms.JMSException;
-import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.slf4j.Logger;
@@ -42,7 +41,7 @@ import org.slf4j.LoggerFactory;
/**
* The Class TestJms2Jms.
*/
-public class TestJms2Jms {
+class TestJms2Jms {
private static final Logger LOGGER = LoggerFactory.getLogger(TestJms2Jms.class);
protected static final String SERVER_NAME = "JmsTestServer";
@@ -63,28 +62,26 @@ public class TestJms2Jms {
*
* @throws Exception the exception
*/
- @BeforeClass
- public static void setupEmbeddedJmsServer() throws Exception {
+ @BeforeAll
+ static void setupEmbeddedJmsServer() throws Exception {
jmsServerRunner = new JmsServerRunner(SERVER_NAME, SERVER_URI);
- await().pollDelay(3L, TimeUnit.SECONDS).until(() -> new AtomicBoolean(true).get() == true);
+ await().pollDelay(3L, TimeUnit.SECONDS).until(() -> new AtomicBoolean(true).get());
}
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
/**
* Shutdown embedded jms server.
- *
- * @throws IOException Signals that an I/O exception has occurred.
*/
- @AfterClass
- public static void shutdownEmbeddedJmsServer() throws IOException {
+ @AfterAll
+ static void shutdownEmbeddedJmsServer() {
try {
if (jmsServerRunner != null) {
jmsServerRunner.stop();
@@ -99,10 +96,10 @@ public class TestJms2Jms {
* Test jms object events.
*
* @throws ApexException the apex exception
- * @throws JMSException the JMS exception
+ * @throws JMSException the JMS exception
*/
@Test
- public void testJmsObjectEvents() throws ApexException, JMSException {
+ void testJmsObjectEvents() throws ApexException, JMSException {
final String[] args = {
"-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSObjectEvent.json"
};
@@ -113,10 +110,10 @@ public class TestJms2Jms {
* Test jms json events.
*
* @throws ApexException the apex exception
- * @throws JMSException the JMS exception
+ * @throws JMSException the JMS exception
*/
@Test
- public void testJmsJsonEvents() throws ApexException, JMSException {
+ void testJmsJsonEvents() throws ApexException, JMSException {
final String[] args = {
"-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSJsonEvent.json"
};
@@ -126,22 +123,22 @@ public class TestJms2Jms {
/**
* Test jms events.
*
- * @param args the args
+ * @param args the args
* @param sendObjects the send objects
* @throws ApexException the apex exception
- * @throws JMSException the JMS exception
+ * @throws JMSException the JMS exception
*/
private void testJmsEvents(final String[] args, final Boolean sendObjects) throws ApexException, JMSException {
final JmsEventSubscriber subscriber =
- new JmsEventSubscriber(JMS_TOPIC_APEX_OUT, new ActiveMQConnectionFactory(SERVER_URI), null, null);
+ new JmsEventSubscriber(JMS_TOPIC_APEX_OUT, new ActiveMQConnectionFactory(SERVER_URI), null, null);
final JmsEventProducer producer =
- new JmsEventProducer(JMS_TOPIC_APEX_IN, new ActiveMQConnectionFactory(SERVER_URI), null, null,
- EVENT_COUNT, sendObjects, EVENT_INTERVAL);
+ new JmsEventProducer(JMS_TOPIC_APEX_IN, new ActiveMQConnectionFactory(SERVER_URI), null, null,
+ EVENT_COUNT, sendObjects, EVENT_INTERVAL);
final ApexMain apexMain = new ApexMain(args);
- await().atMost(3L, TimeUnit.SECONDS).until(() -> apexMain.isAlive());
+ await().atMost(3L, TimeUnit.SECONDS).until(apexMain::isAlive);
producer.sendEvents();
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java
index 2b9064280..556f8385a 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventProducer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.kafka;
-import com.salesforce.kafka.test.junit4.SharedKafkaTestResource;
+import com.salesforce.kafka.test.junit5.SharedKafkaTestResource;
import java.time.Duration;
import lombok.Getter;
import org.apache.kafka.clients.producer.Producer;
@@ -57,14 +57,14 @@ public class KafkaEventProducer implements Runnable {
/**
* Instantiates a new kafka event producer.
*
- * @param topic the topic
+ * @param topic the topic
* @param sharedKafkaTestResource the kafka server address
- * @param eventCount the event count
- * @param xmlEvents the xml events
- * @param eventInterval the event interval
+ * @param eventCount the event count
+ * @param xmlEvents the xml events
+ * @param eventInterval the event interval
*/
public KafkaEventProducer(final String topic, final SharedKafkaTestResource sharedKafkaTestResource,
- final int eventCount, final boolean xmlEvents, final long eventInterval) {
+ final int eventCount, final boolean xmlEvents, final long eventInterval) {
this.topic = topic;
this.sharedKafkaTestResource = sharedKafkaTestResource;
this.eventCount = eventCount;
@@ -116,13 +116,13 @@ public class KafkaEventProducer implements Runnable {
eventInterval);
ThreadUtilities.sleep(eventInterval);
- String eventString = null;
+ String eventString;
if (xmlEvents) {
eventString = EventGenerator.xmlEvent();
} else {
eventString = EventGenerator.jsonEvent();
}
- producer.send(new ProducerRecord<String, String>(topic, "Event" + i + "Of" + eventCount, eventString));
+ producer.send(new ProducerRecord<>(topic, "Event" + i + "Of" + eventCount, eventString));
producer.flush();
eventsSentCount++;
LOGGER.debug("****** Sent event No. {} ******\n{}", eventsSentCount, eventString);
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java
index 5a6696d80..dd3e9ddb4 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/KafkaEventSubscriber.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,16 +22,15 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.kafka;
-import com.salesforce.kafka.test.junit4.SharedKafkaTestResource;
+import com.salesforce.kafka.test.junit5.SharedKafkaTestResource;
import java.time.Duration;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.Properties;
import lombok.Getter;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.serialization.StringDeserializer;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,12 +57,11 @@ public class KafkaEventSubscriber implements Runnable {
/**
* Instantiates a new kafka event subscriber.
*
- * @param topic the topic
+ * @param topic the topic
* @param sharedKafkaTestResource the kafka server address
- * @throws MessagingException the messaging exception
*/
public KafkaEventSubscriber(final String topic,
- final SharedKafkaTestResource sharedKafkaTestResource) throws MessagingException {
+ final SharedKafkaTestResource sharedKafkaTestResource) {
this.topic = topic;
final Properties consumerProperties = new Properties();
@@ -71,7 +69,7 @@ public class KafkaEventSubscriber implements Runnable {
consumer = sharedKafkaTestResource.getKafkaTestUtils().getKafkaConsumer(StringDeserializer.class,
StringDeserializer.class, consumerProperties);
- consumer.subscribe(Arrays.asList(topic));
+ consumer.subscribe(Collections.singletonList(topic));
subscriberThread = new Thread(this);
subscriberThread.start();
@@ -88,10 +86,10 @@ public class KafkaEventSubscriber implements Runnable {
while (subscriberThread.isAlive() && !subscriberThread.isInterrupted()) {
try {
final ConsumerRecords<String, String> records = consumer.poll(POLL_DURATION);
- for (final ConsumerRecord<String, String> record : records) {
+ for (final ConsumerRecord<String, String> rec : records) {
eventsReceivedCount++;
LOGGER.debug("****** Received event No. {} ******\noffset={}\nkey={}\n{}", eventsReceivedCount,
- record.offset(), record.key(), record.value());
+ rec.offset(), rec.key(), rec.value());
}
} catch (final Exception e) {
// Thread interrupted
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java
index 50e6afb58..a2da3c0ae 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/kafka/TestKafka2Kafka.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,23 +23,26 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.kafka;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
-import com.salesforce.kafka.test.junit4.SharedKafkaTestResource;
+import com.salesforce.kafka.test.junit5.SharedKafkaTestResource;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* The Class TestKafka2Kafka tests Kafka event sending and reception.
*/
-public class TestKafka2Kafka {
+@ExtendWith(SharedKafkaTestResource.class)
+class TestKafka2Kafka {
private static final long MAX_TEST_LENGTH = 300000;
private static final int EVENT_COUNT = 25;
@@ -48,14 +51,15 @@ public class TestKafka2Kafka {
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
- @ClassRule
- public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource()
- // Start a cluster with 1 brokers.
+ @RegisterExtension
+ @Order(1)
+ static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource()
+ // Start a cluster with 1 broker.
.withBrokers(1)
// Disable topic auto-creation.
.withBrokerProperty("auto.create.topics.enable", "false");
@@ -66,42 +70,40 @@ public class TestKafka2Kafka {
* @throws Exception the apex exception
*/
@Test
- public void testJsonKafkaEvents() throws Exception {
+ void testJsonKafkaEvents() throws Exception {
final String conditionedConfigFile = getConditionedConfigFile(
"target" + File.separator + "examples/config/SampleDomain/Kafka2KafkaJsonEvent.json");
final String[] args = {"-rfr", "target", "-p", conditionedConfigFile};
- testKafkaEvents(args, false, "json");
+ testKafkaEvents(args);
}
/**
* Test kafka events.
*
* @param args the args
- * @param xmlEvents the xml events
- * @param topicSuffix the topic suffix
* @throws Exception on errors
*/
- private void testKafkaEvents(String[] args, final Boolean xmlEvents, final String topicSuffix) throws Exception {
+ private void testKafkaEvents(String[] args) throws Exception {
- sharedKafkaTestResource.getKafkaTestUtils().createTopic("apex-out-" + topicSuffix, 1, (short) 1);
- sharedKafkaTestResource.getKafkaTestUtils().createTopic("apex-in-" + topicSuffix, 1, (short) 1);
+ sharedKafkaTestResource.getKafkaTestUtils().createTopic("apex-out-" + "json", 1, (short) 1);
+ sharedKafkaTestResource.getKafkaTestUtils().createTopic("apex-in-" + "json", 1, (short) 1);
final KafkaEventSubscriber subscriber =
- new KafkaEventSubscriber("apex-out-" + topicSuffix, sharedKafkaTestResource);
+ new KafkaEventSubscriber("apex-out-" + "json", sharedKafkaTestResource);
- await().atMost(30, TimeUnit.SECONDS).until(() -> subscriber.isAlive());
+ await().atMost(30, TimeUnit.SECONDS).until(subscriber::isAlive);
final ApexMain apexMain = new ApexMain(args);
- await().atMost(10, TimeUnit.SECONDS).until(() -> apexMain.isAlive());
+ await().atMost(10, TimeUnit.SECONDS).until(apexMain::isAlive);
long initWaitEndTIme = System.currentTimeMillis() + 10000;
await().atMost(12, TimeUnit.SECONDS).until(() -> initWaitEndTIme < System.currentTimeMillis());
- final KafkaEventProducer producer = new KafkaEventProducer("apex-in-" + topicSuffix, sharedKafkaTestResource,
- EVENT_COUNT, xmlEvents, EVENT_INTERVAL);
+ final KafkaEventProducer producer = new KafkaEventProducer("apex-in-" + "json", sharedKafkaTestResource,
+ EVENT_COUNT, false, EVENT_INTERVAL);
- await().atMost(30, TimeUnit.SECONDS).until(() -> producer.isAlive());
+ await().atMost(30, TimeUnit.SECONDS).until(producer::isAlive);
producer.sendEvents();
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
index 593ddd03e..56931b733 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020,2023 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -24,7 +24,7 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
@@ -32,11 +32,11 @@ import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
@@ -50,7 +50,7 @@ import org.slf4j.ext.XLoggerFactory;
/**
* This class runs integration tests for execution property in restClient.
*/
-public class TestExecutionPropertyRest {
+class TestExecutionPropertyRest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestExecutionPropertyRest.class);
@@ -70,8 +70,8 @@ public class TestExecutionPropertyRest {
*
* @throws Exception the exception
*/
- @BeforeClass
- public static void setUp() throws Exception {
+ @BeforeAll
+ static void setUp() throws Exception {
if (NetworkUtil.isTcpPortOpen("localHost", PORT, 3, 50L)) {
throw new IllegalStateException("port " + PORT + " is still in use");
}
@@ -92,11 +92,9 @@ public class TestExecutionPropertyRest {
/**
* Tear down.
- *
- * @throws Exception the exception
*/
- @AfterClass
- public static void tearDown() throws Exception {
+ @AfterAll
+ static void tearDown() {
if (server != null) {
server.stop();
}
@@ -105,8 +103,8 @@ public class TestExecutionPropertyRest {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
@@ -114,10 +112,11 @@ public class TestExecutionPropertyRest {
/**
* After test.
+ *
* @throws ApexException the exception.
*/
- @After
- public void afterTest() throws ApexException {
+ @AfterEach
+ void afterTest() throws ApexException {
if (null != apexMain) {
apexMain.shutdown();
}
@@ -129,7 +128,7 @@ public class TestExecutionPropertyRest {
* Test Bad Url tag in Parameter .
*/
@Test
- public void testBadUrl() throws Exception {
+ void testBadUrl() {
// @formatter:off
final String[] cliArgs = new String[] {
"-c",
@@ -158,17 +157,17 @@ public class TestExecutionPropertyRest {
final String outString = outContent.toString();
- LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl");
+ LOGGER.info("testReplaceUrlTag-OUTSTRING=\n{}\nEnd-TagUrl", outString);
assertThat(outString).contains("item \"url\" "
- + "value \"http://localhost:32801/TestExecutionRest/apex/event/tagId}\" INVALID, "
- + "invalid URL has been set for event sending on RESTCLIENT");
+ + "value \"http://localhost:32801/TestExecutionRest/apex/event/tagId}\" INVALID, "
+ + "invalid URL has been set for event sending on RESTCLIENT");
}
/**
* Test Not find value for tags in Url .
*/
@Test
- public void testNoValueSetForTagUrl() throws Exception {
+ void testNoValueSetForTagUrl() {
// @formatter:off
final String[] cliArgs = new String[] {
"-c",
@@ -200,14 +199,14 @@ public class TestExecutionPropertyRest {
.contains("key \"Number\" specified on url \"http://localhost:32801/TestExecutionRest/apex"
+ "/event/{tagId}/{Number}\" not found in execution properties passed by the current policy"));
assertTrue(apexMain.isAlive());
- LOGGER.info("testNoValueSetForTagUrl-OUTSTRING=\n" + outContent.toString() + "\nEnd-TagUrl");
+ LOGGER.info("testNoValueSetForTagUrl-OUTSTRING=\n{}\nEnd-TagUrl", outContent);
}
/**
* Test Bad Http code Filter.
*/
@Test
- public void testBadCodeFilter() throws Exception {
+ void testBadCodeFilter() {
// @formatter:off
final String[] cliArgs = new String[] {
"-c",
@@ -237,14 +236,14 @@ public class TestExecutionPropertyRest {
await().atMost(5, TimeUnit.SECONDS).until(() -> outContent.toString()
.contains("failed with status code 500 and message \"{\"testToRun\": FetchHttpCode}"));
assertTrue(apexMain.isAlive());
- LOGGER.info("testBadCodeFilter-OUTSTRING=\n" + outContent.toString() + "\nEnd-TagUrl");
+ LOGGER.info("testBadCodeFilter-OUTSTRING=\n{}\nEnd-TagUrl", outContent);
}
/**
* Test Http code filter set and multi-tag Url are transformed correctly.
*/
@Test
- public void testReplaceUrlMultiTag() throws Exception {
+ void testReplaceUrlMultiTag() {
final Client client = ClientBuilder.newClient();
// @formatter:off
final String[] cliArgs = new String[] {
@@ -277,7 +276,8 @@ public class TestExecutionPropertyRest {
return response.readEntity(String.class).contains("\"PostProperUrl\": 3");
});
assertTrue(apexMain.isAlive());
- LOGGER.info("testReplaceUrlMultiTag-OUTSTRING=\n" + outContent.toString() + "\nEnd-MultiTagUrl");
+ LOGGER.info("testReplaceUrlMultiTag-OUTSTRING=\n{}\nEnd-MultiTagUrl", outContent);
+ client.close();
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
index 737065638..21f3d09a4 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,24 +24,22 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.gson.Gson;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
@@ -55,7 +53,7 @@ import org.slf4j.ext.XLoggerFactory;
/**
* The Class TestFile2Rest.
*/
-public class TestFile2Rest {
+class TestFile2Rest {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestFile2Rest.class);
private static final int PORT = 32801;
@@ -73,10 +71,10 @@ public class TestFile2Rest {
*
* @throws Exception the exception
*/
- @BeforeClass
- public static void setUp() throws Exception {
+ @BeforeAll
+ static void setUp() throws Exception {
server = HttpServletServerFactoryInstance.getServerFactory().build("TestFile2Rest", false, null, PORT, false,
- "/TestFile2Rest", false, false);
+ "/TestFile2Rest", false, false);
server.addServletClass(null, TestRestClientEndpoint.class.getName());
server.setSerializationProvider(GsonMessageBodyHandler.class.getName());
@@ -90,11 +88,9 @@ public class TestFile2Rest {
/**
* Tear down.
- *
- * @throws Exception the exception
*/
- @AfterClass
- public static void tearDown() throws Exception {
+ @AfterAll
+ static void tearDown() {
if (server != null) {
server.stop();
}
@@ -103,8 +99,8 @@ public class TestFile2Rest {
/**
* Before test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
@@ -112,10 +108,11 @@ public class TestFile2Rest {
/**
* After test.
+ *
* @throws ApexException the exception.
*/
- @After
- public void afterTest() throws ApexException {
+ @AfterEach
+ void afterTest() throws ApexException {
if (null != apexMain) {
apexMain.shutdown();
}
@@ -126,12 +123,10 @@ public class TestFile2Rest {
/**
* Test file events post.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsPost() throws MessagingException, ApexException, IOException {
+ void testFileEventsPost() throws ApexException {
final Client client = ClientBuilder.newClient();
// @formatter:off
@@ -142,7 +137,7 @@ public class TestFile2Rest {
"target/examples/config/SampleDomain/File2RESTJsonEventPost.json"
};
// @formatter:on
- final ApexMain apexMain = new ApexMain(args);
+ final ApexMain apexMainTemp = new ApexMain(args);
Response response = null;
@@ -150,7 +145,7 @@ public class TestFile2Rest {
for (int i = 0; i < 100; i++) {
ThreadUtilities.sleep(100);
response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
if (Response.Status.OK.getStatusCode() != response.getStatus()) {
break;
@@ -158,27 +153,26 @@ public class TestFile2Rest {
final String responseString = response.readEntity(String.class);
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap =
+ new Gson().fromJson(responseString, Map.class);
if ((double) jsonMap.get("POST") == 100) {
break;
}
}
- apexMain.shutdown();
+ apexMainTemp.shutdown();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ client.close();
}
/**
* Test file events put.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsPut() throws MessagingException, ApexException, IOException {
+ void testFileEventsPut() throws ApexException {
// @formatter:off
final String[] args = {
"-rfr",
@@ -187,7 +181,7 @@ public class TestFile2Rest {
"target/examples/config/SampleDomain/File2RESTJsonEventPut.json"
};
// @formatter:on
- final ApexMain apexMain = new ApexMain(args);
+ final ApexMain apexMainTemp = new ApexMain(args);
final Client client = ClientBuilder.newClient();
@@ -197,7 +191,7 @@ public class TestFile2Rest {
for (int i = 0; i < 20; i++) {
ThreadUtilities.sleep(300);
response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats")
- .request("application/json").get();
+ .request("application/json").get();
if (Response.Status.OK.getStatusCode() != response.getStatus()) {
break;
@@ -205,27 +199,24 @@ public class TestFile2Rest {
final String responseString = response.readEntity(String.class);
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap =
+ new Gson().fromJson(responseString, Map.class);
if ((double) jsonMap.get("PUT") == 20) {
break;
}
}
- apexMain.shutdown();
+ apexMainTemp.shutdown();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ client.close();
}
/**
* Test file events no url.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsNoUrl() throws MessagingException, ApexException, IOException {
+ void testFileEventsNoUrl() {
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventNoURL.json"};
apexMain = new ApexMain(args);
@@ -236,13 +227,9 @@ public class TestFile2Rest {
/**
* Test file events bad url.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadUrl() throws MessagingException, ApexException, IOException {
+ void testFileEventsBadUrl() {
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadURL.json"};
apexMain = new ApexMain(args);
@@ -256,13 +243,9 @@ public class TestFile2Rest {
/**
* Test file events bad http method.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadHttpMethod() throws MessagingException, ApexException, IOException {
+ void testFileEventsBadHttpMethod() {
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json"};
apexMain = new ApexMain(args);
@@ -275,13 +258,9 @@ public class TestFile2Rest {
/**
* Test file events bad response.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadResponse() throws MessagingException, ApexException, IOException {
+ void testFileEventsBadResponse() {
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json"};
apexMain = new ApexMain(args);
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
index 34aaab802..557cfdebd 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,20 +23,17 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@@ -48,7 +45,7 @@ import org.slf4j.ext.XLoggerFactory;
/**
* The Class TestRest2File.
*/
-public class TestRest2File {
+class TestRest2File {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestRest2File.class);
private static final int PORT = 32801;
@@ -64,8 +61,8 @@ public class TestRest2File {
/**
* Before Test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
@@ -76,8 +73,8 @@ public class TestRest2File {
*
* @throws Exception the exception
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
server = HttpServletServerFactoryInstance.getServerFactory().build("TestRest2File", false, null, PORT, false,
"/TestRest2File", false, false);
@@ -96,8 +93,8 @@ public class TestRest2File {
*
* @throws Exception the exception
*/
- @After
- public void tearDown() throws Exception {
+ @AfterEach
+ void tearDown() throws Exception {
if (null != apexMain) {
apexMain.shutdown();
}
@@ -110,31 +107,26 @@ public class TestRest2File {
/**
* Test rest events in.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestEventsIn() throws MessagingException, ApexException, IOException {
+ void testRestEventsIn() {
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/REST2FileJsonEvent.json"};
apexMain = new ApexMain(args);
await().atMost(5, TimeUnit.SECONDS).until(
() -> Files.readString(Path.of("target/examples/events/SampleDomain/EventsOut.json")).contains(
- "04\",\n" + " \"version\": \"0.0.1\",\n" + " \"nameSpace\": \"org.onap.policy.apex.sample.events\""));
+ """
+ 04",
+ "version": "0.0.1",
+ "nameSpace": "org.onap.policy.apex.sample.events\""""));
assertTrue(apexMain.isAlive());
}
/**
* Test file empty events.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEmptyEvents() throws MessagingException, ApexException, IOException {
+ void testFileEmptyEvents() {
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEmptyEvents.json"};
apexMain = new ApexMain(args);
@@ -145,13 +137,9 @@ public class TestRest2File {
/**
* Test file events no url.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsNoUrl() throws MessagingException, ApexException, IOException {
+ void testFileEventsNoUrl() {
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventNoURL.json"};
apexMain = new ApexMain(args);
@@ -162,13 +150,9 @@ public class TestRest2File {
/**
* Test file events bad url.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadUrl() throws MessagingException, ApexException, IOException {
+ void testFileEventsBadUrl() {
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadURL.json"};
apexMain = new ApexMain(args);
@@ -180,13 +164,9 @@ public class TestRest2File {
/**
* Test file events bad http method.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadHttpMethod() throws MessagingException, ApexException, IOException {
+ void testFileEventsBadHttpMethod() {
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json"};
apexMain = new ApexMain(args);
@@ -199,13 +179,9 @@ public class TestRest2File {
/**
* Test file events bad response.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadResponse() throws MessagingException, ApexException, IOException {
+ void testFileEventsBadResponse() {
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadResponse.json"};
apexMain = new ApexMain(args);
@@ -221,7 +197,7 @@ public class TestRest2File {
* Check if a required string exists in the output.
*
* @param outputEventText the text to examine
- * @param requiredString the string to search for
+ * @param requiredString the string to search for
*/
private void checkRequiredString(String outputEventText, String requiredString) {
if (!outputEventText.contains(requiredString)) {
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
index 8a506e16b..0c88a5bb6 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -25,8 +25,9 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.restserver;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.gson.Gson;
import jakarta.ws.rs.client.Client;
@@ -34,15 +35,13 @@ import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -52,7 +51,7 @@ import org.slf4j.ext.XLoggerFactory;
/**
* The Class TestRestServer.
*/
-public class TestRestServer {
+class TestRestServer {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestRestServer.class);
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
@@ -66,8 +65,8 @@ public class TestRestServer {
/**
* Before Test.
*/
- @Before
- public void beforeTest() {
+ @BeforeEach
+ void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
@@ -76,8 +75,8 @@ public class TestRestServer {
/**
* After test.
*/
- @After
- public void afterTest() {
+ @AfterEach
+ void afterTest() {
System.setOut(stdout);
System.setErr(stderr);
}
@@ -85,14 +84,12 @@ public class TestRestServer {
/**
* Test rest server put.
*
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
* @throws InterruptedException interrupted exception
*/
@SuppressWarnings("unchecked")
@Test
- public void testRestServerPut() throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerPut() throws ApexException, InterruptedException {
LOGGER.debug("testRestServerPut start");
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/RESTServerJsonEvent.json"};
@@ -116,6 +113,7 @@ public class TestRestServer {
final String responseString = response.readEntity(String.class);
jsonMap = new Gson().fromJson(responseString, Map.class);
+ response.close();
}
apexMain.shutdown();
@@ -123,22 +121,22 @@ public class TestRestServer {
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ assertNotNull(jsonMap);
assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace"));
assertEquals("Test slogan for External Event0", jsonMap.get("TestSlogan"));
LOGGER.debug("testRestServerPut end");
+ client.close();
}
/**
* Test rest server post.
*
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
* @throws InterruptedException interrupted exception
*/
@SuppressWarnings("unchecked")
@Test
- public void testRestServerPost() throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerPost() throws ApexException, InterruptedException {
LOGGER.debug("testRestServerPost start");
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/RESTServerJsonEvent.json"};
final ApexMain apexMain = new ApexMain(args);
@@ -161,28 +159,29 @@ public class TestRestServer {
final String responseString = response.readEntity(String.class);
jsonMap = new Gson().fromJson(responseString, Map.class);
+ response.close();
}
apexMain.shutdown();
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
+ assertNotNull(jsonMap);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace"));
assertEquals("Test slogan for External Event0", jsonMap.get("TestSlogan"));
LOGGER.debug("testRestServerPost end");
+ client.close();
}
/**
* Test rest server get status.
*
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
* @throws InterruptedException interrupted exception
*/
@Test
- public void testRestServerGetStatus() throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerGetStatus() throws ApexException, InterruptedException {
LOGGER.debug("testRestServerGetStatus start");
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/RESTServerJsonEvent.json"};
final ApexMain apexMain = new ApexMain(args);
@@ -207,6 +206,8 @@ public class TestRestServer {
if (Response.Status.OK.getStatusCode() != putResponse.getStatus()) {
break;
}
+ postResponse.close();
+ putResponse.close();
}
final Response statResponse =
@@ -219,30 +220,30 @@ public class TestRestServer {
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
assertEquals(Response.Status.OK.getStatusCode(), postResponse.getStatus());
+ assertNotNull(putResponse);
assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
assertEquals(Response.Status.OK.getStatusCode(), statResponse.getStatus());
- @SuppressWarnings("unchecked")
- final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
+ @SuppressWarnings("unchecked") final Map<String, Object> jsonMap =
+ new Gson().fromJson(responseString, Map.class);
assertEquals("[FirstConsumer", ((String) jsonMap.get("INPUTS")).substring(0, 14));
assertEquals(1.0, jsonMap.get("STAT"));
assertTrue((double) jsonMap.get("POST") >= 10.0);
assertTrue((double) jsonMap.get("PUT") >= 10.0);
LOGGER.debug("testRestServerGetStatus end");
+ client.close();
}
/**
* Test rest server multi inputs.
*
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
* @throws InterruptedException interrupted exception
*/
@SuppressWarnings("unchecked")
@Test
- public void testRestServerMultiInputs()
- throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerMultiInputs()
+ throws ApexException, InterruptedException {
LOGGER.debug("testRestServerMultiInputs start");
final String[] args =
{"-rfr", "target", "-p", "target/examples/config/SampleDomain/RESTServerJsonEventMultiIn.json"};
@@ -280,33 +281,34 @@ public class TestRestServer {
final String secondResponseString = secondResponse.readEntity(String.class);
secondJsonMap = new Gson().fromJson(secondResponseString, Map.class);
+ firstResponse.close();
+ secondResponse.close();
}
apexMain.shutdown();
await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
+ assertNotNull(firstJsonMap);
assertEquals(Response.Status.OK.getStatusCode(), firstResponse.getStatus());
assertEquals("org.onap.policy.apex.sample.events", firstJsonMap.get("nameSpace"));
assertEquals("Test slogan for External Event0", firstJsonMap.get("TestSlogan"));
+ assertNotNull(secondJsonMap);
assertEquals(Response.Status.OK.getStatusCode(), secondResponse.getStatus());
assertEquals("org.onap.policy.apex.sample.events", secondJsonMap.get("nameSpace"));
assertEquals("Test slogan for External Event0", secondJsonMap.get("TestSlogan"));
LOGGER.debug("testRestServerMultiInputs end");
+ client.close();
}
/**
* Test rest server producer standalone.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException interrupted exception
*/
@Test
- public void testRestServerProducerStandalone()
- throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerProducerStandalone() throws ApexException {
LOGGER.debug("testRestServerProducerStandalone start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json"};
@@ -324,14 +326,10 @@ public class TestRestServer {
/**
* Test rest server producer host.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException interrupted exception
*/
@Test
- public void testRestServerProducerHost()
- throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerProducerHost() throws ApexException {
LOGGER.debug("testRestServerProducerHost start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerHost.json"};
@@ -348,14 +346,10 @@ public class TestRestServer {
/**
* Test rest server producer port.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException interrupted exception
*/
@Test
- public void testRestServerProducerPort()
- throws MessagingException, ApexException, IOException, InterruptedException {
+ void testRestServerProducerPort() throws ApexException {
LOGGER.debug("testRestServerProducerPort start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerPort.json"};
@@ -372,12 +366,10 @@ public class TestRestServer {
/**
* Test rest server consumer standalone no host.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerConsumerStandaloneNoHost() throws MessagingException, ApexException, IOException {
+ void testRestServerConsumerStandaloneNoHost() throws ApexException {
LOGGER.debug("testRestServerConsumerStandaloneNoHost start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoHost.json"};
@@ -394,12 +386,10 @@ public class TestRestServer {
/**
* Test rest server consumer standalone no port.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerConsumerStandaloneNoPort() throws MessagingException, ApexException, IOException {
+ void testRestServerConsumerStandaloneNoPort() throws ApexException {
LOGGER.debug("testRestServerConsumerStandaloneNoPort start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.json"};
@@ -417,12 +407,10 @@ public class TestRestServer {
/**
* Test rest server producer not sync.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerProducerNotSync() throws MessagingException, ApexException, IOException {
+ void testRestServerProducerNotSync() throws ApexException {
LOGGER.debug("testRestServerProducerNotSync start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json"};
@@ -441,12 +429,10 @@ public class TestRestServer {
/**
* Test rest server consumer not sync.
*
- * @throws MessagingException the messaging exception
* @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerConsumerNotSync() throws MessagingException, ApexException, IOException {
+ void testRestServerConsumerNotSync() throws ApexException {
LOGGER.debug("testRestServerConsumerNotSync start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerNotSync.json"};
@@ -473,12 +459,10 @@ public class TestRestServer {
final int nextMatchCase = rand.nextInt(4);
final String nextEventName = "Event0" + rand.nextInt(2) + "00";
- final String eventString = "{\n" + "\"nameSpace\": \"org.onap.policy.apex.sample.events\",\n" + "\"name\": \""
+ return "{\n" + "\"nameSpace\": \"org.onap.policy.apex.sample.events\",\n" + "\"name\": \""
+ nextEventName + "\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_" + eventsSent++ + "\",\n"
+ "\"target\": \"apex\",\n" + "\"TestSlogan\": \"Test slogan for External Event0\",\n"
+ "\"TestMatchCase\": " + nextMatchCase + ",\n" + "\"TestTimestamp\": " + System.currentTimeMillis() + ",\n"
+ "\"TestTemperature\": 9080.866\n" + "}";
-
- return eventString;
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java
index b2ae68fb4..7ca8e1a05 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/context/EventAlbumContextTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,15 +22,16 @@
package org.onap.policy.apex.testsuites.integration.uservice.context;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import java.nio.file.Path;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
@@ -38,7 +39,7 @@ import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class EventAlbumContextTest {
+class EventAlbumContextTest {
private File tempCommandFile;
private File tempLogFile;
private File tempPolicyFile;
@@ -47,22 +48,22 @@ public class EventAlbumContextTest {
private String outputFile;
private String compareFile;
- @Rule
- public TemporaryFolder tempTestDir = new TemporaryFolder();
+ @TempDir
+ Path tempTestDir;
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
@Test
- public void testJavaEventAlbumContextTest() throws IOException, ApexException {
- tempCommandFile = tempTestDir.newFile("TestPolicyJavaEventContext.apex");
- tempLogFile = tempTestDir.newFile("TestPolicyJavaEventContext.log");
- tempPolicyFile = tempTestDir.newFile("TestPolicyJavaEventContext.json");
+ void testJavaEventAlbumContextTest() throws IOException, ApexException {
+ tempCommandFile = tempTestDir.resolve("TestPolicyJavaEventContext.apex").toFile();
+ tempLogFile = tempTestDir.resolve("TestPolicyJavaEventContext.log").toFile();
+ tempPolicyFile = tempTestDir.resolve("TestPolicyJavaEventContext.json").toFile();
eventContextString = ResourceUtils.getResourceAsString("examples/scripts/TestPolicyJavaEventContext.apex");
@@ -74,10 +75,10 @@ public class EventAlbumContextTest {
}
@Test
- public void testAvroEventAlbumContextTest() throws IOException, ApexException {
- tempCommandFile = tempTestDir.newFile("TestPolicyAvroEventContext.apex");
- tempLogFile = tempTestDir.newFile("TestPolicyAvroEventContext.log");
- tempPolicyFile = tempTestDir.newFile("TestPolicyAvroEventContext.json");
+ void testAvroEventAlbumContextTest() throws IOException, ApexException {
+ tempCommandFile = tempTestDir.resolve("TestPolicyAvroEventContext.apex").toFile();
+ tempLogFile = tempTestDir.resolve("TestPolicyAvroEventContext.log").toFile();
+ tempPolicyFile = tempTestDir.resolve("TestPolicyAvroEventContext.json").toFile();
eventContextString = ResourceUtils.getResourceAsString("examples/scripts/TestPolicyAvroEventContext.apex");
@@ -107,7 +108,7 @@ public class EventAlbumContextTest {
if (outputEventFile.exists() && outputEventFile.length() > 0) {
// The output event is in this file
receivedApexOutputString =
- TextFileUtils.getTextFileAsString(outputEventFile.getCanonicalPath()).replaceAll("\\s+", "");
+ TextFileUtils.getTextFileAsString(outputEventFile.getCanonicalPath()).replaceAll("\\s+", "");
break;
}
@@ -117,10 +118,10 @@ public class EventAlbumContextTest {
// Shut down Apex
apexMain.shutdown();
- assertTrue("Test failed, the output event file was not created", outputEventFile.exists());
- outputEventFile.delete();
+ assertTrue(outputEventFile.exists(), "Test failed, the output event file was not created");
+ assertTrue(outputEventFile.delete());
- assertTrue("Test failed, the output event file was empty", receivedApexOutputString.length() > 0);
+ assertFalse(receivedApexOutputString.isEmpty(), "Test failed, the output event file was empty");
// We compare the output to what we expect to get
final String expectedFileContent = TextFileUtils.getTextFileAsString(compareFile);
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
index b3f9faa3f..9af22ce9b 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,18 +23,18 @@
package org.onap.policy.apex.testsuites.integration.uservice.engine;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -70,14 +70,13 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexServiceModelUpdateTest {
+class ApexServiceModelUpdateTest {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexServiceModelUpdateTest.class);
private final AxArtifactKey engineServiceKey = new AxArtifactKey("Machine-1_process-1_engine-1", "0.0.0");
private final EngineServiceParameters parameters = new EngineServiceParameters();
private EngineService service = null;
- private TestListener listener = null;
private int actionEventsReceived = 0;
private AxPolicyModel apexSamplePolicyModel = null;
@@ -86,8 +85,8 @@ public class ApexServiceModelUpdateTest {
/**
* Set up parameters.
*/
- @Before
- public void setupParameters() {
+ @BeforeEach
+ void setupParameters() {
ParameterService.register(new SchemaParameters());
ParameterService.register(new ContextParameters());
ParameterService.register(new DistributorParameters());
@@ -103,8 +102,8 @@ public class ApexServiceModelUpdateTest {
/**
* Clear down parameters.
*/
- @After
- public void teardownParameters() {
+ @AfterEach
+ void teardownParameters() {
ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME);
ParameterService.deregister(ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -118,10 +117,10 @@ public class ApexServiceModelUpdateTest {
* Sets up the test by creating an engine and reading in the test policy.
*
* @throws ApexException if something goes wrong
- * @throws IOException on IO exceptions
+ * @throws IOException on IO exceptions
*/
- @Before
- public void setUp() throws ApexException, IOException {
+ @BeforeEach
+ void setUp() throws ApexException, IOException {
// create engine with 3 threads
parameters.setInstanceCount(3);
parameters.setName(engineServiceKey.getName());
@@ -140,17 +139,17 @@ public class ApexServiceModelUpdateTest {
LOGGER.debug("Running TestApexEngine. . .");
// create engine
- listener = new TestListener();
+ TestListener listener = new TestListener();
service.registerActionListener("MyListener", listener);
}
/**
- * Tear down the the test infrastructure.
+ * Tear down the test infrastructure.
*
* @throws ApexException if there is an error
*/
- @After
- public void tearDown() throws Exception {
+ @AfterEach
+ void tearDown() throws Exception {
if (service != null) {
service.stop();
}
@@ -161,10 +160,10 @@ public class ApexServiceModelUpdateTest {
* Test start with no model.
*/
@Test
- public void testNoModelStart() {
+ void testNoModelStart() {
assertThatThrownBy(service::startAll)
.hasMessage("start()<-Machine-1_process-1_engine-1-0:0.0.0,STOPPED, cannot start engine, "
- + "engine has not been initialized, its model is not loaded");
+ + "engine has not been initialized, its model is not loaded");
}
/**
@@ -173,7 +172,7 @@ public class ApexServiceModelUpdateTest {
* @throws ApexException if there is an error
*/
@Test
- public void testModelUpdateStringNewNoForce() throws ApexException {
+ void testModelUpdateStringNewNoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSampleModelString, false);
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
@@ -185,7 +184,7 @@ public class ApexServiceModelUpdateTest {
* @throws ApexException if there is an error
*/
@Test
- public void testModelUpdateStringNewForce() throws ApexException {
+ void testModelUpdateStringNewForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSampleModelString, true);
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
@@ -197,7 +196,7 @@ public class ApexServiceModelUpdateTest {
* @throws ApexException if there is an error
*/
@Test
- public void testModelUpdateStringNewNewNoForce() throws ApexException {
+ void testModelUpdateStringNewNewNoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSampleModelString, false);
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
@@ -216,7 +215,7 @@ public class ApexServiceModelUpdateTest {
* @throws ApexException if there is an error
*/
@Test
- public void testModelUpdateIncoNoForce() throws ApexException {
+ void testModelUpdateIncoNoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSamplePolicyModel, false);
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
@@ -227,8 +226,8 @@ public class ApexServiceModelUpdateTest {
assertThatThrownBy(() -> service.updateModel(parameters.getEngineKey(), incoPolicyModel0, false))
.hasMessage("apex model update failed, supplied model with key \"INCOMPATIBLE:0.0.1\" is "
- + "not a compatible model update from the existing engine model " + "with key "
- + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"");
+ + "not a compatible model update from the existing engine model " + "with key "
+ + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"");
// Still on old model
sendEvents();
@@ -238,8 +237,8 @@ public class ApexServiceModelUpdateTest {
assertThatThrownBy(() -> service.updateModel(parameters.getEngineKey(), incoPolicyModel1, false))
.hasMessage("apex model update failed, supplied model with key \"SamplePolicyModelJAVASCRIPT:"
- + "1.0.1\" is not a compatible model update from the existing engine model with key "
- + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"");
+ + "1.0.1\" is not a compatible model update from the existing engine model with key "
+ + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"");
// Still on old model
sendEvents();
@@ -267,7 +266,7 @@ public class ApexServiceModelUpdateTest {
* @throws ApexException if there is an error
*/
@Test
- public void testModelUpdateIncoForce() throws ApexException {
+ void testModelUpdateIncoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSamplePolicyModel, false);
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
@@ -316,19 +315,19 @@ public class ApexServiceModelUpdateTest {
// Send some events
final Date testStartTime = new Date();
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ final Map<String, Object> eventDataMap = new HashMap<>();
eventDataMap.put("TestSlogan", "This is a test slogan");
eventDataMap.put("TestMatchCase", (byte) 123);
eventDataMap.put("TestTimestamp", testStartTime.getTime());
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event);
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event2);
@@ -352,14 +351,14 @@ public class ApexServiceModelUpdateTest {
*/
@Override
public synchronized void onApexEvent(final ApexEvent event) {
- LOGGER.debug("result 1 is:" + event);
+ LOGGER.debug("result 1 is:{}", event);
checkResult(event);
actionEventsReceived++;
final Date testStartTime = new Date((Long) event.get("TestTimestamp"));
final Date testEndTime = new Date();
- LOGGER.info("policy execution time: " + (testEndTime.getTime() - testStartTime.getTime()) + "ms");
+ LOGGER.info("policy execution time: {}ms", testEndTime.getTime() - testStartTime.getTime());
}
/**
@@ -374,13 +373,13 @@ public class ApexServiceModelUpdateTest {
assertEquals((byte) 123, result.get("TestMatchCase"));
assertEquals(34.5445667, result.get("TestTemperature"));
assertTrue(((byte) result.get("TestMatchCaseSelected")) >= 0
- && ((byte) result.get("TestMatchCaseSelected") <= 3));
+ && ((byte) result.get("TestMatchCaseSelected") <= 3));
assertTrue(((byte) result.get("TestEstablishCaseSelected")) >= 0
- && ((byte) result.get("TestEstablishCaseSelected") <= 3));
+ && ((byte) result.get("TestEstablishCaseSelected") <= 3));
assertTrue(((byte) result.get("TestDecideCaseSelected")) >= 0
- && ((byte) result.get("TestDecideCaseSelected") <= 3));
+ && ((byte) result.get("TestDecideCaseSelected") <= 3));
assertTrue(
- ((byte) result.get("TestActCaseSelected")) >= 0 && ((byte) result.get("TestActCaseSelected") <= 3));
+ ((byte) result.get("TestActCaseSelected")) >= 0 && ((byte) result.get("TestActCaseSelected") <= 3));
}
}
@@ -390,11 +389,11 @@ public class ApexServiceModelUpdateTest {
* @param policyModel the eca policy model
* @return the model string
* @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
*/
private String getModelString(final AxPolicyModel policyModel) throws ApexModelException, IOException {
try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
- new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(policyModel, baOutputStream);
+ new ApexModelWriter<>(AxPolicyModel.class).write(policyModel, baOutputStream);
return baOutputStream.toString();
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
index e2464e368..386f0426d 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,21 +22,21 @@
package org.onap.policy.apex.testsuites.integration.uservice.engine;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
import org.onap.policy.apex.context.parameters.DistributorParameters;
@@ -71,7 +71,7 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexServiceTest {
+class ApexServiceTest {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexServiceTest.class);
@@ -82,16 +82,14 @@ public class ApexServiceTest {
private static final AxArtifactKey engineServiceKey = new AxArtifactKey("Machine-1_process-1_engine-1", "0.0.0");
private static final EngineServiceParameters parameters = new EngineServiceParameters();
private static EngineService service = null;
- private static TestListener listener = null;
- private static AxPolicyModel apexPolicyModel = null;
private static int actionEventsReceived = 0;
private static String apexModelString;
private boolean waitFlag = true;
- @BeforeClass
- public static void beforeSetUp() throws Exception {
+ @BeforeAll
+ static void beforeSetUp() throws Exception {
// create engine with 3 threads
parameters.setInstanceCount(3);
parameters.setName(engineServiceKey.getName());
@@ -103,26 +101,26 @@ public class ApexServiceTest {
LOGGER.debug("Running TestApexEngine. . .");
- apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
+ AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
assertNotNull(apexPolicyModel);
apexModelString = getModelString(apexPolicyModel);
// create engine
- listener = new TestListener();
+ TestListener listener = new TestListener();
service.registerActionListener("Listener", listener);
}
- @AfterClass
- public static void afterCleardown() throws Exception {
+ @AfterAll
+ static void afterClearDown() {
ModelService.clear();
}
/**
* Set up parameters.
*/
- @Before
- public void setupParameters() {
+ @BeforeEach
+ void setupParameters() {
ParameterService.register(new SchemaParameters());
ParameterService.register(new ContextParameters());
ParameterService.register(new DistributorParameters());
@@ -138,8 +136,8 @@ public class ApexServiceTest {
/**
* Clear down parameters.
*/
- @After
- public void teardownParameters() {
+ @AfterEach
+ void teardownParameters() {
ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME);
ParameterService.deregister(ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
@@ -155,7 +153,7 @@ public class ApexServiceTest {
* @throws ApexException if there is a problem
*/
@Test
- public void testExecutionSet1() throws ApexException {
+ void testExecutionSet1() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
final long starttime = System.currentTimeMillis();
@@ -173,20 +171,20 @@ public class ApexServiceTest {
// Send some events
final Date testStartTime = new Date();
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ final Map<String, Object> eventDataMap = new HashMap<>();
eventDataMap.put("TestSlogan", "This is a test slogan");
eventDataMap.put("TestMatchCase", (byte) 123);
eventDataMap.put("TestTimestamp", testStartTime.getTime());
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event.setExecutionId(System.nanoTime());
event.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event);
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.setExecutionId(System.nanoTime());
event2.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event2);
@@ -217,7 +215,7 @@ public class ApexServiceTest {
* @throws ApexException if there is a problem
*/
@Test
- public void testExecutionSet1Sync() throws ApexException {
+ void testExecutionSet1Sync() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
final long starttime = System.currentTimeMillis();
@@ -233,24 +231,21 @@ public class ApexServiceTest {
// Send some events
final Date testStartTime = new Date();
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ final Map<String, Object> eventDataMap = new HashMap<>();
eventDataMap.put("TestSlogan", "This is a test slogan");
eventDataMap.put("TestMatchCase", (byte) 123);
eventDataMap.put("TestTimestamp", testStartTime.getTime());
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event1 =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event1.putAll(eventDataMap);
event1.setExecutionId(System.nanoTime());
- final ApexEventListener myEventListener1 = new ApexEventListener() {
- @Override
- public void onApexEvent(final ApexEvent responseEvent) {
- assertNotNull("Synchronous sendEventWait failed", responseEvent);
- assertEquals(event1.getExecutionId(), responseEvent.getExecutionId());
- waitFlag = false;
- }
+ final ApexEventListener myEventListener1 = responseEvent -> {
+ assertNotNull(responseEvent, "Synchronous sendEventWait failed");
+ assertEquals(event1.getExecutionId(), responseEvent.getExecutionId());
+ waitFlag = false;
};
waitFlag = true;
@@ -262,18 +257,15 @@ public class ApexServiceTest {
}
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.setExecutionId(System.nanoTime());
event2.putAll(eventDataMap);
- final ApexEventListener myEventListener2 = new ApexEventListener() {
- @Override
- public void onApexEvent(final ApexEvent responseEvent) {
- assertNotNull("Synchronous sendEventWait failed", responseEvent);
- assertEquals(event2.getExecutionId(), responseEvent.getExecutionId());
- assertEquals(2, actionEventsReceived);
- waitFlag = false;
- }
+ final ApexEventListener myEventListener2 = responseEvent -> {
+ assertNotNull(responseEvent, "Synchronous sendEventWait failed");
+ assertEquals(event2.getExecutionId(), responseEvent.getExecutionId());
+ assertEquals(2, actionEventsReceived);
+ waitFlag = false;
};
waitFlag = true;
@@ -305,69 +297,7 @@ public class ApexServiceTest {
* @throws ApexException if there is a problem
*/
@Test
- public void testExecutionSet2() throws ApexException {
- service.updateModel(parameters.getEngineKey(), apexModelString, true);
-
- final long starttime = System.currentTimeMillis();
- for (final AxArtifactKey engineKey : service.getEngineKeys()) {
- LOGGER.debug("{}", service.getStatus(engineKey));
- }
- while (!service.isStarted() && System.currentTimeMillis() - starttime < MAX_START_WAIT) {
- ThreadUtilities.sleep(200);
- }
- if (!service.isStarted()) {
- fail("Apex Service " + service.getKey() + " failed to start after " + MAX_START_WAIT + " ms");
- }
-
- final EngineServiceEventInterface engineServiceEventInterface = service.getEngineServiceEventInterface();
-
- // Send some events
- final Date testStartTime = new Date();
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
- eventDataMap.put("TestSlogan", "This is a test slogan");
- eventDataMap.put("TestMatchCase", (byte) 123);
- eventDataMap.put("TestTimestamp", testStartTime.getTime());
- eventDataMap.put("TestTemperature", 34.5445667);
-
- final ApexEvent event =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
- event.setExecutionId(System.nanoTime());
- event.putAll(eventDataMap);
- engineServiceEventInterface.sendEvent(event);
-
- final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
- event2.setExecutionId(System.nanoTime());
- event2.putAll(eventDataMap);
- engineServiceEventInterface.sendEvent(event2);
-
- // Wait for results
- final long recvtime = System.currentTimeMillis();
- while (actionEventsReceived < 2 && System.currentTimeMillis() - recvtime < MAX_RECV_WAIT) {
- ThreadUtilities.sleep(100);
- }
- ThreadUtilities.sleep(500);
- assertEquals(2, actionEventsReceived);
- actionEventsReceived = 0;
-
- // Stop all engines on this engine service
- final long stoptime = System.currentTimeMillis();
- service.stop();
- while (!service.isStopped() && System.currentTimeMillis() - stoptime < MAX_STOP_WAIT) {
- ThreadUtilities.sleep(200);
- }
- if (!service.isStopped()) {
- fail("Apex Service " + service.getKey() + " failed to stop after " + MAX_STOP_WAIT + " ms");
- }
- }
-
- /**
- * Update the engine then test the engine with 2 sample events - again.
- *
- * @throws ApexException if there is a problem
- */
- @Test
- public void testExecutionSet2Sync() throws ApexException {
+ void testExecutionSet2Sync() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
final long starttime = System.currentTimeMillis();
@@ -383,23 +313,20 @@ public class ApexServiceTest {
// Send some events
final Date testStartTime = new Date();
- final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ final Map<String, Object> eventDataMap = new HashMap<>();
eventDataMap.put("TestSlogan", "This is a test slogan");
eventDataMap.put("TestMatchCase", (byte) 123);
eventDataMap.put("TestTimestamp", testStartTime.getTime());
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event1 =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event1.putAll(eventDataMap);
- final ApexEventListener myEventListener1 = new ApexEventListener() {
- @Override
- public void onApexEvent(final ApexEvent responseEvent) {
- assertNotNull("Synchronous sendEventWait failed", responseEvent);
- assertEquals(event1.getExecutionId(), responseEvent.getExecutionId());
- waitFlag = false;
- }
+ final ApexEventListener myEventListener1 = responseEvent -> {
+ assertNotNull(responseEvent, "Synchronous sendEventWait failed");
+ assertEquals(event1.getExecutionId(), responseEvent.getExecutionId());
+ waitFlag = false;
};
waitFlag = true;
@@ -411,16 +338,13 @@ public class ApexServiceTest {
}
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.putAll(eventDataMap);
- final ApexEventListener myEventListener2 = new ApexEventListener() {
- @Override
- public void onApexEvent(final ApexEvent responseEvent) {
- assertNotNull("Synchronous sendEventWait failed", responseEvent);
- assertEquals(event2.getExecutionId(), responseEvent.getExecutionId());
- waitFlag = false;
- }
+ final ApexEventListener myEventListener2 = responseEvent -> {
+ assertNotNull(responseEvent, "Synchronous sendEventWait failed");
+ assertEquals(event2.getExecutionId(), responseEvent.getExecutionId());
+ waitFlag = false;
};
waitFlag = true;
@@ -454,8 +378,8 @@ public class ApexServiceTest {
*
* @throws ApexException if there is an error
*/
- @AfterClass
- public static void tearDown() throws Exception {
+ @AfterAll
+ static void tearDown() throws Exception {
// Stop all engines on this engine service
final long stoptime = System.currentTimeMillis();
service.stop();
@@ -481,14 +405,14 @@ public class ApexServiceTest {
*/
@Override
public synchronized void onApexEvent(final ApexEvent event) {
- LOGGER.debug("result 1 is:" + event);
+ LOGGER.debug("result 1 is:{}", event);
checkResult(event);
actionEventsReceived++;
final Date testStartTime = new Date((Long) event.get("TestTimestamp"));
final Date testEndTime = new Date();
- LOGGER.debug("policy execution time: " + (testEndTime.getTime() - testStartTime.getTime()) + "ms");
+ LOGGER.debug("policy execution time: {}ms", testEndTime.getTime() - testStartTime.getTime());
}
/**
@@ -503,13 +427,13 @@ public class ApexServiceTest {
assertEquals((byte) 123, result.get("TestMatchCase"));
assertEquals(34.5445667, result.get("TestTemperature"));
assertTrue(((byte) result.get("TestMatchCaseSelected")) >= 0
- && ((byte) result.get("TestMatchCaseSelected") <= 3));
+ && ((byte) result.get("TestMatchCaseSelected") <= 3));
assertTrue(((byte) result.get("TestEstablishCaseSelected")) >= 0
- && ((byte) result.get("TestEstablishCaseSelected") <= 3));
+ && ((byte) result.get("TestEstablishCaseSelected") <= 3));
assertTrue(((byte) result.get("TestDecideCaseSelected")) >= 0
- && ((byte) result.get("TestDecideCaseSelected") <= 3));
+ && ((byte) result.get("TestDecideCaseSelected") <= 3));
assertTrue(
- ((byte) result.get("TestActCaseSelected")) >= 0 && ((byte) result.get("TestActCaseSelected") <= 3));
+ ((byte) result.get("TestActCaseSelected")) >= 0 && ((byte) result.get("TestActCaseSelected") <= 3));
}
}
@@ -519,11 +443,11 @@ public class ApexServiceTest {
* @param policyModel the eca policy model
* @return the model string
* @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
*/
private static String getModelString(final AxPolicyModel policyModel) throws ApexModelException, IOException {
try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
- new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(policyModel, baOutputStream);
+ new ApexModelWriter<>(AxPolicyModel.class).write(policyModel, baOutputStream);
return baOutputStream.toString();
}
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java
index 226756b1c..0a9d69b19 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -22,7 +22,6 @@
package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
-import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.EnumMap;
@@ -56,27 +55,28 @@ public class DummyApexEventConsumer implements ApexEventConsumer {
private String name = null;
// The peer references for this event handler
- private Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
+ private final Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
+ new EnumMap<>(EventHandlerPeeredMode.class);
private DummyCarrierTechnologyParameters dummyConsumerProperties = null;
@Override
public void init(final String consumerName, final EventHandlerParameters consumerParameters,
- final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
+ final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
this.eventReceiver = incomingEventReceiver;
this.name = consumerName;
// Check and get the properties
if (!(consumerParameters.getCarrierTechnologyParameters() instanceof DummyCarrierTechnologyParameters)) {
String message = "specified consumer properties of type \""
- + consumerParameters.getCarrierTechnologyParameters().getClass().getName()
- + "\" are not applicable to a dummy consumer";
+ + consumerParameters.getCarrierTechnologyParameters().getClass().getName()
+ + "\" are not applicable to a dummy consumer";
LOGGER.warn(message);
throw new ApexEventException(message);
}
dummyConsumerProperties = (DummyCarrierTechnologyParameters) consumerParameters
- .getCarrierTechnologyParameters();
+ .getCarrierTechnologyParameters();
}
@Override
@@ -109,10 +109,10 @@ public class DummyApexEventConsumer implements ApexEventConsumer {
public void run() {
Properties executionProperties = new Properties();
try {
- executionProperties.load(new FileInputStream(new File(dummyConsumerProperties.getPropertyFileName())));
+ executionProperties.load(new FileInputStream(dummyConsumerProperties.getPropertyFileName()));
} catch (IOException e1) {
String message = "reading of executor properties for testing failed from file: "
- + dummyConsumerProperties.getPropertyFileName();
+ + dummyConsumerProperties.getPropertyFileName();
LOGGER.warn(message);
throw new ApexEventRuntimeException(message);
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventProducer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventProducer.java
index b22b25883..ca25aea40 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventProducer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventProducer.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,11 +56,12 @@ public class DummyApexEventProducer implements ApexEventProducer {
private String name = null;
// The peer references for this event handler
- private Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
+ private final Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
+ new EnumMap<>(EventHandlerPeeredMode.class);
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the Properties
@@ -70,7 +71,7 @@ public class DummyApexEventProducer implements ApexEventProducer {
throw new ApexEventException(message);
}
dummyProducerProperties =
- (DummyCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ (DummyCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
new File(dummyProducerProperties.getPropertyFileName()).delete();
}
@@ -96,10 +97,10 @@ public class DummyApexEventProducer implements ApexEventProducer {
*/
@Override
public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
- final Object eventAsJsonString) {
+ final Object eventAsJsonString) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache =
- (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
@@ -114,17 +115,17 @@ public class DummyApexEventProducer implements ApexEventProducer {
}
if (!dummyProducerProperties.getTestToRun().equals(testEvent.getTestToRun())) {
String message = "tests in received test event and parameters do not match " + testEvent.getTestToRun()
- + ":" + dummyProducerProperties.getTestToRun();
+ + ":" + dummyProducerProperties.getTestToRun();
LOGGER.warn(message);
throw new ApexEventRuntimeException(message);
}
try {
- executionProperties.store(new FileOutputStream(new File(dummyProducerProperties.getPropertyFileName())),
- "");
+ executionProperties.store(new FileOutputStream(dummyProducerProperties.getPropertyFileName()),
+ "");
} catch (IOException ioe) {
String message = "writing of executor properties for testing failed from file: "
- + dummyProducerProperties.getPropertyFileName();
+ + dummyProducerProperties.getPropertyFileName();
LOGGER.warn(message, ioe);
throw new ApexEventRuntimeException(message, ioe);
}
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/TestExecutionProperties.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/TestExecutionProperties.java
index d4855f988..e5cdcdc03 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/TestExecutionProperties.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/TestExecutionProperties.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,27 +22,27 @@
package org.onap.policy.apex.testsuites.integration.uservice.executionproperties;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
import org.onap.policy.apex.service.engine.main.ApexMain;
/**
* This class runs integration tests for execution properties.
*/
-public class TestExecutionProperties {
+class TestExecutionProperties {
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
@@ -50,7 +50,7 @@ public class TestExecutionProperties {
* Test read only execution properties are returned from policy.
*/
@Test
- public void testReadOnly() throws Exception {
+ void testReadOnly() throws Exception {
testExecutionProperties("readOnly");
}
@@ -58,7 +58,7 @@ public class TestExecutionProperties {
* Test where execution properties set in task.
*/
@Test
- public void testEmptyToDefined() throws Exception {
+ void testEmptyToDefined() throws Exception {
testExecutionProperties("emptyToDefined");
}
@@ -66,7 +66,7 @@ public class TestExecutionProperties {
* Test where execution properties cleared in task.
*/
@Test
- public void testDefinedToEmpty() throws Exception {
+ void testDefinedToEmpty() throws Exception {
testExecutionProperties("definedToEmpty");
}
@@ -74,7 +74,7 @@ public class TestExecutionProperties {
* Test where an execution properties added in task.
*/
@Test
- public void testAddProperty() throws Exception {
+ void testAddProperty() throws Exception {
testExecutionProperties("addProperty");
}
@@ -82,7 +82,7 @@ public class TestExecutionProperties {
* Test empty properties are transferred correctly.
*/
@Test
- public void testEmptyToEmpty() throws Exception {
+ void testEmptyToEmpty() throws Exception {
testExecutionProperties("emptyToEmpty");
}
@@ -117,15 +117,15 @@ public class TestExecutionProperties {
// @formatter:on
final ApexMain apexMain = new ApexMain(args);
- await().atMost(1, TimeUnit.SECONDS).until(() -> apexMain.isAlive());
- await().atMost(10, TimeUnit.SECONDS).until(() -> outFile.exists());
+ await().atMost(1, TimeUnit.SECONDS).until(apexMain::isAlive);
+ await().atMost(10, TimeUnit.SECONDS).until(outFile::exists);
await().atMost(1, TimeUnit.SECONDS).until(() -> outFile.length() > 0);
apexMain.shutdown();
Properties expectedProperties = new Properties();
expectedProperties.load(new FileInputStream(
- new File("src/test/resources/testdata/executionproperties/" + testName + "_out_expected.properties")));
+ "src/test/resources/testdata/executionproperties/" + testName + "_out_expected.properties"));
Properties actualProperties = new Properties();
actualProperties.load(new FileInputStream(outFile));
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java
index f78fd12cd..44908f4b1 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020,2023 Nordix Foundation.
+ * Copyright (C) 2020, 2023-2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,16 +22,16 @@
package org.onap.policy.apex.testsuites.integration.uservice.taskparameters;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Response;
import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
@@ -48,7 +48,7 @@ import org.slf4j.ext.XLoggerFactory;
* dynamically populated using executionProperties is hit and values get updated in
* {@link RestClientEndpointForTaskParameters} which acts as a temporary server for requests.
*/
-public class TestTaskParameters {
+class TestTaskParameters {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestTaskParameters.class);
@@ -61,8 +61,8 @@ public class TestTaskParameters {
*
* @throws Exception the exception
*/
- @BeforeClass
- public static void setUp() throws Exception {
+ @BeforeAll
+ static void setUp() throws Exception {
if (NetworkUtil.isTcpPortOpen(HOST, PORT, 3, 50L)) {
throw new IllegalStateException("port " + PORT + " is still in use");
}
@@ -85,10 +85,9 @@ public class TestTaskParameters {
/**
* Tear down.
*
- * @throws Exception the exception
*/
- @AfterClass
- public static void tearDown() throws Exception {
+ @AfterAll
+ static void tearDown() {
if (server != null) {
server.stop();
}
@@ -97,8 +96,8 @@ public class TestTaskParameters {
/**
* Clear relative file root environment variable.
*/
- @Before
- public void clearRelativeFileRoot() {
+ @BeforeEach
+ void clearRelativeFileRoot() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
@@ -107,7 +106,7 @@ public class TestTaskParameters {
* updated to all tasks.
*/
@Test
- public void testTaskParameters_with_noTaskIds() throws Exception {
+ void testTaskParameters_with_noTaskIds() throws Exception {
String responseEntity = testTaskParameters(
"src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_noTaskIds.json");
assertTrue(responseEntity.contains("{\"closedLoopId\": closedLoopId123,\"serviceId\": serviceId123}"));
@@ -118,7 +117,7 @@ public class TestTaskParameters {
* that particular task alone.
*/
@Test
- public void testTaskParameters_with_validTaskIds() throws Exception {
+ void testTaskParameters_with_validTaskIds() throws Exception {
String responseEntity = testTaskParameters(
"src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_validTaskIds.json");
assertTrue(responseEntity.contains("{\"closedLoopId\": closedLoopIdxyz,\"serviceId\": serviceIdxyz}"));
@@ -130,7 +129,7 @@ public class TestTaskParameters {
* accessible in the task
*/
@Test
- public void testTaskParameters_with_invalidTaskIds() throws Exception {
+ void testTaskParameters_with_invalidTaskIds() throws Exception {
String responseEntity = testTaskParameters(
"src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_invalidTaskIds.json");
assertTrue(responseEntity.contains("{\"closedLoopId\": INVALID - closedLoopId not available in TaskParameters,"
@@ -170,6 +169,7 @@ public class TestTaskParameters {
String responseEntity = response.readEntity(String.class);
LOGGER.info("testTaskParameters-OUTSTRING=\n {}", responseEntity);
+ client.close();
return responseEntity;
}
}
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java
index 747e9d6fa..2a1f238cd 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStatsTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,22 +21,21 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the EventBatchStats class.
- *
*/
-public class EventBatchStatsTest {
+class EventBatchStatsTest {
@Test
- public void test() {
+ void test() {
EventBatchStats stats = new EventBatchStats(new EventBatch(1, "Label"));
assertNotNull(stats);
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java
index 821cb68bd..9ee880f34 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,20 +21,19 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.InputEvent;
/**
* Test the EventBatch class.
- *
*/
-public class EventBatchTest {
+class EventBatchTest {
@Test
- public void testEventBatch() {
+ void testEventBatch() {
EventBatch batch = new EventBatch(1, "TheApexClient");
assertNotNull(batch);
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java
index 75d6d65f3..b4411a9b0 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,27 +21,25 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import jakarta.inject.Provider;
import jakarta.ws.rs.core.Response;
import org.glassfish.grizzly.http.server.Request;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent;
/**
* Test the EventGeneratorEndpoint class.
- *
*/
-@RunWith(MockitoJUnitRunner.class)
-public class EventGeneratorEndpointTest {
+@ExtendWith(MockitoExtension.class)
+class EventGeneratorEndpointTest {
@Mock
private Provider<Request> httpRequestProviderMock;
@@ -50,21 +48,18 @@ public class EventGeneratorEndpointTest {
/**
* Set up mocking of the engine service facade.
- *
- * @throws ApexException on engine service facade setup errors
*/
- @Before
- public void initializeMocking() throws ApexException {
-
- Mockito.doReturn(httpRequestMock).when(httpRequestProviderMock).get();
+ @BeforeEach
+ void initializeMocking() {
- Mockito.doReturn("zooby").when(httpRequestMock).getRemoteHost();
- Mockito.doReturn(12345).when(httpRequestMock).getRemotePort();
+ Mockito.lenient().doReturn(httpRequestMock).when(httpRequestProviderMock).get();
+ Mockito.lenient().doReturn("zooby").when(httpRequestMock).getRemoteHost();
+ Mockito.lenient().doReturn(12345).when(httpRequestMock).getRemotePort();
}
@Test
- public void testEventGeneratorEndpointGetStats() {
+ void testEventGeneratorEndpointGetStats() {
EventGeneratorEndpoint.clearEventGenerationStats();
EventGeneratorEndpoint.setFinished(false);
@@ -73,10 +68,11 @@ public class EventGeneratorEndpointTest {
Response stats = egep.serviceGetStats();
assertEquals(200, stats.getStatus());
+ stats.close();
}
@Test
- public void testEventGeneratorEndpointGetEventsZeroBatchCount() {
+ void testEventGeneratorEndpointGetEventsZeroBatchCount() {
EventGeneratorParameters incomingParameters = new EventGeneratorParameters();
incomingParameters.setBatchCount(1);
@@ -96,7 +92,7 @@ public class EventGeneratorEndpointTest {
}
@Test
- public void testEventGeneratorEndpointPostBadEvent() {
+ void testEventGeneratorEndpointPostBadEvent() {
EventGeneratorParameters incomingParameters = new EventGeneratorParameters();
incomingParameters.setBatchCount(1);
@@ -112,5 +108,6 @@ public class EventGeneratorEndpointTest {
Response events = egep.postEventResponse(oe.asJson());
assertEquals(409, events.getStatus());
+ events.close();
}
}
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java
index fd41d81e6..1714f43b4 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersHandlerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,162 +23,169 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.commons.cli.ParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test event generator parameters.
*/
-public class EventGeneratorParametersHandlerTest {
+class EventGeneratorParametersHandlerTest {
@Test
- public void testEventGeneratorParameterhandler() throws ParseException {
+ void testEventGeneratorParameterHandler() throws ParseException {
EventGeneratorParameterHandler handler = new EventGeneratorParameterHandler();
assertNotNull(handler);
- String[] args = { "-h" };
- EventGeneratorParameters parameters = handler.parse(args);
- assertNull(parameters);
- assertEquals("usage: EventGenerator [options...]",
- handler.getHelp(EventGenerator.class.getSimpleName()).substring(0, 34));
-
- args = new String[] {};
- parameters = handler.parse(args);
- assertEquals("localhost", parameters.getHost());
- assertEquals(32801, parameters.getPort());
-
- args = new String[] { "-H", "MyHost" };
- parameters = handler.parse(args);
- assertEquals("MyHost", parameters.getHost());
-
- args = new String[] { "-p", "12345" };
- parameters = handler.parse(args);
- assertEquals(12345, parameters.getPort());
-
-
- args = new String[] { "-H", "MyHost", "-p", "12345" };
- parameters = handler.parse(args);
- assertEquals("MyHost", parameters.getHost());
- assertEquals(12345, parameters.getPort());
-
- args = new String[] { "-c", "src/test/resources/parameters/unit/Valid.json" };
- parameters = handler.parse(args);
- assertEquals("ValidPars", parameters.getName());
- assertEquals("FileHost", parameters.getHost());
- assertEquals(54321, parameters.getPort());
-
- args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json" };
- parameters = handler.parse(args);
- assertEquals("localhost", parameters.getHost());
- assertEquals(32801, parameters.getPort());
-
- args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bc", "100" };
- parameters = handler.parse(args);
- assertEquals(100, parameters.getBatchCount());
+ assertValidInputs(handler);
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bc", "-1" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bc", "-1"};
handler.parse(arguments);
}).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
- "\"batchCount\" value \"-1\" INVALID, is below the minimum");
- args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bs", "12345" };
- parameters = handler.parse(args);
- assertEquals(12345, parameters.getBatchSize());
+ "\"batchCount\" value \"-1\" INVALID, is below the minimum");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bs", "0" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bs", "0"};
handler.parse(arguments);
}).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
- "\"batchSize\" value \"0\" INVALID, is below the minimum");
- args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bd", "1000" };
- parameters = handler.parse(args);
+ "\"batchSize\" value \"0\" INVALID, is below the minimum");
+
+
+ String[] args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bd", "1000"};
+ EventGeneratorParameters parameters = handler.parse(args);
assertEquals(1000, parameters.getDelayBetweenBatches());
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-bd", "-1" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bd", "-1"};
handler.parse(arguments);
}).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
- "\"batchSize\" value \"1\" INVALID, is below the minimum");
+ "\"batchSize\" value \"1\" INVALID, is below the minimum");
- args = new String[] { "-c", "src/test/resources/parameters/unit/Default.json", "-o", "Zooby" };
+ args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-o", "Zooby"};
parameters = handler.parse(args);
assertEquals("Zooby", parameters.getOutFile());
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-z" };
+ String[] arguments = new String[] {"-z"};
handler.parse(arguments);
}).hasMessage("Unrecognized option: -z");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-H" };
+ String[] arguments = new String[] {"-H"};
handler.parse(arguments);
}).hasMessage("Missing argument for option: H");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-p" };
+ String[] arguments = new String[] {"-p"};
handler.parse(arguments);
}).hasMessage("Missing argument for option: p");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-p", "12345", "-z" };
+ String[] arguments = new String[] {"-p", "12345", "-z"};
handler.parse(arguments);
}).hasMessage("Unrecognized option: -z");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-p", "12345", "somethingElse" };
+ String[] arguments = new String[] {"-p", "12345", "somethingElse"};
handler.parse(arguments);
}).hasMessage("too many command line arguments specified : [somethingElse]");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c" };
+ String[] arguments = new String[] {"-c"};
handler.parse(arguments);
}).hasMessage("Missing argument for option: c");
- args = new String[] { "-H", "MyHost", "-c", "src/test/resources/parameters/unit/Valid.json" };
+ args = new String[] {"-H", "MyHost", "-c", "src/test/resources/parameters/unit/Valid.json"};
parameters = handler.parse(args);
assertEquals("MyHost", parameters.getHost());
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/NonExistant.json" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/NonExistant.json"};
handler.parse(arguments);
}).hasMessageStartingWith("Could not read parameters from configuration file ");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/BadHost.json" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/BadHost.json"};
handler.parse(arguments);
}).hasMessage("Error parsing JSON parameters from configuration file "
- + "\"src/test/resources/parameters/unit/BadHost.json\": "
- + "com.google.gson.stream.MalformedJsonException: "
- + "Unexpected value at line 3 column 14 path $.host");
+ + "\"src/test/resources/parameters/unit/BadHost.json\": "
+ + "com.google.gson.stream.MalformedJsonException: "
+ + "Unexpected value at line 3 column 14 path $.host");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/BadPort.json" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/BadPort.json"};
handler.parse(arguments);
}).hasMessage("Error parsing JSON parameters from configuration file "
- + "\"src/test/resources/parameters/unit/BadPort.json\": "
- + "java.lang.IllegalStateException: Expected an int "
- + "but was BOOLEAN at line 4 column 18 path $.port");
+ + "\"src/test/resources/parameters/unit/BadPort.json\": "
+ + "java.lang.IllegalStateException: Expected an int "
+ + "but was BOOLEAN at line 4 column 18 path $.port");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/Empty.json" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/Empty.json"};
handler.parse(arguments);
}).hasMessage("No parameters found in configuration file "
- + "\"src/test/resources/parameters/unit/Empty.json\"");
+ + "\"src/test/resources/parameters/unit/Empty.json\"");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-c", "src/test/resources/parameters/unit/NullHost.json" };
+ String[] arguments = new String[] {"-c", "src/test/resources/parameters/unit/NullHost.json"};
handler.parse(arguments);
}).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
- "\"host\" value \"null\" INVALID, is null");
+ "\"host\" value \"null\" INVALID, is null");
assertThatThrownBy(() -> {
- String[] arguments = new String[] { "-p", "1023" };
+ String[] arguments = new String[] {"-p", "1023"};
handler.parse(arguments);
}).hasMessageContaining("specified parameters are not valid", "EventGeneratorParameters",
- "\"port\" value \"1023\" INVALID, is below the minimum");
+ "\"port\" value \"1023\" INVALID, is below the minimum");
+ }
+
+ private static void assertValidInputs(EventGeneratorParameterHandler handler) throws ParseException {
+ String[] args = {"-h"};
+ EventGeneratorParameters parameters = handler.parse(args);
+ assertNull(parameters);
+ assertEquals("usage: EventGenerator [options...]",
+ handler.getHelp(EventGenerator.class.getSimpleName()).substring(0, 34));
+
+ args = new String[] {};
+ parameters = handler.parse(args);
+ assertEquals("localhost", parameters.getHost());
+ assertEquals(32801, parameters.getPort());
+
+ args = new String[] {"-H", "MyHost"};
+ parameters = handler.parse(args);
+ assertEquals("MyHost", parameters.getHost());
+
+ args = new String[] {"-p", "12345"};
+ parameters = handler.parse(args);
+ assertEquals(12345, parameters.getPort());
+
+
+ args = new String[] {"-H", "MyHost", "-p", "12345"};
+ parameters = handler.parse(args);
+ assertEquals("MyHost", parameters.getHost());
+ assertEquals(12345, parameters.getPort());
+
+ args = new String[] {"-c", "src/test/resources/parameters/unit/Valid.json"};
+ parameters = handler.parse(args);
+ assertEquals("ValidPars", parameters.getName());
+ assertEquals("FileHost", parameters.getHost());
+ assertEquals(54321, parameters.getPort());
+
+ args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json"};
+ parameters = handler.parse(args);
+ assertEquals("localhost", parameters.getHost());
+ assertEquals(32801, parameters.getPort());
+
+ args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bc", "100"};
+ parameters = handler.parse(args);
+ assertEquals(100, parameters.getBatchCount());
+
+ args = new String[] {"-c", "src/test/resources/parameters/unit/Default.json", "-bs", "12345"};
+ parameters = handler.parse(args);
+ assertEquals(12345, parameters.getBatchSize());
}
}
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java
index 8d97bb7c5..ebacde846 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorParametersTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,19 +21,19 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test event generator parameters.
*/
-public class EventGeneratorParametersTest {
+class EventGeneratorParametersTest {
@Test
- public void testEventGeneratorParameters() {
+ void testEventGeneratorParameters() {
EventGeneratorParameters parameters = new EventGeneratorParameters();
parameters.setName("TheName");
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java
index f8854b8c7..a8cacf425 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStatsTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,20 +21,20 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the EventGeneratorStats class.
- *
*/
-public class EventGeneratorStatsTest {
+class EventGeneratorStatsTest {
+
@Test
- public void testEventGeneratorStats() {
+ void testEventGeneratorStats() {
Map<Integer, EventBatch> batchMap = new LinkedHashMap<>();
EventGeneratorStats egs = new EventGeneratorStats(batchMap);
assertNotNull(egs);
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java
index 08860b013..e874ee9c0 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +23,13 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
@@ -37,7 +38,7 @@ import org.onap.policy.apex.service.engine.main.ApexMain;
/**
* This class tests the event generator.
*/
-public class EventGeneratorTest {
+class EventGeneratorTest {
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final PrintStream stdout = System.out;
@@ -48,14 +49,14 @@ public class EventGeneratorTest {
* @throws ApexException on Apex exceptions
*/
@Test
- public void testEventGeneration() throws ApexException {
+ void testEventGeneration() throws ApexException {
EventGeneratorParameters pars = new EventGeneratorParameters();
pars.setBatchCount(1);
pars.setBatchSize(10);
EventGenerator eventGenerator = new EventGenerator(pars);
- final String[] args = { "-rfr", "target", "-p",
- "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json" };
+ final String[] args = {"-rfr", "target", "-p",
+ "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json"};
final ApexMain apexMain = new ApexMain(args);
@@ -72,10 +73,10 @@ public class EventGeneratorTest {
}
@Test
- public void testEventGeneratorBadParams() {
+ void testEventGeneratorBadParams() {
System.setOut(new PrintStream(outContent));
- final String[] args = { "-zzz" };
+ final String[] args = {"-zzz"};
EventGenerator.main(args);
@@ -87,10 +88,10 @@ public class EventGeneratorTest {
}
@Test
- public void testEventGeneratorHelp() {
+ void testEventGeneratorHelp() {
System.setOut(new PrintStream(outContent));
- final String[] args = { "-h" };
+ final String[] args = {"-h"};
EventGenerator.main(args);
@@ -102,16 +103,11 @@ public class EventGeneratorTest {
}
@Test
- public void testEventGeneratorStart() {
+ void testEventGeneratorStart() {
System.setOut(new PrintStream(outContent));
- (new Thread() {
- @Override
- public void run() {
- EventGenerator.main(null);
- }
- }).start();
+ (new Thread(() -> EventGenerator.main(null))).start();
ThreadUtilities.sleep(1000);
final String outString = outContent.toString();
@@ -123,7 +119,7 @@ public class EventGeneratorTest {
}
@Test
- public void testEventGeneratorOutfileGood() {
+ void testEventGeneratorOutfileGood() {
EventGeneratorParameters pars = new EventGeneratorParameters();
pars.setOutFile("target/statsOutFile.json");
@@ -134,11 +130,11 @@ public class EventGeneratorTest {
File outFile = new File("target/statsOutFile.json");
assertTrue(outFile.exists());
- outFile.delete();
+ assertTrue(outFile.delete());
}
@Test
- public void testEventGeneratorOutfileBad() {
+ void testEventGeneratorOutfileBad() {
EventGeneratorParameters pars = new EventGeneratorParameters();
pars.setOutFile("/I/Dont/Exist\0");
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java
index 6a3a8cc85..82477f959 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEventTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,19 +21,18 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the InputEvent class.
- *
*/
-public class InputEventTest {
+class InputEventTest {
@Test
- public void testInputEvent() {
+ void testInputEvent() {
InputEvent ie = new InputEvent();
assertNotNull(ie);
diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java
index 8af87ddbd..afcc61e8c 100644
--- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java
+++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEventTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,19 +21,18 @@
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the OutputEvent class.
- *
*/
-public class OutputEventTest {
+class OutputEventTest {
@Test
- public void test() {
+ void test() {
OutputEvent oe = new OutputEvent();
assertNotNull(oe);