David, If you are using Spring to wire up your iBatis configuration, there is an abstract Spring class for performing DAO tests that encapsulates transaction management around each test. You can perform the necessary iBatis calls, and Spring will rollback all of the test changes.
If you require more details on this class, see the Spring API Javadocs (http://static.springsource.org/spring/docs/2.5.x/api/index.html) Here is an example base class I use for all of my DAO tests. Simply subclass this for each test class, ensuring that if you override the onSetUp() or onTearDown() methods (instead of the jUnit setUp() or tearDown() superclass methods), you also invoke the super.onSetUp() or super.onTearDown() methods from within. I use a separate applicationContext file for these testsm as noted below. Hope this helps, -Kevin ------- Code Sample -------- import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTes ts; /** * Abstract base class for DAO tests that require rollback functionality when testing * CRUD operations. * @author Kevin.Burke * */ public abstract class AbstractBaseDaoTestCase extends AbstractTransactionalDataSourceSpringContextTests { protected Log log = LogFactory.getLog( this.getClass() ); public AbstractBaseDaoTestCase() { super(); } protected String[] getConfigLocations() { String[] paths = new String[] { "classpath:applicationContext-db-test.xml" }; return paths; } public Object getBean( String beanName ) { return getApplicationContext().getBean( beanName ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org