BATCH-863: renamed ResourceLineReader to FlatFileItemReader

This commit is contained in:
trisberg
2008-10-07 17:58:48 +00:00
parent 2040c31c6c
commit 9ec2a67a97
20 changed files with 91 additions and 91 deletions

View File

@@ -9,15 +9,15 @@ import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
/**
* Tests for {@link ResourceLineReader}.
* Tests for {@link FlatFileItemReader}.
*/
public class ResourceLineReaderCommonTests extends CommonItemStreamItemReaderTests{
public class FlatFileItemReaderCommonTests extends CommonItemStreamItemReaderTests{
private static final String FOOS = "1 \n 2 \n 3 \n 4 \n 5 \n";
@Override
protected ItemReader<Foo> getItemReader() throws Exception {
ResourceLineReader<Foo> tested = new ResourceLineReader<Foo>();
FlatFileItemReader<Foo> tested = new FlatFileItemReader<Foo>();
Resource resource = new ByteArrayResource(FOOS.getBytes());
tested.setResource(resource);
tested.setLineMapper(new LineMapper<Foo>() {
@@ -35,7 +35,7 @@ public class ResourceLineReaderCommonTests extends CommonItemStreamItemReaderTes
@Override
protected void pointToEmptyInput(ItemReader<Foo> tested) throws Exception {
ResourceLineReader<Foo> reader = (ResourceLineReader<Foo>) tested;
FlatFileItemReader<Foo> reader = (FlatFileItemReader<Foo>) tested;
reader.close(new ExecutionContext());
reader.setResource(new ByteArrayResource("".getBytes()));

View File

@@ -16,14 +16,14 @@ import org.springframework.core.io.Resource;
import org.springframework.util.ClassUtils;
/**
* Tests for {@link ResourceLineReader}.
* Tests for {@link FlatFileItemReader}.
*/
public class ResourceLineReaderTests {
public class FlatFileItemReaderTests {
// common value used for writing to a file
// common value used for writing to a file
private String TEST_STRING = "FlatFileInputTemplate-TestData";
private ResourceLineReader<String> reader = new ResourceLineReader<String>();
private FlatFileItemReader<String> reader = new FlatFileItemReader<String>();
private ExecutionContext executionContext = new ExecutionContext();
@@ -38,7 +38,7 @@ public class ResourceLineReaderTests {
public void testRestartWithCustomRecordSeparatorPolicy() throws Exception {
reader.setRecordSeparatorPolicy(new RecordSeparatorPolicy() {
// 1 record = 2 lines
// 1 record = 2 lines
boolean pair = true;
public boolean isEndOfRecord(String line) {
@@ -75,31 +75,31 @@ public class ResourceLineReaderTests {
reader.setLinesToSkip(2);
reader.open(executionContext);
// read some records
// read some records
reader.read();
reader.read();
// get restart data
// get restart data
reader.update(executionContext);
// read next two records
// read next two records
reader.read();
reader.read();
assertEquals(2, executionContext.getLong(ClassUtils.getShortName(ResourceLineReader.class) + ".read.count"));
// close input
assertEquals(2, executionContext.getLong(ClassUtils.getShortName(FlatFileItemReader.class) + ".read.count"));
// close input
reader.close(executionContext);
reader
.setResource(getInputResource("header\nignoreme\ntestLine1\ntestLine2\ntestLine3\ntestLine4\ntestLine5\ntestLine6"));
// init for restart
// init for restart
reader.open(executionContext);
// read remaining records
// read remaining records
assertEquals("testLine3", reader.read().toString());
assertEquals("testLine4", reader.read().toString());
reader.update(executionContext);
assertEquals(4, executionContext.getLong(ClassUtils.getShortName(ResourceLineReader.class) + ".read.count"));
assertEquals(4, executionContext.getLong(ClassUtils.getShortName(FlatFileItemReader.class) + ".read.count"));
}
@Test
@@ -110,7 +110,7 @@ public class ResourceLineReaderTests {
reader.setResource(resource);
// afterPropertiesSet should only throw an exception if the Resource is
// null
// null
reader.afterPropertiesSet();
reader.open(executionContext);
@@ -126,10 +126,10 @@ public class ResourceLineReaderTests {
reader.setResource(resource);
// afterPropertiesSet should only throw an exception if the Resource is
// null
// null
reader.afterPropertiesSet();
// replace the resource to simulate runtime resource creation
// replace the resource to simulate runtime resource creation
reader.setResource(getInputResource(TEST_STRING));
reader.open(executionContext);
assertEquals(TEST_STRING, reader.read());

View File

@@ -19,7 +19,7 @@ public class MultiResourceItemReaderFlatFileTests extends
protected ItemReader<Foo> getItemReader() throws Exception {
MultiResourceItemReader<Foo> multiReader = new MultiResourceItemReader<Foo>();
ResourceLineReader<Foo> fileReader = new ResourceLineReader<Foo>();
FlatFileItemReader<Foo> fileReader = new FlatFileItemReader<Foo>();
fileReader.setLineMapper(new LineMapper<Foo>() {

View File

@@ -16,7 +16,7 @@ public class MultiResourceItemReaderIntegrationTests extends TestCase {
private MultiResourceItemReader<String> tested = new MultiResourceItemReader<String>();
private ResourceLineReader<String> itemReader = new ResourceLineReader<String>();
private FlatFileItemReader<String> itemReader = new FlatFileItemReader<String>();
private ExecutionContext ctx = new ExecutionContext();

View File

@@ -22,7 +22,7 @@ import junit.framework.TestCase;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.file.ResourceLineReader;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.mapping.FieldSet;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
@@ -52,7 +52,7 @@ public abstract class AbstractTradeBatchTests extends TestCase {
provider.open(new ExecutionContext());
}
protected static class TradeItemReader extends ResourceLineReader<Trade> {
protected static class TradeItemReader extends FlatFileItemReader<Trade> {
protected TradeItemReader(Resource resource) throws Exception {
super();