OPEN - issue BATCH-385: Merge user attributes in StepContext with ExecutionContext

http://jira.springframework.org/browse/BATCH-385

removed delegate calls to ItemStream in favour of direct registration
This commit is contained in:
dsyer
2008-02-29 13:04:18 +00:00
parent 8326d88cda
commit a1daad39f8
14 changed files with 287 additions and 311 deletions

View File

@@ -16,15 +16,12 @@
package org.springframework.batch.item.reader;
import java.util.Properties;
import junit.framework.TestCase;
import org.springframework.batch.io.Skippable;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.support.PropertiesConverter;
/**
* Unit test for {@link DelegatingItemReader}
@@ -72,14 +69,6 @@ public class DelegatingItemReaderTests extends TestCase {
assertSame("domain object is provided by the input template", this, result);
}
/**
* Gets restart data from the input template
*/
public void testGetStreamContext() {
itemProvider.update(executionContext);
assertEquals("foo", executionContext.getString("value"));
}
public void testSkip() throws Exception {
itemProvider.skip();
assertEquals("after skip", itemProvider.read());
@@ -89,10 +78,6 @@ public class DelegatingItemReaderTests extends TestCase {
private Object value;
public Properties getStatistics() {
return PropertiesConverter.stringToProperties("a=b");
}
public void update(ExecutionContext executionContext) {
executionContext.putString("value", "foo");
}

View File

@@ -22,7 +22,6 @@ import org.springframework.batch.io.file.FlatFileItemReader;
import org.springframework.batch.io.file.mapping.FieldSet;
import org.springframework.batch.io.file.mapping.FieldSetMapper;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.reader.DelegatingItemReader;
import org.springframework.batch.item.writer.AbstractItemWriter;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@@ -49,20 +48,15 @@ public abstract class AbstractTradeBatchTests extends TestCase {
provider.open(new ExecutionContext());
}
protected static class TradeItemReader extends DelegatingItemReader {
protected static class TradeItemReader extends FlatFileItemReader {
protected TradeItemReader(Resource resource) throws Exception {
super();
FlatFileItemReader inputSource = new FlatFileItemReader();
inputSource.setResource(resource);
inputSource.setFieldSetMapper(new TradeMapper());
inputSource.afterPropertiesSet();
setItemReader(inputSource);
setResource(resource);
setFieldSetMapper(new TradeMapper());
afterPropertiesSet();
}
public synchronized Object read() throws Exception {
return super.read();
}
}
protected static class TradeMapper implements FieldSetMapper{