From ddac3e8e5e0b53acd678d2a7a491cf55254baae1 Mon Sep 17 00:00:00 2001 From: dsyer Date: Thu, 17 Jan 2008 13:13:06 +0000 Subject: [PATCH] RESOLVED - issue BATCH-296: rollback of first chunk fails http://jira.springframework.org/browse/BATCH-296 Added additional test, but the bug was already fixed in m3. --- .../file/DefaultFlatFileItemReaderTests.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/DefaultFlatFileItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/DefaultFlatFileItemReaderTests.java index b29c357e9..49b498752 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/DefaultFlatFileItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/file/DefaultFlatFileItemReaderTests.java @@ -118,6 +118,34 @@ public class DefaultFlatFileItemReaderTests extends TestCase { // statistics.get(FlatFileInputTemplate.SKIPPED_STATISTICS_NAME)); } + + /** + * Test skip and skipRollback functionality + * @throws IOException + */ + public void testSkipFirstChunk() throws Exception { + + inputSource.close(); + inputSource.setResource(getInputResource("testLine1\ntestLine2\ntestLine3\ntestLine4\ntestLine5\ntestLine6")); + inputSource.open(); + + // read some records + inputSource.read(); // #1 + inputSource.read(); // #2 + inputSource.read(); // #3 + // mark record as skipped + inputSource.skip(); + // rollback + inputSource.getTransactionSynchronization().afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); + // read next record + inputSource.read(); // should be #1 + + // we should now process all records after first commit point, that are + // not marked as skipped + assertEquals("[testLine2]", inputSource.read().toString()); + + } + /** * Test skip and skipRollback functionality