Today I wanted to unittest a method that uses multiple threads, each running within its own transaction (using the REQUIRES_NEW propagation). Such a test must have the following steps:
  1. Start a transaction
  2. Do the test setup
  3. Commit the transaction (otherwise the setup data are not visible to the method-under-test)
  4. Execute the method-under-test
  5. Perform the assertions
For this, Spring provides some helpful classes: