public JobExecution launch(String jobName, JobParameters jobParameters)
      throws NoSuchJobException, JobExecutionAlreadyRunningException, JobRestartException,
          JobInstanceAlreadyCompleteException, JobParametersInvalidException {

    Job job = jobLocator.getJob(jobName);

    JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters);
    boolean restart = false;
    if (lastJobExecution != null) {
      BatchStatus status = lastJobExecution.getStatus();
      if (status.isUnsuccessful() && status != BatchStatus.ABANDONED) {
        restart = true;
      }
    }

    if (job.getJobParametersIncrementer() != null && !restart) {
      jobParameters = job.getJobParametersIncrementer().getNext(jobParameters);
    }

    JobExecution jobExecution = jobLauncher.run(job, jobParameters);

    if (jobExecution.isRunning()) {
      activeExecutions.add(jobExecution);
    }
    return jobExecution;
  }
  @Test
  public void testGrabLineStop() throws Exception {
    BatchStatus batchStatus;
    JobParametersBuilder builder =
        new JobParametersBuilder(getJobLauncherTestUtils().getUniqueJobParameters());

    builder.addParameter("input.file.path", new JobParameter("train-list.properties"));
    builder.addParameter(
        "date", new JobParameter(new SimpleDateFormat("dd/MM/yyyy").parse("01/01/2000")));
    builder.addParameter("language", new JobParameter(Language.EN.name()));
    builder.addParameter("station.departure", new JobParameter("Liège-Guillemins"));
    builder.addParameter("station.arrival", new JobParameter("Bruxelles-Central"));
    builder.addParameter("excel.output.path", new JobParameter("./target"));
    builder.addParameter("excel.file.name", new JobParameter("sncb_"));
    builder.addParameter("excel.file.extension", new JobParameter("xls"));
    builder.addParameter("excel.archive.path", new JobParameter("./target"));
    builder.addParameter("text.output.path", new JobParameter("./target/output.txt"));
    builder.addParameter(
        "excel.template.path",
        new JobParameter(new ClassPathResource("template.xls").getFile().getAbsolutePath()));

    batchStatus = getJobLauncherTestUtils().launchJob(builder.toJobParameters()).getStatus();

    Assert.assertFalse(batchStatus.isUnsuccessful());
  }