Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobExecution


    EasyMock.verify(jobLocator);
  }

  @Test
  public void testGetJobExecutionWithUnserializableExecutionContext() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution(123L);
    JobInstance jobInstance = jobExecution.getJobInstance();
    jobExecution.setJobInstance(null);
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(jobInstance);
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andThrow(
        new IllegalStateException("Planned"));
    stepExecutionDao.addStepExecutions(jobExecution);
    EasyMock.expectLastCall();
    EasyMock.replay(stepExecutionDao, jobExecutionDao, jobInstanceDao, executionContextDao);
    JobExecution result = service.getJobExecution(123L);
    assertNotNull(result);
    assertNotNull(result.getJobInstance());
    assertNotNull(result.getExecutionContext());
    EasyMock.verify(stepExecutionDao, jobExecutionDao, jobInstanceDao, executionContextDao);
  }
View Full Code Here


    assertEquals(2, wrapper.get("jobExecutions", Map.class).size());
  }

  @Test
  public void testViewWithPagination() throws Exception {
    JobExecution jobExecution1 = MetaDataInstanceFactory.createJobExecution();
    JobExecution jobExecution2 = MetaDataInstanceFactory.createJobExecution(13L);
    jobExecution2.setEndTime(new Date());
    model.put("baseUrl", "http://localhost:8080/springsource");
    model.put("jobExecutions", Arrays.asList(new JobExecutionInfo(jobExecution1, TimeZone.getTimeZone("GMT")),
        new JobExecutionInfo(jobExecution2, TimeZone.getTimeZone("GMT"))));
    model.put("currentTime", new Date());
    model.put("startJobExecution", 11);
View Full Code Here

    assertEquals(5, wrapper.get("page", Map.class).size());
  }

  @Test
  public void testViewWithNoPagination() throws Exception {
    JobExecution jobExecution1 = MetaDataInstanceFactory.createJobExecution();
    JobExecution jobExecution2 = MetaDataInstanceFactory.createJobExecution(13L);
    jobExecution2.setEndTime(new Date());
    model.put("baseUrl", "http://localhost:8080/springsource");
    model.put("jobExecutions", Arrays.asList(new JobExecutionInfo(jobExecution1, TimeZone.getTimeZone("GMT")),
        new JobExecutionInfo(jobExecution2, TimeZone.getTimeZone("GMT"))));
    model.put("currentTime", new Date());
    model.put("startJobExecution", 1);
View Full Code Here

    Long jobInstanceId = 12L;
    JobInstance jobInstance = MetaDataInstanceFactory.createJobInstance(jobName, jobInstanceId);
    EasyMock.expect(jobLocator.getJobNames()).andReturn(Collections.<String> emptyList());
    EasyMock.expect(jobInstanceDao.countJobInstances(jobName)).andReturn(1);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobInstanceId)).andReturn(jobInstance);
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    EasyMock.expect(jobExecutionDao.findJobExecutions(jobInstance)).andReturn(Arrays.asList(jobExecution));
    stepExecutionDao.addStepExecutions(jobExecution);
    EasyMock.expectLastCall();
    EasyMock.replay(jobLocator, jobInstanceDao, stepExecutionDao, jobExecutionDao);
    assertEquals(1, service.getJobExecutionsForJobInstance("job", jobInstance.getId()).size());
View Full Code Here

  /**
   * Test method for {@link SimpleJobService#getStepExecution(Long, Long)}.
   */
  @Test
  public void testGetStepExecution() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecutionWithStepExecutions(123L, Arrays
        .asList("step1"));
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(null);
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andReturn(new ExecutionContext());
    stepExecutionDao.addStepExecutions(jobExecution);
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    Long stepExecutionId = stepExecution.getId();
    EasyMock.expect(stepExecutionDao.getStepExecution(jobExecution, stepExecutionId)).andReturn(stepExecution);
    EasyMock.expect(executionContextDao.getExecutionContext(stepExecution)).andReturn(new ExecutionContext());
    EasyMock.replay(jobExecutionDao, stepExecutionDao, executionContextDao, jobInstanceDao);
    assertNotNull(service.getStepExecution(123L, 1234L));
View Full Code Here

    EasyMock.verify(jobExecutionDao, stepExecutionDao, executionContextDao, jobInstanceDao);
  }

  @Test
  public void testGetStepExecutionWithUnserializableExecutionContent() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecutionWithStepExecutions(123L, Arrays
        .asList("step1"));
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(null);
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andReturn(new ExecutionContext());
    stepExecutionDao.addStepExecutions(jobExecution);
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    Long stepExecutionId = stepExecution.getId();
    EasyMock.expect(stepExecutionDao.getStepExecution(jobExecution, stepExecutionId)).andReturn(stepExecution);
    EasyMock.expect(executionContextDao.getExecutionContext(stepExecution)).andThrow(
        new IllegalStateException("Expected"));
    EasyMock.replay(jobExecutionDao, stepExecutionDao, executionContextDao, jobInstanceDao);
View Full Code Here

  @Test
  public void testRemoveInactives() throws Exception {

    testLaunch();

    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(null);
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andReturn(new ExecutionContext());
    stepExecutionDao.addStepExecutions(jobExecution);
View Full Code Here

  @Test
  public void testDestroyWithActives() throws Exception {

    testLaunch();

    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    jobExecution.setEndTime(new Date());
    assertFalse(jobExecution.isRunning());

    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution).anyTimes();
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(null).anyTimes();
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andReturn(new ExecutionContext())
    .anyTimes();
View Full Code Here

  }

  @Test
  public void testRestartSunnyDay() throws Exception {

    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    jobExecution.setStatus(BatchStatus.FAILED);
    jobService.getJobExecutionsForJobInstance("foo", 11L);
    EasyMock.expectLastCall().andReturn(Arrays.asList(jobExecution));
    jobService.restart(123L);
    EasyMock.expectLastCall().andReturn(jobExecution);
    EasyMock.replay(jobService);
View Full Code Here

  }

  @Test
  public void testLaunchJob() throws Exception {
    int before = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
    JobExecution jobExecution = jobLauncher.run(job1, jobParameters);
    assertNotNull(jobExecution);
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    int after = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
    assertEquals(before + 1, after);
  }
View Full Code Here

TOP

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

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.