Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobInstance


    };

    testRun();
    try {
      when(jobRepository.getLastJobExecution(job.getName(), jobParameters)).thenReturn(
          new JobExecution(new JobInstance(1L, job.getName()), jobParameters));
      jobLauncher.run(job, jobParameters);
      fail("Expected JobRestartException");
    }
    catch (JobRestartException e) {
      // expected
View Full Code Here


  private NoWorkFoundStepExecutionListener tested = new NoWorkFoundStepExecutionListener();

  @Test
  public void noWork() {
    StepExecution stepExecution = new StepExecution("NoProcessingStep", new JobExecution(new JobInstance(1L, "NoProcessingJob"), new JobParameters()));

    stepExecution.setExitStatus(ExitStatus.COMPLETED);
    stepExecution.setReadCount(0);

    ExitStatus exitStatus = tested.afterStep(stepExecution);
View Full Code Here

    assertEquals(ExitStatus.FAILED.getExitCode(), exitStatus.getExitCode());
  }

  @Test
  public void workDone() {
    StepExecution stepExecution = new StepExecution("NoProcessingStep", new JobExecution(new JobInstance(1L,
        "NoProcessingJob"), new JobParameters()));

    stepExecution.setReadCount(1);

    ExitStatus exitStatus = tested.afterStep(stepExecution);
View Full Code Here

    JobExecution jobExecution = stepExecution.getJobExecution();
    if (!sameJobExecution) {
      jobExecution.setStatus(BatchStatus.FAILED);
      jobExecution.setEndTime(new Date());
      jobRepository.update(jobExecution);
      JobInstance jobInstance = jobExecution.getJobInstance();
      jobExecution = jobRepository.createJobExecution(jobInstance.getJobName(), jobExecution.getJobParameters());
    }

    stepExecution = jobExecution.createStepExecution(stepExecution.getStepName());
    stepExecution.setExecutionContext(executionContext);
View Full Code Here

   *
   * @see org.springframework.batch.core.launch.JobOperator#getExecutions(java.lang.Long)
   */
  @Override
  public List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException {
    JobInstance jobInstance = jobExplorer.getJobInstance(instanceId);
    if (jobInstance == null) {
      throw new NoSuchJobInstanceException(String.format("No job instance with id=%d", instanceId));
    }
    List<Long> list = new ArrayList<Long>();
    for (JobExecution jobExecution : jobExplorer.getJobExecutions(jobInstance)) {
View Full Code Here

    step = getStep(new String[] { "foo", "bar", "spam" });
    step.setStepOperations(template);

    job = new JobSupport("FOO");
    jobInstance = new JobInstance(0L, job.getName());
    jobParameters = new JobParameters();

    step.setTransactionManager(transactionManager);

  }
View Full Code Here

    return null;
  }

  private void checkRepository(BatchStatus status, ExitStatus exitStatus) {
    // because map dao stores in memory, it can be checked directly
    JobInstance jobInstance = jobExecution.getJobInstance();
    JobExecution other = jobExecutionDao.findJobExecutions(jobInstance).get(0);
    assertEquals(jobInstance.getId(), other.getJobId());
    assertEquals(status, other.getStatus());
    if (exitStatus != null) {
      assertEquals(exitStatus.getExitCode(), other.getExitStatus().getExitCode());
    }
  }
View Full Code Here

  }

  @Test
  public void testJobParameters() throws Exception {
    JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
    JobInstance instance = stepExecution.getJobExecution().getJobInstance();
    stepExecution = new StepExecution("step", new JobExecution(instance, jobParameters));
    context = new StepContext(stepExecution);
    assertEquals("bar", context.getJobParameters().get("foo"));
  }
View Full Code Here

  private JobContext context;

  @Before
  public void setUp() {
    jobExecution = new JobExecution(1L);
    JobInstance jobInstance = new JobInstance(2L, "job");
    jobExecution.setJobInstance(jobInstance);
    context = new JobContext(jobExecution);
    list = new ArrayList<String>();
  }
View Full Code Here

  }

  @Test
  public void testJobParameters() throws Exception {
    JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters();
    JobInstance jobInstance = new JobInstance(0L, "foo");
    jobExecution = new JobExecution(5L, jobParameters);
    jobExecution.setJobInstance(jobInstance);
    context = new JobContext(jobExecution);
    assertEquals("bar", context.getJobParameters().get("foo"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.JobInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.