Package org.springframework.batch.item.sample

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


    reader.setQueryProvider(queryProvider);
    reader.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;
          }
        }
    );
    reader.setPageSize(3);
View Full Code Here


    Object[] args = keys.values().toArray();

    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 = ? and VALUE = ?",
View Full Code Here

    for (int i = 0; i < THREAD_COUNT; i++) {
      completionService.submit(new Callable<List<Foo>>() {
                @Override
        public List<Foo> call() throws Exception {
          List<Foo> list = new ArrayList<Foo>();
          Foo next = null;
          do {
            next = reader.read();
            Thread.sleep(10L);
            logger.debug("Reading item: " + next);
            if (next != null) {
View Full Code Here

    queryProvider.setSortKeys(sortKeys);
    reader.setQueryProvider(queryProvider);
    reader.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;
      }
    });
    reader.setPageSize(PAGE_SIZE);
    reader.afterPropertiesSet();
View Full Code Here

    for (int i = 0; i < THREAD_COUNT; i++) {
      completionService.submit(new Callable<List<Foo>>() {
        @Override
        public List<Foo> call() throws Exception {
          List<Foo> list = new ArrayList<Foo>();
          Foo next = null;
          do {
            next = reader.read();
            Thread.sleep(10L); // try to make it fairer
            logger.debug("Reading item: " + next);
            if (next != null) {
View Full Code Here

  /*
   * Regular usage scenario - input object should be passed to the service the injected invoker points to.
   */
  @Test
  public void testProcess() throws Exception {
    Foo foo;
    while ((foo = fooService.generateFoo()) != null) {
      processor.write(Collections.singletonList(foo));
    }

    List<Foo> input = fooService.getGeneratedFoos();
    List<Foo> processed = fooService.getProcessedFooNameValuePairs();
    assertEquals(input.size(), processed.size());
    assertFalse(fooService.getProcessedFooNameValuePairs().isEmpty());

    for (int i = 0; i < input.size(); i++) {
      Foo inputFoo = input.get(i);
      Foo outputFoo = processed.get(i);
      assertEquals(inputFoo.getName(), outputFoo.getName());
      assertEquals(inputFoo.getValue(), outputFoo.getValue());
      assertEquals(0, outputFoo.getId());
    }

  }
View Full Code Here

  @Autowired
  private ItemProcessorAdapter<Foo,String> processor;

  @Test
  public void testProcess() throws Exception {
    Foo item = new Foo(0,"foo",1);
    assertEquals("foo", processor.process(item));
  }
View Full Code Here

  /*
   * Regular usage scenario - input object should be passed to the service the injected invoker points to.
   */
  @Test
  public void testProcess() throws Exception {
    Foo foo;
    List<Foo> foos = new ArrayList<Foo>();
    while ((foo = fooService.generateFoo()) != null) {
      foos.add(foo);
    }
    processor.write(foos);
View Full Code Here

    Resource resource = new ByteArrayResource(FOOS.getBytes());
    tested.setResource(resource);
    tested.setLineMapper(new LineMapper<Foo>() {
            @Override
      public Foo mapLine(String line, int lineNumber) {
        Foo foo = new Foo();
        foo.setValue(Integer.valueOf(line.trim()));
        return foo;
      }
    });
   
    tested.setSaveState(true);
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

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.