use of org.springframework.transaction.PlatformTransactionManager in project spring-framework by spring-projects.
the class TransactionInterceptorTests method determineTransactionManagerWithNoBeanFactory.
@Test
public void determineTransactionManagerWithNoBeanFactory() {
PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class);
TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, null);
assertThat(ti.determineTransactionManager(new DefaultTransactionAttribute())).isSameAs(transactionManager);
}
use of org.springframework.transaction.PlatformTransactionManager 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);
}
use of org.springframework.transaction.PlatformTransactionManager in project spring-framework by spring-projects.
the class TransactionInterceptorTests method associateTransactionManager.
private PlatformTransactionManager associateTransactionManager(BeanFactory beanFactory, String name) {
PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class);
given(beanFactory.containsBean(name)).willReturn(true);
given(beanFactory.getBean(name, TransactionManager.class)).willReturn(transactionManager);
return transactionManager;
}
use of org.springframework.transaction.PlatformTransactionManager in project spring-framework by spring-projects.
the class TransactionInterceptorTests method determineTransactionManagerWithEmptyQualifierAndDefaultName.
@Test
public void determineTransactionManagerWithEmptyQualifierAndDefaultName() {
BeanFactory beanFactory = mock(BeanFactory.class);
PlatformTransactionManager defaultTransactionManager = associateTransactionManager(beanFactory, "defaultTransactionManager");
TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName("defaultTransactionManager", beanFactory);
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
attribute.setQualifier("");
assertThat(ti.determineTransactionManager(attribute)).isSameAs(defaultTransactionManager);
}
use of org.springframework.transaction.PlatformTransactionManager in project spring-framework by spring-projects.
the class TransactionInterceptorTests method determineTransactionManagerWithNoBeanFactoryAndNoTransactionAttribute.
@Test
public void determineTransactionManagerWithNoBeanFactoryAndNoTransactionAttribute() {
PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class);
TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, null);
assertThat(ti.determineTransactionManager(null)).isSameAs(transactionManager);
}
Aggregations