Package javax.batch.runtime

Examples of javax.batch.runtime.JobExecution


    assertEquals(3, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size());
  }

  @Test
  public void testDecisionUnmappedExitStatus() throws Exception {
    JobExecution execution = runJob("DecisionStepTests-decisionInvalidExitStatus-context", new Properties(), 10000L);
    assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
    List<StepExecution> stepExecutions = BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId());
    assertEquals(2, stepExecutions.size());

    for (StepExecution curExecution : stepExecutions) {
      assertEquals(BatchStatus.COMPLETED, curExecution.getBatchStatus());
    }
View Full Code Here


    }
  }

  @Test
  public void testDecisionCustomExitStatus() throws Exception {
    JobExecution execution = runJob("DecisionStepTests-decisionCustomExitStatus-context", new Properties(), 10000L);
    assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
    assertEquals(2, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size());
    assertEquals("CustomFail", execution.getExitStatus());
  }
View Full Code Here

    assertEquals("CustomFail", execution.getExitStatus());
  }

  @Test
  public void testDecisionAfterFlow() throws Exception {
    JobExecution execution = runJob("DecisionStepTests-decisionAfterFlow-context", new Properties(), 10000L);
    assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
    assertEquals(3, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size());
  }
View Full Code Here

    assertEquals(3, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size());
  }

  @Test
  public void testDecisionAfterSplit() throws Exception {
    JobExecution execution = runJob("DecisionStepTests-decisionAfterSplit-context", new Properties(), 10000L);
    assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
    assertEquals(4, BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId()).size());
    assertEquals(2, StepExecutionCountingDecider.previousStepCount);
  }
View Full Code Here

    assertEquals(2, StepExecutionCountingDecider.previousStepCount);
  }

  @Test
  public void testDecisionRestart() throws Exception {
    JobExecution execution = runJob("DecisionStepTests-restart-context", new Properties(), 10000L);
    assertEquals(BatchStatus.STOPPED, execution.getBatchStatus());

    List<StepExecution> stepExecutions = BatchRuntime.getJobOperator().getStepExecutions(execution.getExecutionId());
    assertEquals(2, stepExecutions.size());

    assertEquals("step1", stepExecutions.get(0).getStepName());
    assertEquals("decision1", stepExecutions.get(1).getStepName());

    JobExecution execution2 = restartJob(execution.getExecutionId(), new Properties(), 10000L);
    assertEquals(BatchStatus.COMPLETED, execution2.getBatchStatus());

    List<StepExecution> stepExecutions2 = BatchRuntime.getJobOperator().getStepExecutions(execution2.getExecutionId());
    assertEquals(2, stepExecutions2.size());

    assertEquals("decision1", stepExecutions2.get(0).getStepName());
    assertEquals("step2", stepExecutions2.get(1).getStepName());
  }
View Full Code Here

    assertTrue("testBatchlet1 bean definition not found", applicationContext.containsBeanDefinition("testBatchlet1"));
  }

  @Test
  public void testArtifactUniqueness() throws Exception {
    JobExecution jobExecution = runJob("jsrUniqueInstanceTests", new Properties(), 10000L);
    String exitStatus = jobExecution.getExitStatus();

    assertTrue("Exit status must contain listener3", exitStatus.contains("listener3"));
    exitStatus = exitStatus.replace("listener3", "");

    assertTrue("Exit status must contain listener2", exitStatus.contains("listener2"));
View Full Code Here

    assertTrue("singleton".equals(testBatchletBeanDefinition.getScope()));
  }

  @Test
  public void testSpringArtifactUniqueness() throws Exception {
    JobExecution jobExecution = runJob("jsrSpringInstanceTests", new Properties(), 10000L);
    String exitStatus = jobExecution.getExitStatus();

    assertTrue("Exit status must contain listener1", exitStatus.contains("listener1"));
    assertTrue("exitStatus must contain 2 listener1 values", StringUtils.countOccurrencesOf(exitStatus, "listener1") == 2);

    exitStatus = exitStatus.replace("listener1", "");
View Full Code Here

*/
public class JsrEndStateTests extends AbstractJsrTestCase {

  @Test
  public void test() throws Exception {
    JobExecution jobExecution = runJob("jobWithEndTransition", null, 10000L);

    assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
    assertEquals("SUCCESS", jobExecution.getExitStatus());
    assertEquals(1, BatchRuntime.getJobOperator().getStepExecutions(jobExecution.getExecutionId()).size());
  }
View Full Code Here

    private List<JobExecution> findJobExecutions(long exeId)
        throws javax.batch.operations.exception.SecurityException {
        List<JobExecution> jobExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        JobExecution jobExecution = jobOperator.getJobExecution(Long.valueOf(exeId));
        if (jobExecution != null)
            jobExecutions.add(jobExecution);

        return jobExecutions;
    }
View Full Code Here

   * @return the {@link javax.batch.runtime.JobExecution} for the final state of the job
   * @throws java.util.concurrent.TimeoutException if the timeout occurs
   */
  public static JobExecution runJob(String jobName, Properties properties, long timeout) throws TimeoutException {
    long executionId = operator.start(jobName, properties);
    JobExecution execution = operator.getJobExecution(executionId);

    Date curDate = new Date();
    BatchStatus curBatchStatus = execution.getBatchStatus();

    while(true) {
      if(curBatchStatus == BatchStatus.STOPPED || curBatchStatus == BatchStatus.COMPLETED || curBatchStatus == BatchStatus.FAILED) {
        break;
      }

      if(new Date().getTime() - curDate.getTime() > timeout) {
        throw new TimeoutException("Job processing did not complete in time");
      }

      execution = operator.getJobExecution(executionId);
      curBatchStatus = execution.getBatchStatus();
    }
    return execution;
  }
View Full Code Here

TOP

Related Classes of javax.batch.runtime.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.