Aug 16th, 2005, 06:54 PM
I am writing a BaseDatabaseTestCase that extends AbstractTransactionalDataSourceSpringContextTests and I want a method that will populate the database outside of the transaction. I will only run the code the first time the method is run (using a static instance variable to track if it has been populated yet).
I see there is an onSetUpInTransaction(), but I need a way to call the method outside of the transaction. Where would be the best place to put that code?
Aug 17th, 2005, 04:01 PM
I've been going through the source of the AbstractTransactionalDataSourceSpringContextTests and its super classes. I need a point to insert a method that will be called before each test is run, but *not* in the transaction.
The only thing I can think of is to create a class that will populate the database, then put a reference to it in my context files so that it starts up when Spring loads all my beans. This class would be lazyInit="false" so that it loads (and populates the database) before any of my TestCases are executed.
Aug 17th, 2005, 04:10 PM
FYI, an "onSetUpBeforeTransaction" introduced in Spring 1.2.3. This seems to be exactly what you're looking for.
Aug 17th, 2005, 04:43 PM
I'm off to upgrade
Originally Posted by Juergen Hoeller