use of org.springframework.transaction.TransactionManager in project spring-boot by spring-projects.
the class AbstractJpaAutoConfigurationTests method usesManuallyDefinedTransactionManagerBeanIfAvailable.
@Test
void usesManuallyDefinedTransactionManagerBeanIfAvailable() {
this.contextRunner.withUserConfiguration(TestConfigurationWithTransactionManager.class).run((context) -> {
assertThat(context).hasSingleBean(TransactionManager.class);
TransactionManager txManager = context.getBean(TransactionManager.class);
assertThat(txManager).isInstanceOf(CustomJpaTransactionManager.class);
});
}
use of org.springframework.transaction.TransactionManager in project spring-framework by spring-projects.
the class TransactionInterceptorTests method determineTransactionManagerWithQualifierSeveralTimes.
@Test
public void determineTransactionManagerWithQualifierSeveralTimes() {
BeanFactory beanFactory = mock(BeanFactory.class);
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
PlatformTransactionManager txManager = associateTransactionManager(beanFactory, "fooTransactionManager");
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
attribute.setQualifier("fooTransactionManager");
TransactionManager actual = ti.determineTransactionManager(attribute);
assertThat(actual).isSameAs(txManager);
// Call again, should be cached
TransactionManager actual2 = ti.determineTransactionManager(attribute);
assertThat(actual2).isSameAs(txManager);
verify(beanFactory, times(1)).containsBean("fooTransactionManager");
verify(beanFactory, times(1)).getBean("fooTransactionManager", TransactionManager.class);
}
use of org.springframework.transaction.TransactionManager in project spring-framework by spring-projects.
the class TransactionInterceptorTests method determineTransactionManagerWithBeanNameSeveralTimes.
@Test
public void determineTransactionManagerWithBeanNameSeveralTimes() {
BeanFactory beanFactory = mock(BeanFactory.class);
TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName("fooTransactionManager", beanFactory);
PlatformTransactionManager txManager = associateTransactionManager(beanFactory, "fooTransactionManager");
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
TransactionManager actual = ti.determineTransactionManager(attribute);
assertThat(actual).isSameAs(txManager);
// Call again, should be cached
TransactionManager actual2 = ti.determineTransactionManager(attribute);
assertThat(actual2).isSameAs(txManager);
verify(beanFactory, times(1)).getBean("fooTransactionManager", TransactionManager.class);
}
Aggregations