Example usage for org.springframework.batch.core JobInterruptedException getMessage

List of usage examples for org.springframework.batch.core JobInterruptedException getMessage

Introduction

In this page you can find the example usage for org.springframework.batch.core JobInterruptedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.springframework.batch.core.step.tasklet.SystemCommandTaskletIntegrationTests.java

@Test
public void testInterruption() throws Exception {
    String command = System.getProperty("os.name").toLowerCase().contains("win") ? "ping 1.1.1.1 -n 1 -w 5000"
            : "sleep 5";
    tasklet.setCommand(command);//  w w w  .j ava2  s.  co m
    tasklet.setTerminationCheckInterval(10);
    tasklet.afterPropertiesSet();

    stepExecution.setTerminateOnly();
    try {
        tasklet.execute(null, null);
        fail();
    } catch (JobInterruptedException e) {
        System.out.println(e.getMessage());
        assertTrue(e.getMessage().contains("Job interrupted while executing system command"));
        assertTrue(e.getMessage().contains(command));
    }
}