Java 类org.springframework.batch.core.JobInterruptedException 实例源码

项目:spring-cloud-task    文件:DeployerStepExecutionHandlerTests.java   
@Test
public void testJobInterruptedException() throws Exception {
    StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);

    when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
    when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
    when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
    when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
    when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
    when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
    when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
    when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
    when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
    when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
    doThrow(new JobInterruptedException("expected")).when(this.step).execute(workerStep);

    handler.run();

    verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());

    assertEquals(BatchStatus.STOPPED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
项目:Spring-Batch-en-Castellano    文件:RemoteStep.java   
@Override
public void execute(StepExecution stepExecution) throws JobInterruptedException {
    step.execute(stepExecution);
}
项目:marklogic-spring-batch    文件:StepSupport.java   
/**
 * Not supported but provided so that tests can easily create a step.
 *
 * @throws UnsupportedOperationException always
 *
 * @see org.springframework.batch.core.Step#execute(org.springframework.batch.core.StepExecution)
 */
@Override
public void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException {
    throw new UnsupportedOperationException(
            "Cannot process a StepExecution.  Use a smarter subclass of StepSupport.");
}