diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java index c0f1f8214..88277ec40 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java @@ -1,11 +1,16 @@ package org.springframework.batch.item.database; +import static org.junit.Assert.assertEquals; + import javax.sql.DataSource; import org.springframework.batch.item.AbstractItemStreamItemReaderTests; +import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.sample.Foo; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.junit.Before; import org.junit.After; +import org.junit.Test; public abstract class AbstractDatabaseItemStreamItemReaderTests extends AbstractItemStreamItemReaderTests { @@ -23,6 +28,18 @@ public abstract class AbstractDatabaseItemStreamItemReaderTests extends Abstract ctx.close(); } + @Test + public void testReadToExhaustion() throws Exception { + ItemReader reader = getItemReader(); + pointToEmptyInput(reader); + int count = 0; + Foo item = new Foo(); + while (count++<100 && item!=null) { + item = reader.read(); + } + assertEquals(2, count); + } + protected DataSource getDataSource() { return (DataSource) ctx.getBean("dataSource"); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java index 5d1d36fa2..1eff93894 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java @@ -1,18 +1,19 @@ package org.springframework.batch.item.database; -import org.junit.runner.RunWith; import org.junit.internal.runners.JUnit4ClassRunner; -import org.springframework.batch.item.sample.Foo; -import org.springframework.batch.item.ItemReader; +import org.junit.runner.RunWith; import org.springframework.batch.item.ExecutionContext; -import org.springframework.orm.ibatis.SqlMapClientFactoryBean; +import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.sample.Foo; import org.springframework.core.io.ClassPathResource; +import org.springframework.orm.ibatis.SqlMapClientFactoryBean; + import com.ibatis.sqlmap.client.SqlMapClient; @SuppressWarnings("unchecked") @RunWith(JUnit4ClassRunner.class) public class IbatisPagingItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { - + protected ItemReader getItemReader() throws Exception { SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean(); factory.setConfigLocation(new ClassPathResource("ibatis-config.xml", getClass()));