/*
   * Job interrupted scenario.
   */
  @Test
  public void testInterruption() throws Exception {
    String command = "sleep 5";
    tasklet.setCommand(command);
    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));
    }
  }
 @Override
 public void beforeStep(StepExecution stepExecution) {
   stepExecution.setTerminateOnly();
 }