Package org.springframework.batch.item.sample

Examples of org.springframework.batch.item.sample.Foo


public class FooRowMapper implements RowMapper<Foo> {

        @Override
    public Foo mapRow(ResultSet rs, int rowNum) throws SQLException {

      Foo foo = new Foo();
      foo.setId(rs.getInt(1));
      foo.setName(rs.getString(2));
      foo.setValue(rs.getInt(3));
     
      return foo;
    }
View Full Code Here


  @Transactional @Test
  public void testNormalProcessing() throws Exception {
    getAsInitializingBean(reader).afterPropertiesSet();
    getAsItemStream(reader).open(executionContext);
   
    Foo foo1 = reader.read();
    assertEquals(1, foo1.getValue());

    Foo foo2 = reader.read();
    assertEquals(2, foo2.getValue());

    Foo foo3 = reader.read();
    assertEquals(3, foo3.getValue());

    Foo foo4 = reader.read();
    assertEquals(4, foo4.getValue());

    Foo foo5 = reader.read();
    assertEquals(5, foo5.getValue());

    assertNull(reader.read());
  }
View Full Code Here

  @Transactional @Test
  public void testRestart() throws Exception {

    getAsItemStream(reader).open(executionContext);
   
    Foo foo1 = reader.read();
    assertEquals(1, foo1.getValue());

    Foo foo2 = reader.read();
    assertEquals(2, foo2.getValue());

    getAsItemStream(reader).update(executionContext);
 
    getAsItemStream(reader).close();

    // create new input source
    reader = createItemReader();

    getAsItemStream(reader).open(executionContext);

    Foo fooAfterRestart = reader.read();
    assertEquals(3, fooAfterRestart.getValue());
  }
View Full Code Here

  @Transactional @Test
  public void testRestartOnSecondPage() throws Exception {

    getAsItemStream(reader).open(executionContext);
   
    Foo foo1 = reader.read();
    assertEquals(1, foo1.getValue());
    Foo foo2 = reader.read();
    assertEquals(2, foo2.getValue());
    Foo foo3 = reader.read();
    assertEquals(3, foo3.getValue());
    Foo foo4 = reader.read();
    assertEquals(4, foo4.getValue());

    getAsItemStream(reader).update(executionContext);
 
    getAsItemStream(reader).close();

    // create new input source
    reader = createItemReader();

    getAsItemStream(reader).open(executionContext);

    Foo foo5 = reader.read();
    assertEquals(5, foo5.getValue());

    assertNull(reader.read());
  }
View Full Code Here

  @Transactional @Test
  public void testInvalidRestore() throws Exception {

    getAsItemStream(reader).open(executionContext);
   
    Foo foo1 = reader.read();
    assertEquals(1, foo1.getValue());

    Foo foo2 = reader.read();
    assertEquals(2, foo2.getValue());

    getAsItemStream(reader).update(executionContext);
 
    getAsItemStream(reader).close();

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

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

    try {
      getAsItemStream(reader).open(executionContext);
      fail();
    }
View Full Code Here

   */
  @Transactional @Test
  public void testRestoreFromEmptyData() throws Exception {
    getAsItemStream(reader).open(executionContext);

    Foo foo = reader.read();
    assertEquals(1, foo.getValue());
  }
View Full Code Here

  @Transactional @Test
  public void testRollbackAndRestart() throws Exception {

    getAsItemStream(reader).open(executionContext);
   
    Foo foo1 = reader.read();

    getAsItemStream(reader).update(executionContext);

    Foo foo2 = reader.read();
    Assert.state(!foo2.equals(foo1));

    Foo foo3 = reader.read();
    Assert.state(!foo2.equals(foo3));
 
    getAsItemStream(reader).close();

    // create new input source
View Full Code Here

  @Transactional @Test
  public void testRollbackOnFirstChunkAndRestart() throws Exception {

    getAsItemStream(reader).open(executionContext);
   
    Foo foo1 = reader.read();

    Foo foo2 = reader.read();
    Assert.state(!foo2.equals(foo1));

    Foo foo3 = reader.read();
    Assert.state(!foo2.equals(foo3));
 
    getAsItemStream(reader).close();

    // create new input source
View Full Code Here

  public void testMultipleRestarts() throws Exception {
   
    getAsItemStream(reader).open(executionContext);
   

    Foo foo1 = reader.read();

    getAsItemStream(reader).update(executionContext);

    Foo foo2 = reader.read();
    Assert.state(!foo2.equals(foo1));

    Foo foo3 = reader.read();
    Assert.state(!foo2.equals(foo3));
 
    getAsItemStream(reader).close();

    // create new input source
    reader = createItemReader();

    getAsItemStream(reader).open(executionContext);

    assertEquals(foo2, reader.read());
    assertEquals(foo3, reader.read());
   
    getAsItemStream(reader).update(executionContext);
   
    getAsItemStream(reader).close();

    // create new input source
    reader = createItemReader();

    getAsItemStream(reader).open(executionContext);
   
    Foo foo4 = reader.read();
    Foo foo5 = reader.read();
    assertEquals(4, foo4.getValue());
    assertEquals(5, foo5.getValue());
  }
View Full Code Here

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

    for (int i = 0; i < total; i++) {
      Foo item = reader.read();
      logger.debug("Item: " + item);
      assertNotNull(item);
    }

    Foo item = reader.read();
    logger.debug("Item: " + item);
    assertNull(item);

  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.sample.Foo

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.