aboutsummaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test/src/test
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 /testsuites/integration/integration-uservice-test/src/test
parente9b746340711ddfccee7ac0f669ace626b1b3d46 (diff)
Convert junit4 to junit5
- testsuites module Issue-ID: POLICY-5041 Change-Id: I1d9984651f34f1dca253094c26da1dd593128966 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'testsuites/integration/integration-uservice-test/src/test')
-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
30 files changed, 569 insertions, 1128 deletions
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;
}
}