Results 1 to 3 of 3

Thread: Can't setup using AbstractTransactionalDataSourceSpringContextTests

  1. #1
    Join Date
    Aug 2004
    Posts
    230

    Default Can't setup using AbstractTransactionalDataSourceSpringContextTests

    I am using AbstractTransactionalDataSourceSpringContextTests (or a subclass) for most integration tests. However, some test methods need to use @NoTransaction. When this is the case, onSetUpBeforeTransaction() which is where we pull beans which cannot be injected by type from the context, resulting NPEs.

    Since onSetup is made final by AbstractTransactionalDataSourceSpringContextTests there seems to be no pre-test hook to use. This seems like an oversight in the test classes. I would think at least there should be an onSetup* that /always/ gets invoked -- transaction or not.
    Barry Kaplan (memelet)

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    What about onSetUpBeforeTransaction - the method will be called always. As the test is transactional - a tx will be called always - if you don't want/need transactions then use AbstractDependencyInjectionSpringContextTests.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2004
    Posts
    230

    Default

    Well, I have a test where some test methods should be run in a transactions and others not (@NotTransactional). Its the non-tx tests which are giving me trouble -- the onSetUpBeforeTransaction is /not/ invoked when @NotTransactional is specified, and there is no other setup hook available for these methods.

    From what I can see, I would need to split the test methods across two tests, one which is AbstractTransactional*Tests and one which is just AbstractDependency*Tests. But it would be nice to mix the methods in the same tests for clarity.
    Barry Kaplan (memelet)

Posting Permissions

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