I have the following situation:
@Test
@Sql(scripts = "before.sql" , executionPhase = BEFORE_TEST_METHOD, config = @SqlConfig(transactionMode = ISOLATED))
@Sql(scripts = "cleanUp.sql", executionPhase = AFTER_TEST_METHOD , config = @SqlConfig(transactionMode = ISOLATED))
I need the test data to be committed before the test begin(it is obligatory to be committed), and after that to clean up that data.
The problem is, when AFTER_TEST_METHOD is executed it is suspending the current transaction in order to make a new one (because of ISOLATED), so if my mockMvc.perform(...) is locking the test data the test cannot finish because the isolated transaction is waiting for lock.
If I use INFERRED, the clean up is reusing the existing transaction which is roll-baked from the Spring transaction manager, so the committed data from BEFORE_TEST_METHOD stays.
Is there a some way to resolve this, some configuration that I'm missing ?
Thanks.
P.S I'm using testNG