Skip to content

Commit 27abde6

Browse files
committed
Add regression test for aggressive cancelation
Ensure commands run after a command is canceled are not themselves canceled.
1 parent 5b24cd5 commit 27abde6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/test/java/org/scijava/command/CommandModuleTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ public void testCancelable() throws InterruptedException, ExecutionException {
5858
assertTrue(c.isCanceled());
5959
assertEquals("Stop! Collaborate and listen!", ice.getCancelReason());
6060
assertEquals("Stop! Collaborate and listen!", c.getCancelReason());
61+
62+
final CommandModule crow = commandService.run(CrowCommand.class, true).get();
63+
assertFalse(crow.isCanceled());
6164
}
62-
65+
66+
6367
@Test
6468
public void testNotCancelable() throws InterruptedException,
6569
ExecutionException
@@ -98,6 +102,16 @@ public void run() {
98102
}
99103
}
100104

105+
/** A {@link Cancelable} command which is not auto-canceled. */
106+
@Plugin(type = Command.class)
107+
public static class CrowCommand extends ContextCommand {
108+
109+
@Override
110+
public void run() {
111+
// everything's good
112+
}
113+
}
114+
101115
@Plugin(type = PreprocessorPlugin.class)
102116
public static class CommandCanceler extends AbstractPreprocessorPlugin {
103117

0 commit comments

Comments
 (0)