Package org.springframework.batch.core.repository

Examples of org.springframework.batch.core.repository.JobRepository


  @Ignore
  @Test
  public void testTransactionAttributesForCreateMethodNullHypothesis() throws Exception {
    testCreateRepository();
    JobRepository repository = factory.getObject();
    DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(
        DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
    when(transactionManager.getTransaction(transactionDefinition)).thenReturn(null);
    try {
      repository.createJobExecution("foo", new JobParameters());
      // we expect an exception from the txControl because we provided the
      // wrong meta data
      fail("Expected IllegalArgumentException");
    }
    catch (AssertionError e) {
View Full Code Here


  @Test
  public void testTransactionAttributesForCreateMethod() throws Exception {

    testCreateRepository();
    JobRepository repository = factory.getObject();
    DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(
        DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
    transactionDefinition.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_SERIALIZABLE);
    when(transactionManager.getTransaction(transactionDefinition)).thenReturn(null);
    Connection conn = mock(Connection.class);
    when(dataSource.getConnection()).thenReturn(conn);
    try {
      repository.createJobExecution("foo", new JobParameters());
      // we expect an exception but not from the txControl because we
      // provided the correct meta data
      fail("Expected IllegalArgumentException");
    }
    catch (IllegalArgumentException e) {
View Full Code Here

  @Test
  public void testSetTransactionAttributesForCreateMethod() throws Exception {

    factory.setIsolationLevelForCreate("ISOLATION_READ_UNCOMMITTED");
    testCreateRepository();
    JobRepository repository = factory.getObject();
    DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(
        DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
    transactionDefinition.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    when(transactionManager.getTransaction(transactionDefinition)).thenReturn(null);
    Connection conn = mock(Connection.class);
    when(dataSource.getConnection()).thenReturn(conn);
    try {
      repository.createJobExecution("foo", new JobParameters());
      // we expect an exception but not from the txControl because we
      // provided the correct meta data
      fail("Expected IllegalArgumentException");
    }
    catch (IllegalArgumentException e) {
View Full Code Here

  @Test
  public void testCustomLobType() throws Exception {
    factory.setClobType(Types.ARRAY);
    testCreateRepository();
    JobRepository repository = factory.getObject();
    assertNotNull(repository);
  }
View Full Code Here

  @Test(expected=JobRestartException.class)
  public void testRunStepStatusUnknown() throws Exception {
    //try and restart a job where the step execution is UNKNOWN
    //setup
    String jobName = "test_job";
    JobRepository jobRepository = mock(JobRepository.class);
    JobParameters parameters = new JobParametersBuilder().addLong("runtime", System.currentTimeMillis()).toJobParameters();
    JobExecution jobExecution = mock(JobExecution.class);
    Job job = mock(Job.class);
    JobParametersValidator validator = mock(JobParametersValidator.class);
    StepExecution stepExecution = mock(StepExecution.class);

    when(job.getName()).thenReturn(jobName);
    when(job.isRestartable()).thenReturn(true);
    when(job.getJobParametersValidator()).thenReturn(validator);
    when(jobRepository.getLastJobExecution(jobName, parameters)).thenReturn(jobExecution);
    when(stepExecution.getStatus()).thenReturn(BatchStatus.UNKNOWN);
    when(jobExecution.getStepExecutions()).thenReturn(Arrays.asList(stepExecution));

    //setup launcher
    jobLauncher = new SimpleJobLauncher();
View Full Code Here

  private StepExecution stepExecution2;

  @Before
  public void init() throws Exception {
    MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
    JobRepository jobRepository = factory.getObject();
    aggregator.setJobExplorer(new MapJobExplorerFactoryBean(factory).getObject());
    jobExecution = jobRepository.createJobExecution("job", new JobParameters());
    result = jobExecution.createStepExecution("aggregate");
    stepExecution1 = jobExecution.createStepExecution("foo:1");
    stepExecution2 = jobExecution.createStepExecution("foo:2");
    jobRepository.add(stepExecution1);
    jobRepository.add(stepExecution2);
  }
View Full Code Here

  public void testStepExecutionUpdateFailure() throws Exception {

    JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
    StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);

    JobRepository repository = new JobRepositoryFailedUpdateStub();

    step.setJobRepository(repository);
    step.afterPropertiesSet();

    step.execute(stepExecution);
View Full Code Here

  private JobExecution execution;

  @Before
  public void init() throws Exception {
    JobRepository jobRepository = new MapJobRepositoryFactoryBean().getObject();
    job.setJobRepository(jobRepository);
    execution = jobRepository.createJobExecution("job", new JobParameters());
  }
View Full Code Here

      }
    }

    MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
    factory.afterPropertiesSet();
    JobRepository repository = factory.getObject();
    job.setJobRepository(repository);
    job.setRestartable(true);

    JobExecution execution = repository.createJobExecution("testHandleStepJob", new JobParameters());
    job.handleStep(new StubStep(), execution);

    assertEquals(StubStep.value, execution.getExecutionContext().get(StubStep.key));

    // simulate restart and check the job execution context's content survives
    execution.setEndTime(new Date());
    execution.setStatus(BatchStatus.FAILED);
    repository.update(execution);

    JobExecution restarted = repository.createJobExecution("testHandleStepJob", new JobParameters());
    assertEquals(StubStep.value, restarted.getExecutionContext().get(StubStep.key));
  }
View Full Code Here

public class FlowBuilderTests {

  @Test
  public void test() throws Exception {
    FlowBuilder<Flow> builder = new FlowBuilder<Flow>("flow");
    JobRepository jobRepository = new MapJobRepositoryFactoryBean().getObject();
    JobExecution execution = jobRepository.createJobExecution("foo", new JobParameters());
    builder.start(new StepSupport("step") {
      @Override
      public void execute(StepExecution stepExecution) throws JobInterruptedException,
          UnexpectedJobExecutionException {
      }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.repository.JobRepository

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.