aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--LICENSE.txt2
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java2
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java76
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java95
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java23
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java24
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java9
-rw-r--r--context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java48
-rw-r--r--core/core-infrastructure/pom.xml4
-rw-r--r--packages/apex-pdp-package-full/pom.xml2
-rw-r--r--packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexApps.bat)0
-rwxr-xr-xpackages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexApps.sh)0
-rwxr-xr-xpackages/apex-pdp-package-full/src/main/package/scripts/apexBash.sh (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexBash.sh)0
-rw-r--r--packages/apex-pdp-package-full/src/main/package/scripts/apexCLIEditor.bat (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexCLIEditor.bat)0
-rwxr-xr-xpackages/apex-pdp-package-full/src/main/package/scripts/apexCLIEditor.sh (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexCLIEditor.sh)0
-rw-r--r--packages/apex-pdp-package-full/src/main/package/scripts/apexEngine.bat (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexEngine.bat)0
-rwxr-xr-xpackages/apex-pdp-package-full/src/main/package/scripts/apexEngine.sh (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexEngine.sh)0
-rw-r--r--packages/apex-pdp-package-full/src/main/package/scripts/apexRESTEditor.bat (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexRESTEditor.bat)0
-rwxr-xr-xpackages/apex-pdp-package-full/src/main/package/scripts/apexRESTEditor.sh (renamed from packages/apex-pdp-package-full/src/main/package/bin/apexRESTEditor.sh)0
-rw-r--r--packages/apex-pdp-package-full/src/main/package/tarball/assembly.xml2
-rw-r--r--plugins/plugins-context/context-locking/context-locking-curator/pom.xml6
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/pom.xml6
-rw-r--r--plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java10
-rw-r--r--plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java10
-rw-r--r--testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java11
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml13
-rw-r--r--testsuites/integration/integration-context-test/src/test/resources/logback-test.xml76
-rw-r--r--testsuites/integration/integration-executor-test/pom.xml89
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexActionListener.java101
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngine.java129
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java47
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java52
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java47
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java47
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java47
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java188
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexModelExport.java114
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexPolicyModelAnalysis.java38
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyCreateModelFiles.java73
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyDBWrite.java59
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModel.java81
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModelCreator.java61
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java102
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java158
-rw-r--r--testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml69
-rw-r--r--testsuites/integration/integration-executor-test/src/test/resources/logback-test.xml78
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java12
-rw-r--r--testsuites/integration/pom.xml3
49 files changed, 1842 insertions, 173 deletions
diff --git a/.gitignore b/.gitignore
index 8f3629739..50d9bc3ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,5 +7,6 @@
target
.metadata/
/bin/
+bin/
derby.log
.checkstyle
diff --git a/LICENSE.txt b/LICENSE.txt
index e92ae50cd..0a1fe4101 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -12,5 +12,3 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
index e789ae90c..dbf5ab2c6 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
@@ -308,7 +308,7 @@ public class SequentialContextInstantiation {
testBadItem001.setByteValue(BYTE_VAL);
testBadItem002.setIntValue(INT_VAL);
testBadItem003.setLongValue(LONG_VAL);
- testBadItem004.setFloatValue(new Float(FLOAT_VAL));
+ testBadItem004.setFloatValue(FLOAT_VAL);
testBadItem005.setDoubleValue(PI_VAL);
testBadItem006.setStringValue(STRING_GLOBAL_VAL);
testBadItem007.setLongValue(testDate.getTime());
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
index 2eea957c6..b62364e9d 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
@@ -20,7 +20,13 @@
package org.onap.policy.apex.context.test.locking;
+import java.io.Closeable;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
@@ -28,6 +34,7 @@ import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
import org.onap.policy.apex.context.test.concepts.TestContextLongItem;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.context.test.utils.IntegrationThreadFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
@@ -41,8 +48,6 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ConcurrentContext {
- private static final int TEN_MILLISECONDS = 10;
-
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContext.class);
@@ -75,45 +80,70 @@ public class ConcurrentContext {
LOGGER.debug("starting JVMs and threads . . .");
- final Thread[] threadArray = new Thread[threadCount];
+ final String name = getThreadFactoryName(jvmCount, testType);
+ final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(name);
+ final ExecutorService executorService = Executors.newFixedThreadPool(threadCount, threadFactory);
+
+ final List<Closeable> tasks = new ArrayList<>(threadCount);
+
+ addShutDownHook(tasks);
// Check if we have a single JVM or multiple JVMs
- int runningThreadCount = -1;
if (jvmCount == 1) {
// Run everything in this JVM
for (int t = 0; t < threadCount; t++) {
- threadArray[t] = new Thread(new ConcurrentContextThread(0, t, threadLoops));
- threadArray[t].setName(testType + ":TestConcurrentContextThread_0_" + t);
- threadArray[t].start();
+ final ConcurrentContextThread task = new ConcurrentContextThread(0, t, threadLoops);
+ tasks.add(task);
+ executorService.execute(task);
}
- runningThreadCount = threadCount;
} else {
// Spawn JVMs to run the tests
for (int j = 0; j < jvmCount; j++) {
- threadArray[j] = new Thread(new ConcurrentContextJVMThread(testType, j, threadCount, threadLoops));
- threadArray[j].setName(testType + ":TestConcurrentContextJVMThread_" + j);
- threadArray[j].start();
+ final ConcurrentContextJVMThread task =
+ new ConcurrentContextJVMThread(testType, j, threadCount, threadLoops);
+ tasks.add(task);
+ executorService.execute(task);
}
- runningThreadCount = jvmCount;
}
- boolean allFinished;
- do {
- allFinished = true;
- for (int i = 0; i < runningThreadCount; i++) {
- if (threadArray[i].isAlive()) {
- allFinished = false;
+ try {
+ executorService.shutdown();
+ // wait for threads to finish, if not Timeout
+ executorService.awaitTermination(10, TimeUnit.MINUTES);
+ } catch (final InterruptedException interruptedException) {
+ LOGGER.error("Exception while waiting for threads to finish", interruptedException);
+ // restore the interrupt status
+ Thread.currentThread().interrupt();
+ }
+
+ LOGGER.info("Shutting down now ...");
+ executorService.shutdownNow();
+
+ return concurrentContext.verifyAndClearContext(jvmCount, threadCount, threadLoops);
+ }
+
+
+ private void addShutDownHook(final List<Closeable> tasks) {
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ LOGGER.info("Shutting down ...");
+ for (final Closeable task : tasks) {
try {
- Thread.sleep(TEN_MILLISECONDS);
- } catch (final Exception e) {
+ task.close();
+ } catch (final IOException ioException) {
+ LOGGER.error("Unable to close task ... ", ioException);
}
- break;
}
}
- } while (!allFinished);
+ });
+ }
- return concurrentContext.verifyAndClearContext(jvmCount, threadCount, threadLoops);
+
+ private String getThreadFactoryName(final int jvmCount, final String testType) {
+ return jvmCount == 1 ? testType + ":TestConcurrentContextThread_0_"
+ : testType + ":TestConcurrentContextJVMThread_";
}
/**
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
index 0145bd161..e2a6b0da0 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVM.java
@@ -20,20 +20,25 @@
package org.onap.policy.apex.context.test.locking;
-import com.google.gson.Gson;
-
import java.net.InetAddress;
import java.net.NetworkInterface;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.List;
import java.util.Map.Entry;
import java.util.TreeSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.Distributor;
import org.onap.policy.apex.context.impl.distribution.DistributorFactory;
import org.onap.policy.apex.context.test.factory.TestContextAlbumFactory;
+import org.onap.policy.apex.context.test.utils.IntegrationThreadFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
@@ -42,6 +47,8 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+import com.google.gson.Gson;
+
/**
* The Class ConcurrentContextJVM tests concurrent use of context in a single JVM.
*
@@ -51,9 +58,16 @@ public final class ConcurrentContextJVM {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJVM.class);
- private static final int TEN_MILLISECONDS = 10;
private static final int IPV4_ADDRESS_LENGTH = 4;
+ private final int jvmNo;
+
+ private final int threadCount;
+
+ private final int threadLoops;
+
+ private final ExecutorService executorService;
+
/**
* The Constructor.
*
@@ -63,9 +77,15 @@ public final class ConcurrentContextJVM {
* @param threadLoops the thread loops
* @throws ApexException the apex exception
*/
- private ConcurrentContextJVM(final String testType, final int jvmNo, final int threadCount, final int threadLoops)
- throws ApexException {
- super();
+ private ConcurrentContextJVM(final String testType, final int jvmNo, final int threadCount, final int threadLoops) {
+ this.jvmNo = jvmNo;
+ this.threadCount = threadCount;
+ this.threadLoops = threadLoops;
+ final String name = testType + ":ConcurrentContextThread_" + jvmNo;
+ this.executorService = Executors.newFixedThreadPool(threadCount, new IntegrationThreadFactory(name));
+ }
+
+ public void execute() throws ApexException {
LOGGER.debug("starting JVMs and threads . . .");
final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributor" + jvmNo, "0.0.1");
@@ -87,34 +107,30 @@ public final class ConcurrentContextJVM {
assert (lTypeAlbum != null);
lTypeAlbum.setUserArtifactStack(usedArtifactStackArray);
- final Thread[] threadArray = new Thread[threadCount];
+ final List<Future<?>> tasks = new ArrayList<>(threadCount);
for (int t = 0; t < threadCount; t++) {
- threadArray[t] = new Thread(new ConcurrentContextThread(jvmNo, t, threadLoops));
- threadArray[t].setName(testType + ":ConcurrentContextThread_" + jvmNo + "_" + t);
- threadArray[t].start();
- LOGGER.debug("started thread " + threadArray[t].getName());
+ tasks.add(executorService.submit(new ConcurrentContextThread(jvmNo, t, threadLoops)));
}
- boolean allFinished;
- do {
- allFinished = true;
- for (int t = 0; t < threadCount; t++) {
- if (threadArray[t].isAlive()) {
- allFinished = false;
- try {
- Thread.sleep(TEN_MILLISECONDS);
- } catch (final Exception e) {
- }
- break;
- }
- }
- } while (!allFinished);
+ try {
+ executorService.shutdown();
+ // wait for threads to finish, if not Timeout
+ executorService.awaitTermination(10, TimeUnit.MINUTES);
+ } catch (final InterruptedException interruptedException) {
+ LOGGER.error("Exception while waiting for threads to finish", interruptedException);
+ // restore the interrupt status
+ Thread.currentThread().interrupt();
+ }
LOGGER.debug("threads finished, end value is {}", lTypeAlbum.get("testValue"));
contextDistributor.clear();
+ LOGGER.info("Shutting down now ... ");
+ executorService.shutdownNow();
}
+
+
/**
* The main method.
*
@@ -129,7 +145,7 @@ public final class ConcurrentContextJVM {
// CHECKSTYLE:OFF: checkstyle:magicNumber
// An even number of arguments greater than 3
- if (args.length < 4 || (args.length % 2 != 0)) {
+ if (args.length < 7) {
LOGGER.error("invalid arguments: " + Arrays.toString(args));
LOGGER.error(
"usage: TestConcurrentContextJVM testType jvmNo threadCount threadLoops [parameterKey parameterJson].... ");
@@ -139,6 +155,7 @@ public final class ConcurrentContextJVM {
int jvmNo = -1;
int threadCount = -1;
int threadLoops = -1;
+ String hazelCastfileLocation = null;
try {
jvmNo = Integer.parseInt(args[1]);
@@ -161,7 +178,16 @@ public final class ConcurrentContextJVM {
return;
}
- for (int p = 4; p < args.length - 1; p += 2) {
+ try {
+ hazelCastfileLocation = args[4].trim();
+ } catch (final Exception e) {
+ LOGGER.error("invalid argument hazelcast file location", e);
+ return;
+ }
+
+ System.setProperty("hazelcast.config", hazelCastfileLocation);
+
+ for (int p = 5; p < args.length - 1; p += 2) {
@SuppressWarnings("rawtypes")
final Class parametersClass = Class.forName(args[p]);
final AbstractParameters parameters =
@@ -175,12 +201,17 @@ public final class ConcurrentContextJVM {
}
try {
- new ConcurrentContextJVM(args[0], jvmNo, threadCount, threadLoops);
+ final ConcurrentContextJVM concurrentContextJVM =
+ new ConcurrentContextJVM(args[0], jvmNo, threadCount, threadLoops);
+ concurrentContextJVM.execute();
+
} catch (final Exception e) {
LOGGER.error("error running test in JVM", e);
return;
}
// CHECKSTYLE:ON: checkstyle:magicNumber
+
+
}
/**
@@ -190,11 +221,11 @@ public final class ConcurrentContextJVM {
*/
public static void configure() throws Exception {
System.setProperty("java.net.preferIPv4Stack", "true");
- System.setProperty("hazelcast.config", "src/test/resources/hazelcast/hazelcast.xml");
-
- // The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to work. IN order to
+ // The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to
+ // work. IN order to
// ensure that all
- // the JVMs in a test pick up the same IP address, this function sets te address to be the first non-loopback
+ // the JVMs in a test pick up the same IP address, this function sets te address to be the
+ // first non-loopback
// IPv4 address
// on a host
final TreeSet<String> ipAddressSet = new TreeSet<String>();
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
index da2741f7b..995772f05 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJVMThread.java
@@ -20,9 +20,8 @@
package org.onap.policy.apex.context.test.locking;
-import com.google.gson.Gson;
-
import java.io.BufferedReader;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -36,12 +35,14 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
+import com.google.gson.Gson;
+
/**
* The Class TestConcurrentContextThread tests concurrent use of context.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ConcurrentContextJVMThread implements Runnable {
+public class ConcurrentContextJVMThread implements Runnable, Closeable {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextJVMThread.class);
@@ -49,6 +50,7 @@ public class ConcurrentContextJVMThread implements Runnable {
private final int jvm;
private final int threadCount;
private final int target;
+ private Process process = null;
/**
* The Constructor.
@@ -77,6 +79,8 @@ public class ConcurrentContextJVMThread implements Runnable {
final List<String> commandList = new ArrayList<>();
commandList.add(System.getProperty("java.home") + System.getProperty("file.separator") + "bin"
+ System.getProperty("file.separator") + "java");
+ commandList.add("-Xms512m");
+ commandList.add("-Xmx512m");
commandList.add("-cp");
commandList.add(System.getProperty("java.class.path"));
commandList.add(ConcurrentContextJVM.class.getCanonicalName());
@@ -84,6 +88,7 @@ public class ConcurrentContextJVMThread implements Runnable {
commandList.add(new Integer(jvm).toString());
commandList.add(new Integer(threadCount).toString());
commandList.add(new Integer(target).toString());
+ commandList.add(System.getProperty("hazelcast.config"));
for (final Entry<Class<?>, AbstractParameters> parameterServiceEntry : ParameterService.getAll()) {
commandList.add(parameterServiceEntry.getKey().getCanonicalName());
@@ -95,7 +100,7 @@ public class ConcurrentContextJVMThread implements Runnable {
// Run the JVM
final ProcessBuilder processBuilder = new ProcessBuilder(commandList);
processBuilder.redirectErrorStream(true);
- Process process;
+
try {
process = processBuilder.start();
@@ -121,4 +126,14 @@ public class ConcurrentContextJVMThread implements Runnable {
LOGGER.error("Error occured while writing JVM Output for command ", ioException);
}
}
+
+
+ @Override
+ public void close() {
+ LOGGER.info("Shutting down {} thread ...", Thread.currentThread().getName());
+ if (process != null) {
+ LOGGER.info("Destroying process ...");
+ process.destroy();
+ }
+ }
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
index 554c3d005..75a704557 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextThread.java
@@ -20,6 +20,8 @@
package org.onap.policy.apex.context.test.locking;
+import java.io.Closeable;
+
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
@@ -38,7 +40,8 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ConcurrentContextThread implements Runnable {
+public class ConcurrentContextThread implements Runnable, Closeable {
+ private static final String VALUE = "testValue";
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ConcurrentContextThread.class);
private final Distributor distributor;
@@ -108,8 +111,8 @@ public class ConcurrentContextThread implements Runnable {
}
try {
- lTypeAlbum.lockForWriting("testValue");
- final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
+ lTypeAlbum.lockForWriting(VALUE);
+ final TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(VALUE);
final long value = item.getLongValue();
LOGGER.info("completed TestConcurrentContextThread_" + jvm + "_" + instance + ", value=" + value);
} catch (final Exception e) {
@@ -117,7 +120,7 @@ public class ConcurrentContextThread implements Runnable {
LOGGER.error("failed TestConcurrentContextThread_" + jvm + "_" + instance);
} finally {
try {
- lTypeAlbum.unlockForWriting("testValue");
+ lTypeAlbum.unlockForWriting(VALUE);
distributor.shutdown();
} catch (final ContextException e) {
LOGGER.error("could not unlock test context album item", e);
@@ -129,18 +132,23 @@ public class ConcurrentContextThread implements Runnable {
private void updateAlbum(final ContextAlbum lTypeAlbum) throws Exception {
for (int i = 0; i < threadLoops; i++) {
try {
- lTypeAlbum.lockForWriting("testValue");
- TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get("testValue");
+ lTypeAlbum.lockForWriting(VALUE);
+ TestContextLongItem item = (TestContextLongItem) lTypeAlbum.get(VALUE);
if (item != null) {
long value = item.getLongValue();
item.setLongValue(++value);
} else {
item = new TestContextLongItem(0L);
}
- lTypeAlbum.put("testValue", item);
+ lTypeAlbum.put(VALUE, item);
} finally {
- lTypeAlbum.unlockForWriting("testValue");
+ lTypeAlbum.unlockForWriting(VALUE);
}
}
}
+
+ @Override
+ public void close() {
+ LOGGER.info("Shutting down {} thread ...", Thread.currentThread().getName());
+ }
}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
index 90e586e72..2bf304ec8 100644
--- a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
@@ -17,6 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.apex.context.test.utils;
import java.util.TimeZone;
@@ -51,8 +52,12 @@ public class Constants {
public static final String TEST_POLICY_CONTEXT_ITEM = TestPolicyContextItem.class.getName();
public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("Europe/Dublin");
- public static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = {new AxArtifactKey("testC-top", VERSION),
- new AxArtifactKey("testC-next", VERSION), new AxArtifactKey("testC-bot", VERSION)};
+ private static final AxArtifactKey KEY = new AxArtifactKey("testC-top", VERSION);
+ private static final AxArtifactKey KEY3 = new AxArtifactKey("testC-bot", VERSION);
+ private static final AxArtifactKey KEY2 = new AxArtifactKey("testC-next", VERSION);
+
+ private static final AxArtifactKey[] AX_ARTIFACT_KEYS = {KEY, KEY2, KEY3};
+ public static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = AX_ARTIFACT_KEYS;
private Constants() {}
diff --git a/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java
new file mode 100644
index 000000000..b5ea84d2f
--- /dev/null
+++ b/context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/IntegrationThreadFactory.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.apex.context.test.utils;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class IntegrationThreadFactory implements ThreadFactory {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(IntegrationThreadFactory.class);
+
+
+ private final String threadFactoryName;
+
+ private final AtomicInteger counter = new AtomicInteger();
+
+ public IntegrationThreadFactory(final String threadFactoryName) {
+ this.threadFactoryName = threadFactoryName;
+ }
+
+ @Override
+ public Thread newThread(final Runnable runnable) {
+ final Thread thread = new Thread(runnable);
+ thread.setName(threadFactoryName + "_" + counter.getAndIncrement());
+ LOGGER.debug("started thread " + thread.getName());
+ return thread;
+ }
+
+}
diff --git a/core/core-infrastructure/pom.xml b/core/core-infrastructure/pom.xml
index 84548c7e2..e314052b3 100644
--- a/core/core-infrastructure/pom.xml
+++ b/core/core-infrastructure/pom.xml
@@ -34,7 +34,7 @@
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
- <version>1.3.4</version>
+ <version>1.3.8</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -45,4 +45,4 @@
<artifactId>gson</artifactId>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/packages/apex-pdp-package-full/pom.xml b/packages/apex-pdp-package-full/pom.xml
index ef8766117..890f9f55e 100644
--- a/packages/apex-pdp-package-full/pom.xml
+++ b/packages/apex-pdp-package-full/pom.xml
@@ -500,4 +500,4 @@
</build>
</profile>
</profiles>
-</project> \ No newline at end of file
+</project>
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexApps.bat b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat
index 5aba49702..5aba49702 100644
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexApps.bat
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.bat
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexApps.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh
index adcbfcbb1..adcbfcbb1 100755
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexApps.sh
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexApps.sh
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexBash.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexBash.sh
index 2a201cc72..2a201cc72 100755
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexBash.sh
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexBash.sh
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexCLIEditor.bat b/packages/apex-pdp-package-full/src/main/package/scripts/apexCLIEditor.bat
index c4cb649bc..c4cb649bc 100644
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexCLIEditor.bat
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexCLIEditor.bat
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexCLIEditor.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexCLIEditor.sh
index 28a26171b..28a26171b 100755
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexCLIEditor.sh
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexCLIEditor.sh
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexEngine.bat b/packages/apex-pdp-package-full/src/main/package/scripts/apexEngine.bat
index d44adbbe6..d44adbbe6 100644
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexEngine.bat
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexEngine.bat
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexEngine.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexEngine.sh
index c07e38b51..c07e38b51 100755
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexEngine.sh
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexEngine.sh
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexRESTEditor.bat b/packages/apex-pdp-package-full/src/main/package/scripts/apexRESTEditor.bat
index 69ada95bf..69ada95bf 100644
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexRESTEditor.bat
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexRESTEditor.bat
diff --git a/packages/apex-pdp-package-full/src/main/package/bin/apexRESTEditor.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexRESTEditor.sh
index 3f2ae867b..3f2ae867b 100755
--- a/packages/apex-pdp-package-full/src/main/package/bin/apexRESTEditor.sh
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexRESTEditor.sh
diff --git a/packages/apex-pdp-package-full/src/main/package/tarball/assembly.xml b/packages/apex-pdp-package-full/src/main/package/tarball/assembly.xml
index 79ad9e11c..cd242f33c 100644
--- a/packages/apex-pdp-package-full/src/main/package/tarball/assembly.xml
+++ b/packages/apex-pdp-package-full/src/main/package/tarball/assembly.xml
@@ -45,7 +45,7 @@
</dependencySets>
<fileSets>
<fileSet>
- <directory>${project.basedir}/src/main/package/bin</directory>
+ <directory>${project.basedir}/src/main/package/scripts</directory>
<includes>
<include>*</include>
</includes>
diff --git a/plugins/plugins-context/context-locking/context-locking-curator/pom.xml b/plugins/plugins-context/context-locking/context-locking-curator/pom.xml
index 1094ced4e..220bfbae6 100644
--- a/plugins/plugins-context/context-locking/context-locking-curator/pom.xml
+++ b/plugins/plugins-context/context-locking/context-locking-curator/pom.xml
@@ -53,12 +53,16 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.5.4-beta</version>
- <exclusions>
+ <exclusions>
<!-- Zookeeper uses an ancient version of log4j -->
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/plugins/plugins-executor/plugins-executor-jruby/pom.xml b/plugins/plugins-executor/plugins-executor-jruby/pom.xml
index c9f72fc07..901d30e9f 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/pom.xml
+++ b/plugins/plugins-executor/plugins-executor-jruby/pom.xml
@@ -38,13 +38,9 @@
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
- <version>9.2.0.0</version>
+ <version>9.1.2.0</version>
<exclusions>
<exclusion>
- <groupId>org.jruby.extras</groupId>
- <artifactId>bytelist</artifactId>
- </exclusion>
- <exclusion>
<groupId>org.jruby</groupId>
<artifactId>dirgra</artifactId>
</exclusion>
diff --git a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java
index b0dd9c5c9..71dce5801 100644
--- a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskExecutor.java
@@ -26,6 +26,7 @@ import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.TaskExecutor;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
import org.python.core.CompileMode;
+import org.python.core.CompilerFlags;
import org.python.core.Py;
import org.python.core.PyCode;
import org.python.core.PyException;
@@ -34,8 +35,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JythonTaskExecutor is the task executor for task logic written in Jython It is unlikely that this is thread
- * safe.
+ * The Class JythonTaskExecutor is the task executor for task logic written in Jython It is unlikely
+ * that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -61,8 +62,9 @@ public class JythonTaskExecutor extends TaskExecutor {
super.prepare();
try {
synchronized (Py.class) {
- compiled = Py.compile_flags(getSubject().getTaskLogic().getLogic(),
- "<" + getSubject().getKey().toString() + ">", CompileMode.exec, null);
+ final String logic = getSubject().getTaskLogic().getLogic();
+ final String filename = "<" + getSubject().getKey().toString() + ">";
+ compiled = Py.compile_flags(logic, filename, CompileMode.exec, new CompilerFlags());
}
} catch (final PyException e) {
LOGGER.warn("failed to compile Jython code for task " + getSubject().getKey().getID(), e);
diff --git a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java
index 4fd48f2e7..d28001d87 100644
--- a/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-jython/src/main/java/org/onap/policy/apex/plugins/executor/jython/JythonTaskSelectExecutor.java
@@ -26,6 +26,7 @@ import org.onap.policy.apex.core.engine.executor.TaskSelectExecutor;
import org.onap.policy.apex.core.engine.executor.exception.StateMachineException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.python.core.CompileMode;
+import org.python.core.CompilerFlags;
import org.python.core.Py;
import org.python.core.PyCode;
import org.python.core.PyException;
@@ -34,8 +35,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class JythonTaskSelectExecutor is the task selection executor for task selection logic written in Jython It is
- * unlikely that this is thread safe.
+ * The Class JythonTaskSelectExecutor is the task selection executor for task selection logic
+ * written in Jython It is unlikely that this is thread safe.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -60,8 +61,9 @@ public class JythonTaskSelectExecutor extends TaskSelectExecutor {
super.prepare();
try {
synchronized (Py.class) {
- compiled = Py.compile_flags(getSubject().getTaskSelectionLogic().getLogic(),
- "<" + getSubject().getKey().toString() + ">", CompileMode.exec, null);
+ final String logic = getSubject().getTaskSelectionLogic().getLogic();
+ final String filename = "<" + getSubject().getKey().toString() + ">";
+ compiled = Py.compile_flags(logic, filename, CompileMode.exec, new CompilerFlags());
}
} catch (final PyException e) {
LOGGER.warn("failed to compile Jython code for task selection logic in " + getSubject().getKey().getID(),
diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
index 7a3a29cc1..e2c2de97a 100644
--- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
+++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java
@@ -48,6 +48,7 @@ import org.onap.policy.apex.context.test.locking.ConcurrentContext;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.apex.model.utilities.ResourceUtils;
import org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor;
import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor;
import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters;
@@ -65,6 +66,11 @@ import com.hazelcast.config.Config;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestConcurrentContext {
+ private static final String HAZELCAST_CONFIG = "hazelcast.config";
+
+ private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack";
+ private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml";
+
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(TestConcurrentContext.class);
@@ -89,8 +95,9 @@ public class TestConcurrentContext {
@BeforeClass
public static void configure() throws Exception {
- System.setProperty("java.net.preferIPv4Stack", "true");
- System.setProperty("hazelcast.config", "src/test/resources/hazelcast/hazelcast.xml");
+ System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true");
+ final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE);
+ System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation);
// The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to
// work. IN order to ensure that all
diff --git a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
index d69f24b90..2918909c3 100644
--- a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
+++ b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml
@@ -41,14 +41,23 @@
</interfaces>
</network>
<properties>
- <property name="hazelcast.icmp.enabled">true</property>
+ <property name="hazelcast.icmp.enabled">false</property>
<property name="hazelcast.logging.type">slf4j</property>
<!-- disable the hazelcast shutdown hook - prefer to control the shutdown
in code -->
<property name="hazelcast.shutdownhook.enabled">false</property>
<property name="hazelcast.graceful.shutdown.max.wait">60</property>
+ <property name="hazelcast.operation.generic.thread.count">1</property>
+ <property name="hazelcast.operation.thread.count">1</property>
+ <property name="hazelcast.clientengine.thread.count">1</property>
+ <property name="hazelcast.client.event.thread.count">1</property>
+ <property name="hazelcast.event.thread.count">1</property>
+ <property name="hazelcast.io.output.thread.count">1</property>
+ <property name="hazelcast.io.thread.count">1</property>
+ <property name="hazelcast.executor.client.thread.count">1</property>
+ <property name="hazelcast.clientengine.thread.count">1</property>
</properties>
<executor-service>
- <pool-size>16</pool-size>
+ <pool-size>2</pool-size>
</executor-service>
</hazelcast>
diff --git a/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml b/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml
deleted file mode 100644
index 7fd818d4b..000000000
--- a/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2016-2018 Ericsson. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- SPDX-License-Identifier: Apache-2.0
- ============LICENSE_END=========================================================
--->
-
-<configuration>
- <contextName>Apex</contextName>
- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
- <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" />
-
- <!-- USE FOR STD OUT ONLY -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <appender name="FILE"
- class="ch.qos.logback.core.FileAppender">
- <file>${LOG_DIR}/apex.log</file>
- <encoder>
- <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
- %logger{26} - %msg %n %ex{full}</pattern>
- </encoder>
- </appender>
-
- <appender name="CTXT_FILE"
- class="ch.qos.logback.core.FileAppender">
- <file>${LOG_DIR}/apex_ctxt.log</file>
- <encoder>
- <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
- %logger{26} - %msg %n %ex{full}</pattern>
- </encoder>
- </appender>
-
- <logger name="org.infinispan" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.ericsson.apex.context.monitoring" level="TRACE" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.ericsson.apex.context.monitoring" level="TRACE" additivity="false">
- <appender-ref ref="CTXT_FILE" />
- </logger>
-
- <logger name="org.jgroups" level="off" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
-</configuration>
diff --git a/testsuites/integration/integration-executor-test/pom.xml b/testsuites/integration/integration-executor-test/pom.xml
new file mode 100644
index 000000000..d064f6373
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/pom.xml
@@ -0,0 +1,89 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
+ <artifactId>integration</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>integration-executor-test</artifactId>
+ <name>${project.artifactId}</name>
+ <description>[${project.parent.artifactId}] module to run executor tests using various executor script plugins</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.core</groupId>
+ <artifactId>core-infrastructure</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.context</groupId>
+ <artifactId>context-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
+ <artifactId>integration-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+ <artifactId>plugins-executor-mvel</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+ <artifactId>plugins-executor-jruby</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+ <artifactId>plugins-executor-jython</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+ <artifactId>plugins-executor-javascript</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+ <artifactId>plugins-executor-java</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>${version.derby}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexActionListener.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexActionListener.java
new file mode 100644
index 000000000..fa79843e9
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexActionListener.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.policy.apex.core.engine.engine.EnEventListener;
+import org.onap.policy.apex.core.engine.event.EnEvent;
+import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The listener interface for receiving testApexAction events. The class that is interested in
+ * processing a testApexAction event implements this interface, and the object created with that
+ * class is registered with a component using the component's <code>addTestApexActionListener</code>
+ * method. When the testApexAction event occurs, that object's appropriate method is invoked.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestApexActionListener implements EnEventListener {
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestApexActionListener.class);
+
+ private List<EnEvent> resultEvents = new ArrayList<>();
+
+ private final String id;
+
+ /**
+ * Instantiates a new test apex action listener.
+ *
+ * @param id the id
+ */
+ public TestApexActionListener(final String id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets the result.
+ *
+ * @param allowNulls if true and the returned event is null, then return, otherwise wait until
+ * an event is returned.
+ * @return the result
+ */
+ public EnEvent getResult(final boolean allowNulls) {
+ EnEvent result = null;
+ while (true) {
+ while (resultEvents.isEmpty()) {
+ ThreadUtilities.sleep(100);
+ }
+ result = resultEvents.remove(0);
+ if (result != null || allowNulls) {
+ break;
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.core.engine.engine.EnEventListener#onEnEvent(org.onap.policy.apex.core.
+ * engine.event.EnEvent)
+ */
+ @Override
+ public void onEnEvent(final EnEvent actionEvent) {
+ ThreadUtilities.sleep(100);
+ if (actionEvent != null) {
+ logger.info("Action event from engine: {}", actionEvent.getName());
+ }
+ resultEvents.add(actionEvent);
+ }
+
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngine.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngine.java
new file mode 100644
index 000000000..b087552eb
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngine.java
@@ -0,0 +1,129 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.core.engine.engine.ApexEngine;
+import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
+import org.onap.policy.apex.core.engine.event.EnEvent;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+public class TestApexEngine {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestApexEngine.class);
+
+ /**
+ * Instantiates a new test apex engine.
+ *
+ * @param axLogicExecutorType the type of logic executor to use to construct the sample policy
+ * model for this test
+ * @throws ApexException the apex exception
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ public TestApexEngine(final String axLogicExecutorType, final EngineParameters parameters)
+ throws ApexException, InterruptedException, IOException {
+ logger.debug("Running TestApexEngine test for + " + axLogicExecutorType + "logic . . .");
+
+ final AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel(axLogicExecutorType);
+ assertNotNull(apexPolicyModel);
+ final AxArtifactKey key = new AxArtifactKey("TestApexEngine", "0.0.1");
+
+ final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(key);
+ final TestApexActionListener listener = new TestApexActionListener("Test");
+ apexEngine.addEventListener("listener", listener);
+ apexEngine.updateModel(apexPolicyModel);
+ apexEngine.start();
+
+ for (final AxEvent axEvent : apexPolicyModel.getEvents().getEventMap().values()) {
+ final EnEvent event = apexEngine.createEvent(axEvent.getKey());
+
+ final Date aDate = new Date(1433453067123L);
+ final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ eventDataMap.put("TestSlogan", "This is a test slogan for event " + event.getName());
+ eventDataMap.put("TestMatchCase", new Byte((byte) 123));
+ eventDataMap.put("TestTimestamp", aDate.getTime());
+ eventDataMap.put("TestTemperature", 34.5445667);
+
+ event.putAll(eventDataMap);
+
+ apexEngine.handleEvent(event);
+ }
+
+ EnEvent result = listener.getResult(false);
+ logger.debug("result 1 is:" + result);
+ checkResult(result);
+ result = listener.getResult(false);
+ logger.debug("result 2 is:" + result);
+ checkResult(result);
+
+ final Map<AxArtifactKey, Map<String, Object>> apexContext = apexEngine.getEngineContext();
+ assertNotNull(apexContext);
+ apexEngine.stop();
+ }
+
+ /**
+ * Check result.
+ *
+ * @param result the result
+ */
+ private void checkResult(final EnEvent result) {
+ if (result.getExceptionMessage() == null) {
+ assertTrue(result.getName().equals("Event0004") || result.getName().equals("Event0104"));
+
+ assertTrue(((String) result.get("TestSlogan")).startsWith("This is a test slogan for event "));
+ assertTrue(((String) result.get("TestSlogan")).contains(result.getName().substring(0, 8)));
+
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
+ assertTrue(
+ (Byte) result.get("TestMatchCaseSelected") >= 0 && (Byte) result.get("TestMatchCaseSelected") <= 4);
+ assertTrue((Byte) result.get("TestEstablishCaseSelected") >= 0
+ && (Byte) result.get("TestEstablishCaseSelected") <= 4);
+ assertTrue((Byte) result.get("TestDecideCaseSelected") >= 0
+ && (Byte) result.get("TestDecideCaseSelected") <= 4);
+ assertTrue((Byte) result.get("TestActCaseSelected") >= 0 && (Byte) result.get("TestActCaseSelected") <= 4);
+ } else {
+ assertTrue(result.getName().equals("Event0001") || result.getName().equals("Event0104"));
+
+ assertTrue(((String) result.get("TestSlogan")).startsWith("This is a test slogan for event "));
+ assertTrue(((String) result.get("TestSlogan")).contains(result.getName().substring(0, 8)));
+
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
+ }
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java
new file mode 100644
index 000000000..8b1cc0b04
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJRuby.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters;
+
+public class TestApexEngineJRuby {
+
+ /**
+ * Test apex engine.
+ *
+ * @throws ApexException the apex exception
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @Test
+ public void testApexEngineJRuby() throws ApexException, InterruptedException, IOException {
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("JRUBY", new JrubyExecutorParameters());
+
+ new TestApexEngine("JRUBY", parameters);
+ new TestApexEngine("JRUBY", parameters);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java
new file mode 100644
index 000000000..44593a0a2
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJava.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
+
+/**
+ * The Class TestApexEngine_Java.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestApexEngineJava {
+
+ /**
+ * Test apex engine.
+ *
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
+ @Test
+ public void testApexEngineJava() throws InterruptedException, IOException, ApexException {
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
+
+ new TestApexEngine("JAVA", parameters);
+ new TestApexEngine("JAVA", parameters);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java
new file mode 100644
index 000000000..1f55f8458
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJavascript.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
+
+public class TestApexEngineJavascript {
+
+ /**
+ * Test apex engine.
+ *
+ * @throws ApexException the apex exception
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @Test
+ public void testApexEngineJavascript() throws ApexException, InterruptedException, IOException {
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+
+ new TestApexEngine("JAVASCRIPT", parameters);
+ new TestApexEngine("JAVASCRIPT", parameters);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java
new file mode 100644
index 000000000..eabe63dfb
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineJython.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters;
+
+public class TestApexEngineJython {
+
+ /**
+ * Test apex engine.
+ *
+ * @throws ApexException the apex exception
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @Test
+ public void testApexEngineJython() throws ApexException, InterruptedException, IOException {
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("JYTHON", new JythonExecutorParameters());
+
+ new TestApexEngine("JYTHON", parameters);
+ new TestApexEngine("JYTHON", parameters);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java
new file mode 100644
index 000000000..aea7cecc6
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/engine/TestApexEngineMVEL.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.engine;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+
+public class TestApexEngineMVEL {
+
+ /**
+ * Test apex engine.
+ *
+ * @throws ApexException the apex exception
+ * @throws InterruptedException the interrupted exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @Test
+ public void testApexEngineMVEL() throws ApexException, InterruptedException, IOException {
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+
+ new TestApexEngine("MVEL", parameters);
+ new TestApexEngine("MVEL", parameters);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java
new file mode 100644
index 000000000..0ed78a13f
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/event/TestEventInstantiation.java
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.core.engine.engine.ApexEngine;
+import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
+import org.onap.policy.apex.core.engine.event.EnEvent;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestEventInstantiation.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestEventInstantiation {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestEventInstantiation.class);
+
+ /**
+ * Test event instantiation.
+ *
+ * @throws ApexModelException on errors in handling Apex models
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ApexException the apex exception
+ */
+ @Test
+ public void testEventInstantiation() throws ApexModelException, IOException, ApexException {
+ final String xmlFileName = "xml/ApexModel_MVEL.xml";
+
+ logger.debug("Running TestEventInstantiation test on file {} . . .", xmlFileName);
+
+ final AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ assertNotNull(apexPolicyModel);
+
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+
+ final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(apexPolicyModel.getKey());
+ apexEngine.updateModel(apexPolicyModel);
+ apexEngine.start();
+
+ final EnEvent event = apexEngine.createEvent(new AxArtifactKey("Event0000", "0.0.1"));
+
+ Object slogan1 = event.put("TestSlogan", "This is a slogan");
+ assertNull(slogan1);
+ slogan1 = event.get("TestSlogan");
+ assertNotNull(slogan1);
+ assertEquals("This is a slogan", slogan1);
+
+ Object mc1 = event.put("TestMatchCase", new Byte("4"));
+ assertNull(mc1);
+ mc1 = event.get("TestMatchCase");
+ assertNotNull(mc1);
+ assertEquals((byte) 4, mc1);
+
+ Object mc2 = event.put("TestMatchCase", new Byte("16"));
+ assertNotNull(mc2);
+ assertEquals((byte) 4, mc2);
+ mc2 = event.get("TestMatchCase");
+ assertNotNull(mc2);
+ assertEquals((byte) 16, mc2);
+
+ final Date timeNow = new Date();
+ Object timestamp1 = event.put("TestTimestamp", timeNow.getTime());
+ assertNull(timestamp1);
+ timestamp1 = event.get("TestTimestamp");
+ assertNotNull(timestamp1);
+ assertEquals(timeNow.getTime(), timestamp1);
+
+ final double temperature = 123.456789;
+ Object temp1 = event.put("TestTemperature", temperature);
+ assertNull(temp1);
+ temp1 = event.get("TestTemperature");
+ assertNotNull(temp1);
+ assertEquals(temperature, temp1);
+
+ Object value = event.put("TestMatchCase", null);
+ assertEquals(16, ((Byte) value).intValue());
+ value = event.get("TestMatchCase");
+ assertNull(value);
+
+ try {
+ event.put("TestMatchCase", "Hello");
+ } catch (final Exception e) {
+ assertEquals(
+ "Event0000:0.0.1:NULL:TestMatchCase: object \"Hello\" of class \"java.lang.String\" not compatible with class \"java.lang.Byte\"",
+ e.getMessage());
+ }
+
+ try {
+ event.put("TestMatchCase", 123.45);
+ } catch (final Exception e) {
+ assertEquals(
+ "Event0000:0.0.1:NULL:TestMatchCase: object \"123.45\" of class \"java.lang.Double\" not compatible with class \"java.lang.Byte\"",
+ e.getMessage());
+ }
+
+ event.put("TestMatchCase", new Byte("16"));
+
+ final String slogan2 = (String) event.get("TestSlogan");
+ assertNotNull(slogan2);
+ assertEquals("This is a slogan", slogan2);
+
+ final byte mc21 = (byte) event.get("TestMatchCase");
+ assertNotNull(mc21);
+ assertEquals(16, mc21);
+
+ final byte mc22 = (byte) event.get("TestMatchCase");
+ assertNotNull(mc22);
+ assertEquals((byte) 16, mc22);
+
+ final long timestamp2 = (Long) event.get("TestTimestamp");
+ assertNotNull(timestamp2);
+ assertEquals(timestamp2, timestamp1);
+
+ final double temp2 = (double) event.get("TestTemperature");
+ assertNotNull(temp2);
+ assertTrue(temp2 == 123.456789);
+
+ final Double temp3 = (Double) event.get("TestTemperature");
+ assertNotNull(temp3);
+ assertTrue(temp3 == 123.456789);
+
+ final Date aDate = new Date(1433453067123L);
+ final Map<String, Object> eventDataList = new HashMap<String, Object>();
+ eventDataList.put("TestSlogan", "This is a test slogan");
+ eventDataList.put("TestMatchCase", new Byte("123"));
+ eventDataList.put("TestTimestamp", aDate.getTime());
+ eventDataList.put("TestTemperature", 34.5445667);
+
+ event.putAll(eventDataList);
+
+ final String slogan3 = (String) event.get("TestSlogan");
+ assertNotNull(slogan3);
+ assertEquals("This is a test slogan", slogan3);
+
+ final byte mc31 = (byte) event.get("TestMatchCase");
+ assertNotNull(mc31);
+ assertEquals((byte) 123, mc31);
+
+ final long timestamp3 = (Long) event.get("TestTimestamp");
+ assertNotNull(timestamp3);
+ assertEquals(timestamp3, aDate.getTime());
+
+ final double temp4 = (double) event.get("TestTemperature");
+ assertNotNull(temp4);
+ assertTrue(temp4 == 34.5445667);
+
+ logger.debug(event.toString());
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexModelExport.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexModelExport.java
new file mode 100644
index 000000000..6b72faa8f
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexModelExport.java
@@ -0,0 +1,114 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.model.policymodel.handling.PolicyModelSplitter;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestApexModelReader tests Apex model reading.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestApexModelExport {
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestApexModelExport.class);
+
+ private AxPolicyModel model = null;
+
+ @Before
+ public void initApexModelSmall() throws ApexException {
+ model = new TestApexSamplePolicyModelCreator("MVEL").getModel();
+ }
+
+ @Test
+ public void testApexModelExport() throws Exception {
+ logger.info("Starting test: testApexModelExport");
+
+ final List<AxArtifactKey> exportPolicyList = new ArrayList<AxArtifactKey>();
+ exportPolicyList.addAll(model.getPolicies().getPolicyMap().keySet());
+
+ final AxPolicyModel exportedModel0 = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList);
+
+ // Remove unused schemas and their keys
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem000", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem001", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem002", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem003", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem004", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem005", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem006", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem007", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem008", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem009", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem00A", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem00B", "0.0.1"));
+ model.getSchemas().getSchemasMap().remove(new AxArtifactKey("TestContextItem00C", "0.0.1"));
+
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem000", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem001", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem002", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem003", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem004", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem005", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem006", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem007", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem008", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem009", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00A", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00B", "0.0.1"));
+ model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00C", "0.0.1"));
+
+ assertTrue(model.equals(exportedModel0));
+
+ exportPolicyList.remove(0);
+
+ final AxPolicyModel exportedModel1 = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList);
+ assertFalse(model.equals(exportedModel1));
+ assertTrue(model.getPolicies().get("Policy1").equals(exportedModel1.getPolicies().get("Policy1")));
+
+ exportPolicyList.clear();
+ exportPolicyList.add(new AxArtifactKey("NonExistentPolicy", "0.0.1"));
+
+ try {
+ final AxPolicyModel emptyExportedModel = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList);
+ assertNotNull(emptyExportedModel);
+ } catch (final Exception e) {
+ assertTrue(e.getMessage()
+ .equals("new model is invalid:\n" + "***validation of model failed***\n"
+ + "AxPolicies:Policies:0.0.1 - policyMap may not be null or empty\n"
+ + "AxEvents:Events:0.0.1 - eventMap may not be null or empty\n"
+ + "********************************"));
+ }
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexPolicyModelAnalysis.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexPolicyModelAnalysis.java
new file mode 100644
index 000000000..91153d698
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexPolicyModelAnalysis.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.model.policymodel.handling.PolicyAnalyser;
+import org.onap.policy.apex.model.policymodel.handling.PolicyAnalysisResult;
+
+public class TestApexPolicyModelAnalysis {
+ @Test
+ public void testApexPolicyModelAnalysis() throws Exception {
+ final AxPolicyModel model = new TestApexSamplePolicyModelCreator("MVEL").getModel();
+ final PolicyAnalysisResult result = new PolicyAnalyser().analyse(model);
+
+ assertNotNull(result);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyCreateModelFiles.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyCreateModelFiles.java
new file mode 100644
index 000000000..8113436ca
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyCreateModelFiles.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import org.junit.Test;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+
+public class TestApexSamplePolicyCreateModelFiles {
+ @Test
+ public void testModelWriteReadJava() throws Exception {
+ final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("JAVA");
+ final TestApexModel<AxPolicyModel> testApexPolicyModel =
+ new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
+ testApexPolicyModel.testApexModelWriteReadXML();
+ testApexPolicyModel.testApexModelWriteReadJSON();
+ }
+
+ @Test
+ public void testModelWriteReadJavascript() throws Exception {
+ final TestApexSamplePolicyModelCreator apexPolicyModelCreator =
+ new TestApexSamplePolicyModelCreator("JAVASCRIPT");
+ final TestApexModel<AxPolicyModel> testApexPolicyModel =
+ new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
+ testApexPolicyModel.testApexModelWriteReadXML();
+ testApexPolicyModel.testApexModelWriteReadJSON();
+ }
+
+ @Test
+ public void testModelWriteReadJRuby() throws Exception {
+ final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("JRUBY");
+ final TestApexModel<AxPolicyModel> testApexPolicyModel =
+ new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
+ testApexPolicyModel.testApexModelWriteReadXML();
+ testApexPolicyModel.testApexModelWriteReadJSON();
+ }
+
+ @Test
+ public void testModelWriteReadJython() throws Exception {
+ final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("JYTHON");
+ final TestApexModel<AxPolicyModel> testApexPolicyModel =
+ new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
+ testApexPolicyModel.testApexModelWriteReadXML();
+ testApexPolicyModel.testApexModelWriteReadJSON();
+ }
+
+ @Test
+ public void testModelWriteReadMvel() throws Exception {
+ final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("MVEL");
+ final TestApexModel<AxPolicyModel> testApexPolicyModel =
+ new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
+ testApexPolicyModel.testApexModelWriteReadXML();
+ testApexPolicyModel.testApexModelWriteReadJSON();
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyDBWrite.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyDBWrite.java
new file mode 100644
index 000000000..48e2f8058
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyDBWrite.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
+import org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+
+public class TestApexSamplePolicyDBWrite {
+ private Connection connection;
+ TestApexModel<AxPolicyModel> testApexModel;
+
+ @Before
+ public void setup() throws Exception {
+ connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
+
+ final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("MVEL");
+ testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator);
+ }
+
+ @After
+ public void teardown() throws Exception {
+ connection.close();
+ }
+
+ @Test
+ public void testModelWriteReadJPA() throws Exception {
+ final DAOParameters daoParameters = new DAOParameters();
+ daoParameters.setPluginClass(DefaultApexDao.class.getCanonicalName());
+ daoParameters.setPersistenceUnit("SampleModelTest");
+
+ testApexModel.testApexModelWriteReadJPA(daoParameters);
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModel.java
new file mode 100644
index 000000000..3673dae2f
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModel.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
+import org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+
+public class TestApexSamplePolicyModel {
+ private static final String VALID_MODEL_STRING = "***validation of model successful***";
+ private Connection connection;
+ private TestApexModel<AxPolicyModel> testApexModel;
+
+ @Before
+ public void setup() throws Exception {
+ connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
+
+ testApexModel =
+ new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL"));
+ }
+
+ @After
+ public void teardown() throws Exception {
+ connection.close();
+ }
+
+ @Test
+ public void testModelValid() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValid();
+ assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ }
+
+ @Test
+ public void testModelWriteReadXML() throws Exception {
+ testApexModel.testApexModelWriteReadXML();
+ }
+
+ @Test
+ public void testModelWriteReadJSON() throws Exception {
+ testApexModel.testApexModelWriteReadJSON();
+ }
+
+ @Test
+ public void testModelWriteReadJPA() throws Exception {
+ final DAOParameters daoParameters = new DAOParameters();
+ daoParameters.setPluginClass(DefaultApexDao.class.getCanonicalName());
+ daoParameters.setPersistenceUnit("SampleModelTest");
+
+ testApexModel.testApexModelWriteReadJPA(daoParameters);
+ }
+
+
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModelCreator.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModelCreator.java
new file mode 100644
index 000000000..d5ba53699
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestApexSamplePolicyModelCreator.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+
+/**
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestApexSamplePolicyModelCreator implements TestApexModelCreator<AxPolicyModel> {
+ private String logicExecutorType;
+
+ public TestApexSamplePolicyModelCreator(final String logicExecutorType) {
+ this.logicExecutorType = logicExecutorType;
+ }
+
+ @Override
+ public AxPolicyModel getModel() {
+ return new SampleDomainModelFactory().getSamplePolicyModel(logicExecutorType);
+ }
+
+ @Override
+ public AxPolicyModel getMalstructuredModel() {
+ return null;
+ }
+
+ @Override
+ public AxPolicyModel getObservationModel() {
+ return null;
+ }
+
+ @Override
+ public AxPolicyModel getWarningModel() {
+ return getModel();
+ }
+
+ @Override
+ public AxPolicyModel getInvalidModel() {
+ return null;
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java
new file mode 100644
index 000000000..5ca71cf33
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateDifferentModels.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+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 java.io.IOException;
+
+import org.junit.Test;
+import org.onap.policy.apex.context.ContextAlbum;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
+import org.onap.policy.apex.core.engine.engine.impl.ApexEngineImpl;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener;
+import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestApexEngine.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestContextUpdateDifferentModels {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateDifferentModels.class);
+
+ @Test
+ public void testContextUpdateDifferentModels() throws ApexException, InterruptedException, IOException {
+ logger.debug("Running test testContextUpdateDifferentModels . . .");
+
+ final AxPolicyModel apexModelSample = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ assertNotNull(apexModelSample);
+
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+
+ final ApexEngineImpl apexEngine =
+ (ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1"));
+ final TestApexActionListener listener = new TestApexActionListener("Test");
+ apexEngine.addEventListener("listener", listener);
+ apexEngine.updateModel(apexModelSample);
+ apexEngine.start();
+
+ apexEngine.stop();
+
+ final AxPolicyModel someSpuriousModel = new AxPolicyModel(new AxArtifactKey("SomeSpuriousModel", "0.0.1"));
+ assertNotNull(someSpuriousModel);
+
+ try {
+ apexEngine.updateModel(null);
+ fail("null model should throw an exception");
+ } catch (final ApexException e) {
+ assertEquals("updateModel()<-TestApexEngine:0.0.1, Apex model is not defined, it has a null value",
+ e.getMessage());
+ }
+ assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
+ apexModelSample.getAlbums().getAlbumsMap().size());
+ for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
+ assertTrue(
+ contextAlbum.getAlbumDefinition().equals(apexModelSample.getAlbums().get(contextAlbum.getKey())));
+ }
+
+ apexEngine.updateModel(someSpuriousModel);
+ assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
+ someSpuriousModel.getAlbums().getAlbumsMap().size());
+ for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
+ assertTrue(
+ contextAlbum.getAlbumDefinition().equals(someSpuriousModel.getAlbums().get(contextAlbum.getKey())));
+ }
+
+ apexEngine.clear();
+
+ logger.debug("Ran test testContextUpdateDifferentModels");
+ }
+
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java
new file mode 100644
index 000000000..e78d4c5bb
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/plugins/executor/test/script/handling/TestContextUpdateModel.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.executor.test.script.handling;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Test;
+import org.onap.policy.apex.context.ContextException;
+import org.onap.policy.apex.core.engine.EngineParameters;
+import org.onap.policy.apex.core.engine.engine.ApexEngine;
+import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
+import org.onap.policy.apex.core.engine.event.EnEvent;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.mvel.MVELExecutorParameters;
+import org.onap.policy.apex.plugins.executor.test.script.engine.TestApexActionListener;
+import org.onap.policy.apex.test.common.model.SampleDomainModelFactory;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class TestApexEngine.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+public class TestContextUpdateModel {
+ // Logger for this class
+ private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateModel.class);
+
+
+ @Test
+ public void testContextUpdateModel() throws ApexException, InterruptedException, IOException {
+ final AxArtifactKey key = new AxArtifactKey("TestApexEngine", "0.0.1");
+
+ final EngineParameters parameters = new EngineParameters();
+ parameters.getExecutorParameterMap().put("MVEL", new MVELExecutorParameters());
+
+ final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(key);
+ final TestApexActionListener listener = new TestApexActionListener("Test");
+ apexEngine.addEventListener("listener", listener);
+
+ final AxPolicyModel model1 = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ assertNotNull(model1);
+ assertEquals(2, model1.getPolicies().getPolicyMap().size());
+
+ apexEngine.updateModel(model1);
+ apexEngine.start();
+ sendEvent(apexEngine, listener, "Event0000", true);
+ sendEvent(apexEngine, listener, "Event0100", true);
+ apexEngine.stop();
+
+ final AxPolicyModel model2 = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ assertNotNull(model2);
+ model2.getPolicies().getPolicyMap().remove(new AxArtifactKey("Policy0", "0.0.1"));
+ assertEquals(1, model2.getPolicies().getPolicyMap().size());
+ apexEngine.updateModel(model2);
+ apexEngine.start();
+ sendEvent(apexEngine, listener, "Event0000", false);
+ sendEvent(apexEngine, listener, "Event0100", true);
+ apexEngine.stop();
+
+ final AxPolicyModel model3 = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ assertNotNull(model3);
+ model3.getPolicies().getPolicyMap().remove(new AxArtifactKey("Policy1", "0.0.1"));
+ assertEquals(1, model3.getPolicies().getPolicyMap().size());
+ apexEngine.updateModel(model3);
+ apexEngine.start();
+ sendEvent(apexEngine, listener, "Event0000", true);
+ sendEvent(apexEngine, listener, "Event0100", false);
+ apexEngine.stop();
+
+ final AxPolicyModel model4 = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ assertNotNull(model4);
+ assertEquals(2, model4.getPolicies().getPolicyMap().size());
+ apexEngine.updateModel(model4);
+ apexEngine.start();
+ sendEvent(apexEngine, listener, "Event0100", true);
+ sendEvent(apexEngine, listener, "Event0000", true);
+ apexEngine.stop();
+
+ apexEngine.clear();
+ }
+
+ @After
+ public void testContextUpdateModelAfter() {}
+
+ private void sendEvent(final ApexEngine apexEngine, final TestApexActionListener listener, final String eventName,
+ final boolean shouldWork) throws ContextException {
+ final Date aDate = new Date(1433453067123L);
+ final Map<String, Object> eventDataMap = new HashMap<String, Object>();
+ eventDataMap.put("TestSlogan", "This is a test slogan");
+ eventDataMap.put("TestMatchCase", new Byte((byte) 123));
+ eventDataMap.put("TestTimestamp", aDate.getTime());
+ eventDataMap.put("TestTemperature", 34.5445667);
+
+ final EnEvent event0 = apexEngine.createEvent(new AxArtifactKey(eventName, "0.0.1"));
+ event0.putAll(eventDataMap);
+ apexEngine.handleEvent(event0);
+
+ final EnEvent result = listener.getResult(true);
+ logger.debug("result 1 is:" + result);
+ checkResult(result, shouldWork);
+ }
+
+ private void checkResult(final EnEvent result, final boolean shouldWork) {
+ if (!shouldWork) {
+ assertNotNull(result.getExceptionMessage());
+ return;
+ }
+
+ assertTrue(result.getName().equals("Event0004") || result.getName().equals("Event0104"));
+
+ if (result.getName().equals("Event0004")) {
+ assertEquals("This is a test slogan", result.get("TestSlogan"));
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
+ assertEquals((byte) 2, result.get("TestMatchCaseSelected"));
+ assertEquals((byte) 0, result.get("TestEstablishCaseSelected"));
+ assertEquals((byte) 1, result.get("TestDecideCaseSelected"));
+ assertEquals((byte) 3, result.get("TestActCaseSelected"));
+ } else {
+ assertEquals("This is a test slogan", result.get("TestSlogan"));
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
+ assertEquals((byte) 1, result.get("TestMatchCaseSelected"));
+ assertEquals((byte) 3, result.get("TestEstablishCaseSelected"));
+ assertEquals((byte) 1, result.get("TestDecideCaseSelected"));
+ assertEquals((byte) 2, result.get("TestActCaseSelected"));
+ }
+ }
+}
diff --git a/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..5ba5bfa4c
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="SampleModelTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner</class>
+ <class>org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxConcept</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxModel</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.TestEntity</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
+ <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
+ <class>org.onap.policy.apex.model.eventmodel.concepts.AxField</class>
+ <class>org.onap.policy.apex.model.eventmodel.concepts.AxInputField</class>
+ <class>org.onap.policy.apex.model.eventmodel.concepts.AxOutputField</class>
+ <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvent</class>
+ <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvents</class>
+ <class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxLogic</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxTask</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxTasks</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxStateOutput</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxState</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicy</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicies</class>
+ <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
+
+ <properties>
+ <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
+ <property name="javax.persistence.target-database" value="Derby" />
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
+
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/testsuites/integration/integration-executor-test/src/test/resources/logback-test.xml b/testsuites/integration/integration-executor-test/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..b0fa687ce
--- /dev/null
+++ b/testsuites/integration/integration-executor-test/src/test/resources/logback-test.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<configuration>
+
+ <contextName>Apex</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.infinispan" level="INFO" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${LOG_DIR}/apex.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${LOG_DIR}/apex_ctxt.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
+ <appender-ref ref="CTXT_FILE" />
+ </logger>
+
+ <logger name="org.onap.policy.apex.core.engine.monitoring" level="TRACE" additivity="false">
+ <appender-ref ref="CTXT_FILE" />
+ </logger>
+
+ <logger name="org.onap.policy.apex.executionlogging" level="TRACE" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.ericsson.apex" level="INFO" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java
index 0874d9827..8468b6d7f 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java
@@ -91,9 +91,15 @@ public class TestKafka2Kafka {
@AfterClass
public static void shutdownDummyKafkaServer() throws IOException {
- kafkaServer.shutdown();
- zkClient.close();
- zkServer.shutdown();
+ if (kafkaServer != null) {
+ kafkaServer.shutdown();
+ }
+ if (zkClient != null) {
+ zkClient.close();
+ }
+ if (zkServer != null) {
+ zkServer.shutdown();
+ }
}
@Test
diff --git a/testsuites/integration/pom.xml b/testsuites/integration/pom.xml
index 366556cf1..9fcfd324e 100644
--- a/testsuites/integration/pom.xml
+++ b/testsuites/integration/pom.xml
@@ -39,6 +39,7 @@
</activation>
<modules>
<module>integration-common</module>
+ <module>integration-executor-test</module>
<module>integration-uservice-test</module>
</modules>
</profile>
@@ -51,6 +52,7 @@
</activation>
<modules>
<module>integration-common</module>
+ <module>integration-executor-test</module>
<module>integration-uservice-test</module>
<module>integration-context-metrics</module>
</modules>
@@ -64,6 +66,7 @@
</activation>
<modules>
<module>integration-common</module>
+ <module>integration-executor-test</module>
<module>integration-uservice-test</module>
<module>integration-context-test</module>
<module>integration-context-metrics</module>