Align TransactionManagementConfigurer support in TCF with production
This commit picks up where 613bd3be1d
left off by ensuring that a transaction manager configured via the
TransactionManagementConfigurer API takes precedence over any
transaction manager configured as a bean in the ApplicationContext
unless @Transactional is configured with a qualifier for the explicit
transaction manager to use in tests.
Closes gh-24869
This commit is contained in:
@@ -183,13 +183,6 @@ public abstract class TestContextTransactionUtils {
|
||||
if (bf instanceof ListableBeanFactory) {
|
||||
ListableBeanFactory lbf = (ListableBeanFactory) bf;
|
||||
|
||||
// Look up single bean by type
|
||||
Map<String, PlatformTransactionManager> txMgrs =
|
||||
BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, PlatformTransactionManager.class);
|
||||
if (txMgrs.size() == 1) {
|
||||
return txMgrs.values().iterator().next();
|
||||
}
|
||||
|
||||
// Look up single TransactionManagementConfigurer
|
||||
Map<String, TransactionManagementConfigurer> configurers =
|
||||
BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, TransactionManagementConfigurer.class);
|
||||
@@ -203,6 +196,13 @@ public abstract class TestContextTransactionUtils {
|
||||
return (PlatformTransactionManager) tm;
|
||||
}
|
||||
|
||||
// Look up single bean by type
|
||||
Map<String, PlatformTransactionManager> txMgrs =
|
||||
BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, PlatformTransactionManager.class);
|
||||
if (txMgrs.size() == 1) {
|
||||
return txMgrs.values().iterator().next();
|
||||
}
|
||||
|
||||
try {
|
||||
// Look up single bean by type, with support for 'primary' beans
|
||||
return bf.getBean(PlatformTransactionManager.class);
|
||||
|
||||
Reference in New Issue
Block a user