Announcement Announcement Module
Collapse
No announcement yet.
AbstractTransactionalDataSourceSpringContextTests onSetUp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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?

    Comment


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

      Juergen

      Comment


      • #4
        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

        Comment

        Working...
        X