- Start a transaction
- Do the test setup
- Commit the transaction (otherwise the setup data are not visible to the method-under-test)
- Execute the method-under-test
- Perform the assertions
- My test is a subclass of AbstractTestNGSpringContextTests (instead of AbstractTransactionalTestNGSpringContextTests)
- The testclass autowires a TransactionTemplate, which is defined in the context XML:
<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="jtaTransactionManager"/>
</bean> - The test setup uses the TransactionTemplate to execute a TransactionCallback (or TransactionCallbackWithoutResult)