diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java index c9ec45253..4123d999d 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java @@ -15,8 +15,18 @@ */ package org.springframework.batch.item.file; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; + import org.junit.Before; import org.junit.Test; + import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemCountAware; import org.springframework.batch.item.ItemStreamException; @@ -29,15 +39,6 @@ import org.springframework.core.io.Resource; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; -import java.io.IOException; -import java.io.InputStream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * Tests for {@link FlatFileItemReader}. */ @@ -52,13 +53,17 @@ public class FlatFileItemReaderTests { private ExecutionContext executionContext = new ExecutionContext(); + private Resource inputResource2 = getInputResource("testLine1\ntestLine2\ntestLine3\ntestLine4\ntestLine5\ntestLine6"); + + private Resource inputResource1 = getInputResource("testLine1\ntestLine2\ntestLine3\ntestLine4\ntestLine5\ntestLine6"); + @Before public void setUp() { - reader.setResource(getInputResource("testLine1\ntestLine2\ntestLine3\ntestLine4\ntestLine5\ntestLine6")); + reader.setResource(inputResource1); reader.setLineMapper(new PassThroughLineMapper()); - itemReader.setResource(getInputResource("testLine1\ntestLine2\ntestLine3\ntestLine4\ntestLine5\ntestLine6")); + itemReader.setResource(inputResource2); itemReader.setLineMapper(new ItemLineMapper()); } @@ -445,7 +450,7 @@ public class FlatFileItemReaderTests { assertEquals(2, expected.getLineNumber()); assertEquals("testLine2", expected.getInput()); assertEquals("Couldn't map line 2", expected.getCause().getMessage()); - assertEquals("Parsing error at line: 2 in resource=[resource loaded from byte array], input=[testLine2]", expected.getMessage()); + assertEquals(String.format("Parsing error at line: 2 in resource=[%s], input=[testLine2]", inputResource1.toString()), expected.getMessage()); } }