summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-jruby/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-11-15 13:40:08 +0000
committerliamfallon <liam.fallon@est.tech>2019-11-15 13:42:11 +0000
commitc54feabfafaab64d56cf275fb1a474f0e830eba9 (patch)
treee4c47037eac78e0d52436732fc3f6e6158608e38 /plugins/plugins-executor/plugins-executor-jruby/src/test
parent40a1f22ff8d28e78b6512c0a10d454b37f015fdb (diff)
Fix JRuby interpreter shutdown issue
The new version of JRuby fixes this issue. Also amended unit test to check for shutdown and immediate recreation of JRuby interpreter. Issue-ID: POLICY-1276 Change-Id: I723e0396985d3163b483e52fdaceb4b4fab7274b Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-jruby/src/test')
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
index 8b58c38d8..2309c1e29 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/test/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutorTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,8 +70,18 @@ public class JrubyTaskExecutorTest {
@Test
public void testJrubyTaskExecutor() {
+ // Run test twice to check for incorrect shutdown activity
+ jrubyExecutorTest();
+ jrubyExecutorTest();
+ }
+
+ /**
+ * Test the JRuby executor.
+ */
+ private void jrubyExecutorTest() {
JrubyTaskExecutor jte = new JrubyTaskExecutor();
assertNotNull(jte);
+
try {
Field fieldContainer = JrubyTaskExecutor.class.getDeclaredField("container");
fieldContainer.setAccessible(true);
@@ -101,11 +112,11 @@ public class JrubyTaskExecutorTest {
fail("test should throw an exception here");
} catch (Exception jteException) {
assertEquals("execute-post: task logic execution failure on task \"NULL\" in model NULL:0.0.0",
- jteException.getMessage());
+ jteException.getMessage());
}
- final String jrubyLogic =
- "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true" + "\n end";
+ final String jrubyLogic = "if executor.executionId == -1" + "\n return false" + "\n else " + "\n return true"
+ + "\n end";
task.getTaskLogic().setLogic(jrubyLogic);
try {
@@ -116,5 +127,14 @@ public class JrubyTaskExecutorTest {
} catch (Exception jteException) {
fail("test should not throw an exception here");
}
+
+ try {
+ jte.prepare();
+ Map<String, Object> returnMap = jte.execute(0, new Properties(), incomingParameters);
+ assertEquals(0, returnMap.size());
+ jte.cleanUp();
+ } catch (Exception jteException) {
+ fail("test should not throw an exception here");
+ }
}
}