org.springframework.batch.item.database
Class AbstractDataSourceItemReaderIntegrationTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.ConditionalTestCase
              extended by org.springframework.test.AbstractSpringContextTests
                  extended by org.springframework.test.AbstractSingleSpringContextTests
                      extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                          extended by org.springframework.test.AbstractTransactionalSpringContextTests
                              extended by org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
                                  extended by org.springframework.batch.item.database.AbstractDataSourceItemReaderIntegrationTests
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
HibernateCursorItemReaderIntegrationTests, IbatisItemReaderIntegrationTests, JdbcCursorItemReaderIntegrationTests

public abstract class AbstractDataSourceItemReaderIntegrationTests
extends AbstractTransactionalDataSourceSpringContextTests

Common scenarios for testing ItemReader implementations which read data from database.

Author:
Lucas Ward, Robert Kasanicky

Field Summary
protected  ExecutionContext executionContext
           
protected  ItemReader reader
           
 
Fields inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
jdbcTemplate
 
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
transactionDefinition, transactionManager, transactionStatus
 
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO
 
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests
applicationContext
 
Fields inherited from class org.springframework.test.ConditionalTestCase
logger
 
Constructor Summary
AbstractDataSourceItemReaderIntegrationTests()
           
 
Method Summary
protected abstract  ItemReader createItemReader()
           
protected  String[] getConfigLocations()
           
protected  void onSetUpInTransaction()
           
protected  void onTearDownAfterTransaction()
           
 void testInvalidRestore()
          Reading from an input source and then trying to restore causes an error.
 void testMultipleRestarts()
           
 void testNormalProcessing()
          Regular scenario - read all rows and eventually return null.
 void testRestart()
          Restart scenario - read records, save restart data, create new input source and restore from restart data - the new input source should continue where the old one finished.
 void testRestoreFromEmptyData()
          Empty restart data should be handled gracefully.
 void testRollback()
          Rollback scenario - input source rollbacks to last commit point.
 void testRollbackAndRestart()
          Rollback scenario with restart - input source rollbacks to last commit point.
 void testRollbackOnFirstChunkAndRestart()
          Rollback scenario with restart - input source rollbacks to last commit point.
 
Methods inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
countRowsInTable, deleteFromTables, executeSqlScript, getJdbcTemplate, setComplete, setDataSource, setSqlScriptEncoding
 
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
endTransaction, isDefaultRollback, isRollback, onSetUp, onSetUpBeforeTransaction, onTearDown, onTearDownInTransaction, preventTransaction, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables
 
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, prepareApplicationContext, setDirty, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
addContext, contextKeyString, getContext, hasCachedContext, isContextKeyEmpty, setDirty
 
Methods inherited from class org.springframework.test.ConditionalTestCase
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled, runBare
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reader

protected ItemReader reader

executionContext

protected ExecutionContext executionContext
Constructor Detail

AbstractDataSourceItemReaderIntegrationTests

public AbstractDataSourceItemReaderIntegrationTests()
Method Detail

createItemReader

protected abstract ItemReader createItemReader()
                                        throws Exception
Returns:
configured input source ready for use
Throws:
Exception

getConfigLocations

protected String[] getConfigLocations()
Overrides:
getConfigLocations in class AbstractSingleSpringContextTests

onSetUpInTransaction

protected void onSetUpInTransaction()
                             throws Exception
Overrides:
onSetUpInTransaction in class AbstractTransactionalSpringContextTests
Throws:
Exception

onTearDownAfterTransaction

protected void onTearDownAfterTransaction()
                                   throws Exception
Overrides:
onTearDownAfterTransaction in class AbstractTransactionalSpringContextTests
Throws:
Exception

testNormalProcessing

public void testNormalProcessing()
                          throws Exception
Regular scenario - read all rows and eventually return null.

Throws:
Exception

testRestart

public void testRestart()
                 throws Exception
Restart scenario - read records, save restart data, create new input source and restore from restart data - the new input source should continue where the old one finished.

Throws:
Exception

testInvalidRestore

public void testInvalidRestore()
                        throws Exception
Reading from an input source and then trying to restore causes an error.

Throws:
Exception

testRestoreFromEmptyData

public void testRestoreFromEmptyData()
                              throws Exception
Empty restart data should be handled gracefully.

Throws:
Exception

testRollback

public void testRollback()
                  throws Exception
Rollback scenario - input source rollbacks to last commit point.

Throws:
Exception

testRollbackAndRestart

public void testRollbackAndRestart()
                            throws Exception
Rollback scenario with restart - input source rollbacks to last commit point.

Throws:
Exception

testRollbackOnFirstChunkAndRestart

public void testRollbackOnFirstChunkAndRestart()
                                        throws Exception
Rollback scenario with restart - input source rollbacks to last commit point.

Throws:
Exception

testMultipleRestarts

public void testMultipleRestarts()
                          throws Exception
Throws:
Exception


Copyright © 2008 SpringSource. All Rights Reserved.