diff options
author | 2020-04-01 09:38:33 +0100 | |
---|---|---|
committer | 2020-04-02 16:33:47 +0100 | |
commit | 30f94aa98ebc8931e224cdd2e5b8c25949379065 (patch) | |
tree | fe1391f867cd11726da9dfcf6b6089dd74f4c3ef /plugins/plugins-executor/plugins-executor-javascript/src/test/java/org | |
parent | 42cd61abcc9cd27e72eaa34a746ee176dbf30750 (diff) |
Fix hanging timeout on Executor test
Issue-ID: POLICY-2106
Change-Id: I7bd44f8dfe349d73a4c8c4f978a30b455c45b2c7
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-javascript/src/test/java/org')
-rw-r--r-- | plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java index 53781e870..6ea15fc35 100644 --- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java +++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutorTest.java @@ -267,7 +267,7 @@ public class JavascriptExecutorTest { }).doesNotThrowAnyException(); assertThatCode(() -> { - executor.init("while (true) { x = 1; }; true;"); + executor.init("var x = 0; while (x < 100) { x++; }; true;"); }).doesNotThrowAnyException(); concurrentResult.set(true); @@ -276,13 +276,18 @@ public class JavascriptExecutorTest { (new Thread() { public void run() { try { - concurrentResult.set(executor.execute("hello")); + while (executor.execute("hello")) { + // Loop until interrupted + } + concurrentResult.set(false); } catch (StateMachineException e) { - e.printStackTrace(); + // Do nothing } } }).start(); + await().atMost(1000, TimeUnit.MILLISECONDS).until(() -> executor.getExecutorThread().isAlive()); + executor.getExecutorThread().interrupt(); await().atMost(1000, TimeUnit.MILLISECONDS).until(() -> !concurrentResult.get()); |