Package org.springframework.batch.item

Examples of org.springframework.batch.item.ExecutionContext


    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)).andReturn(new ExecutionContext());
    stepExecutionDao.addStepExecutions(jobExecution);
    EasyMock.expectLastCall();
    EasyMock.replay(stepExecutionDao, jobExecutionDao, jobInstanceDao, executionContextDao);
    JobExecution result = service.getJobExecution(123L);
    assertNotNull(result);
View Full Code Here


  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));
    EasyMock.verify(jobExecutionDao, stepExecutionDao, executionContextDao, jobInstanceDao);
  }
View Full Code Here

  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(
View Full Code Here

    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);

    EasyMock.replay(jobExecutionDao, stepExecutionDao, executionContextDao, jobInstanceDao);

    service.removeInactiveExecutions();
View Full Code Here

    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();
    stepExecutionDao.addStepExecutions(jobExecution);
    EasyMock.expectLastCall().anyTimes();

    EasyMock.replay(jobExecutionDao, stepExecutionDao, executionContextDao, jobInstanceDao);
View Full Code Here

      public void handleLine(String line) {
        headers.add(line);
      }
    });
    reader.setLineMapper(lineMapper);
    reader.open(new ExecutionContext());

    List<FieldSet> list = new ArrayList<FieldSet>();
    FieldSet item = reader.read();
    while (item!=null) {
      list.add(item);
      item = reader.read();
    }
    assertEquals(7, list.size());

    FlatFileItemWriter<FieldSet> writer = new FlatFileItemWriter<FieldSet>();
    FileSystemResource resource = new FileSystemResource("target/output/output.txt");
    FileUtils.deleteQuietly(resource.getFile());
    writer.setResource(resource);
    writer.setHeaderCallback(new FlatFileHeaderCallback() {
      public void writeHeader(Writer writer) throws IOException {
        for (String header : headers) {
          writer.write(header);
        }
      }
    });
    writer.setLineAggregator(new DelimitedLineAggregator<FieldSet>());
    writer.open(new ExecutionContext());
   
    String[] names = getFields(list, 1);
    String[] country = getFields(list, 2);
    String[] products = getFields(list, 3);
    double[] amounts = getMinMax(list, 4);
View Full Code Here

    assertEquals(8, count);
  }

  @Test
  public void testOpen() throws Exception {
    ExecutionContext context = new ExecutionContext();
    for (int i=0; i<4; i++) {
      reader.read();
    }
    reader.update(context);
    reader.open(context);
View Full Code Here

    assertEquals(4, count);   
  }

  @Test
  public void testFailAndRestart() throws Exception {
    ExecutionContext context = new ExecutionContext();
    ExampleItemReader.fail = true;
    for (int i=0; i<4; i++) {
      reader.read();
      reader.update(context);
    }
View Full Code Here

    }
  }

  @Test
  public void testOpenWithNoState() throws Exception {
    writer.open(new ExecutionContext());
  }
View Full Code Here

    writer.open(new ExecutionContext());
  }

  @Test
  public void testUpdateAndOpenWithState() throws Exception {
    ExecutionContext executionContext = new ExecutionContext();
    writer.update(executionContext);
    writer.open(executionContext);
    assertEquals(0, executionContext.getInt(ChunkMessageChannelItemWriter.EXPECTED));
    assertEquals(0, executionContext.getInt(ChunkMessageChannelItemWriter.ACTUAL));
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.ExecutionContext

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.