Results 1 to 4 of 4

Thread: AbstractTransactionalDataSourceSpringContextTests onSetUp

  1. #1
    Join Date
    Jul 2005
    Posts
    12

    Default AbstractTransactionalDataSourceSpringContextTests onSetUp

    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?

    Michael.[/code]

  2. #2
    Join Date
    Jul 2005
    Posts
    12

    Default

    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.

    Opinions?

  3. #3
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    FYI, an "onSetUpBeforeTransaction" introduced in Spring 1.2.3. This seems to be exactly what you're looking for.

    Juergen

  4. #4
    Join Date
    Jul 2005
    Posts
    12

    Default

    Quote Originally Posted by Juergen Hoeller
    FYI, an "onSetUpBeforeTransaction" introduced in Spring 1.2.3. This seems to be exactly what you're looking for.

    Juergen
    I'm off to upgrade

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •