Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobInstance


  }

  @Test
  public void testGetLastInstancesSunnyDay() throws Exception {
    jobParameters = new JobParameters();
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    when(jobExplorer.getJobInstances("foo", 0, 2)).thenReturn(Collections.singletonList(jobInstance));
    jobExplorer.getJobInstances("foo", 0, 2);
    List<Long> value = jobOperator.getJobInstances("foo", 0, 2);
    assertEquals(123L, value.get(0).longValue());
  }
View Full Code Here


    assertTrue("Wrong names: " + names, names.contains("foo"));
  }

  @Test
  public void testGetExecutionsSunnyDay() throws Exception {
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    when(jobExplorer.getJobInstance(123L)).thenReturn(jobInstance);

    JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
    when(jobExplorer.getJobExecutions(jobInstance)).thenReturn(Collections.singletonList(jobExecution));
    List<Long> value = jobOperator.getExecutions(123L);
View Full Code Here

    }
  }

  @Test
  public void testStop() throws Exception{
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
    when(jobExplorer.getJobExecution(111L)).thenReturn(jobExecution);
    jobExplorer.getJobExecution(111L);
    jobRepository.update(jobExecution);
    jobOperator.stop(111L);
View Full Code Here

    assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
  }

  @Test
  public void testStopTasklet() throws Exception {
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
    StoppableTasklet tasklet = mock(StoppableTasklet.class);
    TaskletStep taskletStep = new TaskletStep();
    taskletStep.setTasklet(tasklet);
    MockJob job = new MockJob();
View Full Code Here

    assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
  }

  @Test
  public void testStopTaskletException() throws Exception {
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
    StoppableTasklet tasklet = new StoppableTasklet() {

      @Override
      public RepeatStatus execute(StepContribution contribution,
View Full Code Here

      assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
  }

  @Test
  public void testAbort() throws Exception {
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
    jobExecution.setStatus(BatchStatus.STOPPING);
    when(jobExplorer.getJobExecution(123L)).thenReturn(jobExecution);
    jobRepository.update(jobExecution);
    jobOperator.abandon(123L);
View Full Code Here

    assertNotNull(jobExecution.getEndTime());
  }

  @Test(expected = JobExecutionAlreadyRunningException.class)
  public void testAbortNonStopping() throws Exception {
    JobInstance jobInstance = new JobInstance(123L, job.getName());
    JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null);
    jobExecution.setStatus(BatchStatus.STARTED);
    when(jobExplorer.getJobExecution(123L)).thenReturn(jobExecution);
    jobRepository.update(jobExecution);
    jobOperator.abandon(123L);
View Full Code Here

   * Modifications to saved entity do not affect the persisted object.
   */
  @Test
  public void testPersistentCopy() {
    JobExecutionDao tested = new MapJobExecutionDao();
    JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, "mapJob"), new JobParameters());

    assertNull(jobExecution.getStartTime());
    tested.saveJobExecution(jobExecution);
    jobExecution.setStartTime(new Date());

View Full Code Here

    // Implementation of the high-concurrency code
    final Runnable codeUnderTest = new Runnable() {
      @Override
      public void run() {
        try {
          JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, "mapJob"), new JobParameters());
          latch.await();
          tested.saveJobExecution(jobExecution);
          ids.add(jobExecution.getId());
        } catch(Exception e) {
          exception.set(e);
View Full Code Here

   */
  @Transactional
  @Test
  public void testCreateAndRetrieve() throws Exception {

    JobInstance fooInstance = dao.createJobInstance(fooJob, fooParams);
    assertNotNull(fooInstance.getId());
    assertEquals(fooJob, fooInstance.getJobName());

    JobInstance retrievedInstance = dao.getJobInstance(fooJob, fooParams);
    assertEquals(fooInstance, retrievedInstance);
    assertEquals(fooJob, retrievedInstance.getJobName());
  }
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.