From: Mateusz Warowny Date: Thu, 6 Jul 2023 13:56:38 +0000 (+0200) Subject: JAL-4199 Patch task execution in action tests X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6c6b7b78d6255d27d36d88edd0ba90d741118995;p=jalview.git JAL-4199 Patch task execution in action tests --- diff --git a/test/jalview/ws2/actions/alignment/AlignmentActionTest.java b/test/jalview/ws2/actions/alignment/AlignmentActionTest.java index 5586108..e573032 100644 --- a/test/jalview/ws2/actions/alignment/AlignmentActionTest.java +++ b/test/jalview/ws2/actions/alignment/AlignmentActionTest.java @@ -24,6 +24,7 @@ import jalview.datamodel.SequenceI; import jalview.gui.AlignViewport; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.ParamDatastoreI; +import jalview.ws2.actions.PollingTaskExecutor; import jalview.ws2.actions.api.JobI; import jalview.ws2.actions.api.TaskEventListener; import jalview.ws2.api.Credentials; @@ -210,12 +211,16 @@ public class AlignmentActionTest return null; }) .when(listener).taskCompleted(any(), any()); - action.perform(viewport, List.of(), Credentials.empty(), listener); + var executor = PollingTaskExecutor.fromPool(viewport.getServiceExecutor()); + var task = action.createTask(viewport, List.of(), Credentials.empty()); + task.addTaskEventListener(listener); + var cancellable = executor.submit(task); try { latch.await(100, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { + cancellable.cancel(true); } return listener; }