UNDER CONSTRUCTION
${renderedContent}
Quick Links to:
New CSF AbstractIntegrationTestBase.java unit test base class
This new CSF abstract class is to be used with all unit tests. It replaces the following deprecated classes
- BaseTransactionalIntegrationTest
- AbstractTransactionalDataSourceSpringContextTests
that were used in sais-common.
About the AbstractIntegrationTestBase base class
import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.transaction.annotation.Transactional; /** * @author sturner AbstractIntegrationTestBase * * Based on the old BaseTransactionalIntegrationTest class: refactored to move * away from deprecated Spring classes and to the newer Spring TestContext * Framework. * * NOTE - this is now an abstract class. This does not change the usage, as the * old version of the class was only ever used as a base class for JUnit * classes. * * The list of context config locations can be overriden by coding * @ContextConfiguration in a base class. * * The class is marked as @Transactional, which means test methods in derived * classes will be run in a transaction and will be automatically rolled back on * completion. If you do not want transactional behavior in a test method, * annotate the method with @NotTransactional. If you do not want the automatic * rollback, annotate the method with @Rollback(false). BUT - normally our * "integration" tests should use a transaction and do rollback, so the defaults * should always be what you want. */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:applicationContext-csf-unit-tests-default.xml"}) @TestExecutionListeners({TransactionalTestExecutionListener.class, DependencyInjectionTestExecutionListener.class}) @Transactional public abstract class AbstractIntegrationTestBase { public AbstractIntegrationTestBase() { super(); } }
Usage of the AbstractIntegrationTestBase base class
The following code fragment illustrates how to use AbstractIntegrationTestBase class
import edu.mit.csf.test.AbstractIntegrationTestBase; public class TestHibernateAcademicTermDao extends AbstractIntegrationTestBase { }