diff --git a/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java b/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java index c6ce044c..0721c91e 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStepTest.java @@ -162,26 +162,26 @@ public class CatchErrorStepTest { assertCatchError(r, b, Result.SUCCESS, Result.UNSTABLE, true); } - @Test public void catchesTimeoutsByDefault() throws Exception { + @Test public void catchesInterruptionsByDefault() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( - "timeout(time: 1, unit: 'SECONDS') {\n" + - " catchError(message: 'caught error') {\n" + - " sleep 5\n" + - " }\n" + - "}", true)); + "import jenkins.model.CauseOfInterruption\n" + + "import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException\n" + + "catchError(message: 'caught error') {\n" + + " throw new FlowInterruptedException(Result.ABORTED, true, new CauseOfInterruption[0])\n" + + "}", false)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertCatchError(r, b, Result.ABORTED, Result.ABORTED, true); } - @Test public void canAvoidCatchingTimeoutsWithOption() throws Exception { + @Test public void canAvoidCatchingInterruptionsWithOption() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition( - "timeout(time: 1, unit: 'SECONDS') {\n" + - " catchError(message: 'caught error', catchInterruptions: false) {\n" + - " sleep 5\n" + - " }\n" + - "}", true)); + "import jenkins.model.CauseOfInterruption\n" + + "import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException\n" + + "catchError(message: 'caught error', catchInterruptions: false) {\n" + + " throw new FlowInterruptedException(Result.ABORTED, true, new CauseOfInterruption[0])\n" + + "}", false)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertCatchError(r, b, Result.ABORTED, null, false); }