From 30f94aa98ebc8931e224cdd2e5b8c25949379065 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 1 Apr 2020 09:38:33 +0100 Subject: Fix hanging timeout on Executor test Issue-ID: POLICY-2106 Change-Id: I7bd44f8dfe349d73a4c8c4f978a30b455c45b2c7 Signed-off-by: liamfallon --- .../plugins/executor/javascript/JavascriptExecutorTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'plugins/plugins-executor/plugins-executor-javascript/src/test') 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()); -- cgit 1.2.3-korg