Throw exception if TxMgr cannot be retrieved for @Transactional test
Prior to this commit, a @Transactional integration test would silently be executed without a transaction if the transaction manager could not be retrieved from the application context -- for example, it no such bean was defined or if multiple beans were present but none satisfied the qualifier. This commit addresses this issue by throwing an IllegalStateException if the PlatformTransactionManager cannot be retrieved for a @Transactional test. Issue: SPR-13895
This commit is contained in:
@@ -186,6 +186,12 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
|
||||
}
|
||||
|
||||
tm = getTransactionManager(testContext, transactionAttribute.getQualifier());
|
||||
|
||||
if (tm == null) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Failed to retrieve PlatformTransactionManager for @Transactional test for test context %s.",
|
||||
testContext));
|
||||
}
|
||||
}
|
||||
|
||||
if (tm != null) {
|
||||
|
||||
Reference in New Issue
Block a user