Package org.springframework.batch.item

Examples of org.springframework.batch.item.ExecutionContext


      public Serializable checkpointInfo() throws Exception {
        return container;
      }
    });

    ExecutionContext context = new ExecutionContext();

    List<String> items = new ArrayList<String>();
    items.add("foo");
    items.add("bar");
    items.add("baz");
    adapter.open(context);
    adapter.write(items);
    adapter.update(context);
    adapter.write(items);
    adapter.close();

    CheckpointContainer container = (CheckpointContainer) context.get("ItemWriterAdapterTests.1.writer.checkpoint");
    assertEquals(3, container.getCount());

  }
View Full Code Here


  private void doTestItemStream(boolean expectOpen) throws Exception {
    @SuppressWarnings("unchecked")
    ItemStreamWriter<? super Object> writer = mock(ItemStreamWriter.class);
    List<Object> data = Collections.singletonList(new Object());
    ExecutionContext executionContext = new ExecutionContext();
    if (expectOpen) {
      writer.open(executionContext);
    }
    writer.write(data);
View Full Code Here

    writer.setLineSeparator("\n");
    writer.setLineAggregator(new PassThroughLineAggregator<String>());
    writer.afterPropertiesSet();
    writer.setSaveState(true);
    writer.setEncoding("UTF-8");
    executionContext = new ExecutionContext();
  }
View Full Code Here

  }

  @Test
  public void testRead() throws Exception {
    reader.setResource(new ClassPathResource(ClassUtils.addResourcePathToPackagePath(getClass(), "input.xml")));
    reader.open(new ExecutionContext());
    Trade result;
    List<Trade> results = new ArrayList<Trade>();
    while ((result = reader.read()) != null) {
      results.add(result);
    }
View Full Code Here

  @Test
  public void testReadNested() throws Exception {
    reader.setResource(new ClassPathResource(ClassUtils
        .addResourcePathToPackagePath(getClass(), "input-nested.xml")));
    reader.open(new ExecutionContext());
    Trade result;
    List<Trade> results = new ArrayList<Trade>();
    while ((result = reader.read()) != null) {
      results.add(result);
    }
View Full Code Here

    reader.setQueryString(hsqlQuery);
    reader.setSessionFactory(sessionFactory);
    reader.afterPropertiesSet();
    reader.setSaveState(true);
    reader.open(new ExecutionContext());

  }
View Full Code Here

    writer.setMarshaller(getMarshaller());
    writer.setRootTagName("{urn:org.springframework.batch.io.oxm.domain}trades");

    writer.afterPropertiesSet();

    writer.open(new ExecutionContext());

  }
View Full Code Here

    assertNull(reader.read());
  }

  @Test
  public void testReadAfterOpen() throws Exception {
    ExecutionContext executionContext = new ExecutionContext();
    executionContext.putInt(reader.getExecutionContextKey("COUNT"), 1);
    reader.open(executionContext);
    assertNotNull(reader.read());
    assertNull(reader.read());
  }
View Full Code Here

    assertNull(reader.read());
  }

  @Test
  public void testReadAndUpdate() throws Exception {
    ExecutionContext executionContext = new ExecutionContext();
    assertNotNull(reader.read());

    reader.update(executionContext);
    assertEquals(1, executionContext.getInt(reader.getExecutionContextKey("COUNT")));
  }
View Full Code Here

  protected abstract ItemReader<Foo> createItemReader() throws Exception;

  @Before
  public void onSetUpInTransaction() throws Exception {
    reader = createItemReader();
    executionContext = new ExecutionContext();
  }
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.