Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobExecution


        Assert.assertFalse("Empty job name", jobName.length() <= 0);
        Assert.assertNotNull("No job parameters provided", jobParameters);

        Long id = Long.valueOf(idsGenerator.incrementAndGet());
        JobInstance instance = new JobInstance(id, jobName);
        return new JobExecution(instance, jobParameters);
    }
View Full Code Here


    }

    @Test
    public void testExecute() throws JobInterruptedException {
        Step step = createTestStep("testExecute");
        JobExecution jobData = TestDummyJobRepository.createJobExecutionInstance(step.getName());
        StepExecution stepData = new StepExecution(step.getName(), jobData);
        step.execute(stepData);
        assertOperationDetails(getLastEntered(), "execute", step.getName());
    }
View Full Code Here

        SimpleJobLauncher launcher = new SimpleJobLauncher();
        launcher.setJobRepository(new TestDummyJobRepository());
        launcher.afterPropertiesSet();

        Job job = new TestDummyJob("testRunJob");
        JobExecution execution = launcher.run(job, new JobParameters());
        assertNotNull("No job exectuion instance", execution);

        String jobName = job.getName();
        Operation op = assertOperationDetails(getFirstEntered(), "run", job.getName());
        assertOperationPath(op, jobName, null);
View Full Code Here

    protected Operation assertOperationPath(Operation op, FlowExecutor flowExecutor) {
        return assertOperationPath(op, flowExecutor.getStepExecution());
    }

    protected Operation assertOperationPath(Operation op, StepExecution stepExecution) {
        JobExecution jobExecution = stepExecution.getJobExecution();
        JobInstance jobInstance = jobExecution.getJobInstance();
        return assertOperationPath(op, jobInstance.getJobName(), stepExecution.getStepName());
    }
View Full Code Here

    protected FlowExecutor createFlowExecutor(String jobName, String stepName) {
        return createFlowExecutor(createStepExecution(jobName, stepName));
    }

    protected StepExecution createStepExecution(String jobName, String stepName) {
        JobExecution jobExecution = createJobExecution(jobName);
        StepExecution stepExecution = Mockito.mock(StepExecution.class);
        Mockito.when(stepExecution.getStepName()).thenReturn(stepName);
        Mockito.when(stepExecution.getJobExecution()).thenReturn(jobExecution);
        return stepExecution;
    }
View Full Code Here

    }

    protected JobExecution createJobExecution(String jobName) {
        JobInstance jobInstance = Mockito.mock(JobInstance.class);
        Mockito.when(jobInstance.getJobName()).thenReturn(jobName);
        JobExecution jobExecution = Mockito.mock(JobExecution.class);
        Mockito.when(jobExecution.getJobInstance()).thenReturn(jobInstance);
        return jobExecution;
    }
View Full Code Here

  @Test
  public void testSkip() throws Exception {
    this.createUsers(new Object[][] { USER1, USER2_SKIP, USER3, USER4_SKIP, USER5, USER6, USER7, USER8 });

    JobExecution jobExecution = jobLauncherTestUtils.launchJob();
    assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());

    List<SimpleMailMessage> receivedMessages = mailSender.getReceivedMessages();
    assertEquals(6, receivedMessages.size());
    Iterator<SimpleMailMessage> emailIter = receivedMessages.iterator();
    for (Object[] record : new Object[][] { USER1, USER3, USER5, USER6, USER7, USER8 }) {
View Full Code Here

   * @throws Exception if there is a problem
   * @see TestExecutionListener#prepareTestInstance(TestContext)
   */
  @Override
  public void prepareTestInstance(TestContext testContext) throws Exception {
    JobExecution jobExecution = getJobExecution(testContext);
    if (jobExecution != null) {
      testContext.setAttribute(JOB_EXECUTION, jobExecution);
    }
  }
View Full Code Here

   * @see TestExecutionListener#beforeTestMethod(TestContext)
   */
  @Override
  public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws Exception {
    if (testContext.hasAttribute(JOB_EXECUTION)) {
      JobExecution jobExecution = (JobExecution) testContext.getAttribute(JOB_EXECUTION);
      JobSynchronizationManager.register(jobExecution);
    }

  }
View Full Code Here

  private JobLauncherTestUtils jobLauncherTestUtils;
   
  @Test
  public void testLaunchJob() throws Exception {

    JobExecution jobExecution = jobLauncherTestUtils.launchJob();
   
    Thread.sleep(1000);

    assertEquals(BatchStatus.STARTED, jobExecution.getStatus());
    assertTrue(jobExecution.isRunning());
    assertNotNull(jobExecution.getVersion());

    jobOperator.stop(jobExecution.getId());
   
    int count = 0;
    while(jobExecution.isRunning() && count <= 10){
      logger.info("Checking for end time in JobExecution: count="+count);
      Thread.sleep(100);
      count++;
    }
   
    assertFalse("Timed out waiting for job to end.", jobExecution.isRunning());
    assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());

  }
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.