Package org.springframework.batch.item.sample

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


  @Test
  public void testRestart() throws Exception {

    testedAsStream().update(executionContext);

    Foo foo1 = tested.read();
    assertEquals(1, foo1.getValue());

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

    testedAsStream().update(executionContext);

    testedAsStream().close();

    // create new input source
    tested = getItemReader();

    testedAsStream().open(executionContext);

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


  @Test
  public void testResetAndRestart() throws Exception {

    testedAsStream().update(executionContext);

    Foo foo1 = tested.read();
    assertEquals(1, foo1.getValue());

    Foo foo2 = tested.read();
    assertEquals(2, foo2.getValue());
   
    testedAsStream().update(executionContext);
   
    Foo foo3 = tested.read();
    assertEquals(3, foo3.getValue());

    testedAsStream().close();

    // create new input source
    tested = getItemReader();

    testedAsStream().open(executionContext);

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

  @Test
  public void testReopen() throws Exception {
    testedAsStream().update(executionContext);

    Foo foo1 = tested.read();
    assertEquals(1, foo1.getValue());

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

    testedAsStream().update(executionContext);

    // create new input source
    testedAsStream().close();

    testedAsStream().open(executionContext);

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

   * Regular scenario - read the input and eventually return null.
   */
  @Test
  public void testRead() throws Exception {

    Foo foo1 = tested.read();
    assertEquals(1, foo1.getValue());

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

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

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

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

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

          attr = (Attribute) event.getAttributes().next();
        }
        catch  (Exception e) {
          throw new RuntimeException(e);
        }
        Foo foo = new Foo();
        foo.setValue(Integer.parseInt(attr.getValue()));
        return foo;
      }

            @Override
      public boolean supports(Class<?> clazz) {
View Full Code Here

    inputSource.setQueryProvider(queryProvider);
    inputSource.setRowMapper(
        new ParameterizedRowMapper<Foo>() {
                    @Override
          public Foo mapRow(ResultSet rs, int i) throws SQLException {
            Foo foo = new Foo();
            foo.setId(rs.getInt(1));
            foo.setName(rs.getString(2));
            foo.setValue(rs.getInt(3));
            return foo;
          }
        }
    );
    inputSource.setPageSize(3);
View Full Code Here

  @Test
  public void testRead() throws Exception {

    ((ItemStream)tested).open(executionContext);

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

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

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

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

    Object o = tested.read();
    Assert.assertNull(o);
  }
View Full Code Here

  public void testReadAfterJumpFirstPage() throws Exception {

    executionContext.putInt(getName()+".read.count", 2);
    ((ItemStream)tested).open(executionContext);

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

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

    Object o = tested.read();
    Assert.assertNull(o);
  }
View Full Code Here

  public void testReadAfterJumpSecondPage() throws Exception {

    executionContext.putInt(getName()+".read.count", 3);
    ((ItemStream)tested).open(executionContext);

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

    Object o = tested.read();
    Assert.assertNull(o);
  }
View Full Code Here

  public Foo getFoo(Object key){

    RowMapper<Foo> fooMapper = new 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;
      }
    };

    return getJdbcTemplate().query("SELECT ID, NAME, VALUE from T_FOOS where ID = ?",
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.