diff options
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.java | 26 |
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");
+ }
}
}
|