Package org.springframework.batch.item

Examples of org.springframework.batch.item.ExecutionContext


 
    getAsItemStream(reader).close();

    // create new input source
    reader = createItemReader();
    getAsItemStream(reader).open(new ExecutionContext());

    Foo foo = reader.read();
    assertEquals(1, foo.getValue());

    try {
View Full Code Here


   * Empty resource list is OK.
   */
  @Test
  public void testNoResourcesFound() throws Exception {
    tested.setResources(new Resource[] {});
    tested.open(new ExecutionContext());

    assertNull(tested.read());

    tested.close();
  }
View Full Code Here

   */
  @Test
  public void testNonExistentResources() throws Exception {
    tested.setResources(new Resource[] { new FileSystemResource("no/such/file.txt") });
    itemReader.setStrict(false);
    tested.open(new ExecutionContext());

    assertNull(tested.read());

    tested.close();
  }
View Full Code Here

    FileSystemResource resource = new FileSystemResource("build/data");
    resource.getFile().mkdirs();
    assertTrue(resource.getFile().isDirectory());
    tested.setResources(new Resource[] { resource });
    itemReader.setStrict(false);
    tested.open(new ExecutionContext());

    assertNull(tested.read());

    tested.close();
  }
View Full Code Here

  public void setUp() throws Exception {
    reader.setResource(resource);
    reader.setFragmentRootElementName("{urn:org.springframework.batch.io.oxm.domain}trade");
    reader.setUnmarshaller(getUnmarshaller());
    reader.afterPropertiesSet();
    reader.open(new ExecutionContext());
  }
View Full Code Here

  protected void pointToEmptyInput(ItemReader<Foo> tested) throws Exception {
    JpaPagingItemReader<Foo> reader = (JpaPagingItemReader<Foo>) tested;
    reader.close();
    reader.setQueryString("select f from Foo f where f.id = -1");
    reader.afterPropertiesSet();
    reader.open(new ExecutionContext());
  }
View Full Code Here

    ItemReader<Foo> reader = getItemReader();

    int total = JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS");

    ExecutionContext executionContext = new ExecutionContext();
    ((ItemStream) reader).open(executionContext);

    for (int i = 0; i < total; i++) {
      Foo item = reader.read();
      logger.debug("Item: " + item);
View Full Code Here

    int pagesToRead = Math.min(3, total/pageSize);
    if (count >= pagesToRead*pageSize) {
      count -= pagesToRead*pageSize;
    }

    ExecutionContext executionContext = new ExecutionContext();
    executionContext.putInt("JdbcPagingItemReader.read.count", count);
    // Assume the primary keys are in order

    List<Map<String, Object>> ids = jdbcTemplate
        .queryForList("SELECT ID,NAME FROM T_FOOS ORDER BY ID ASC");
    logger.debug("Ids: "+ids);
    int startAfterValue = (new Long(ids.get(count - 1).get("ID").toString())).intValue();
    logger.debug("Start after: " + startAfterValue);
    Map<String, Object> startAfterValues = new LinkedHashMap<String, Object>();
    startAfterValues.put("ID", startAfterValue);
    executionContext.put("JdbcPagingItemReader.start.after", startAfterValues);
    ((ItemStream) reader).open(executionContext);

    for (int i = count; i < total; i++) {
      Foo item = reader.read();
      logger.debug("Item: " + item);
View Full Code Here

  protected TradeItemReader provider;

  @Before
  public void setUp() throws Exception {
    provider = new TradeItemReader(resource);
    provider.open(new ExecutionContext());
  }
View Full Code Here

  @Override
  public Map<String, ExecutionContext> partition(int gridSize) {
    Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize);
    int i = 0;
    for (Resource resource : resources) {
      ExecutionContext context = new ExecutionContext();
      Assert.state(resource.exists(), "Resource does not exist: "+resource);
      try {
        context.putString(keyName, resource.getURL().toExternalForm());
      }
      catch (IOException e) {
        throw new IllegalArgumentException("File could not be located for: "+resource, e);
      }
      map.put(PARTITION_KEY + i, context);
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.