use of cn.taketoday.beans.factory.BeanFactory in project today-framework by TAKETODAY.
the class TransactionInterceptorTests method determineTransactionManagerWithQualifierUnknown.
@Test
public void determineTransactionManagerWithQualifierUnknown() {
BeanFactory beanFactory = mock(BeanFactory.class);
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
attribute.setQualifier("fooTransactionManager");
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> ti.determineTransactionManager(attribute)).withMessageContaining("'fooTransactionManager'");
}
use of cn.taketoday.beans.factory.BeanFactory in project today-framework by TAKETODAY.
the class TransactionInterceptorTests method determineTransactionManagerWithQualifierAndDefaultName.
@Test
public void determineTransactionManagerWithQualifierAndDefaultName() {
BeanFactory beanFactory = mock(BeanFactory.class);
associateTransactionManager(beanFactory, "defaultTransactionManager");
TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName("defaultTransactionManager", beanFactory);
PlatformTransactionManager fooTransactionManager = associateTransactionManager(beanFactory, "fooTransactionManager");
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
attribute.setQualifier("fooTransactionManager");
assertThat(ti.determineTransactionManager(attribute)).isSameAs(fooTransactionManager);
}
use of cn.taketoday.beans.factory.BeanFactory in project today-framework by TAKETODAY.
the class TransactionInterceptorTests method determineTransactionManagerWithQualifierAndDefault.
@Test
public void determineTransactionManagerWithQualifierAndDefault() {
BeanFactory beanFactory = mock(BeanFactory.class);
PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class);
TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, beanFactory);
PlatformTransactionManager fooTransactionManager = associateTransactionManager(beanFactory, "fooTransactionManager");
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
attribute.setQualifier("fooTransactionManager");
assertThat(ti.determineTransactionManager(attribute)).isSameAs(fooTransactionManager);
}
use of cn.taketoday.beans.factory.BeanFactory in project today-framework by TAKETODAY.
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", PlatformTransactionManager.class);
}
use of cn.taketoday.beans.factory.BeanFactory in project today-framework by TAKETODAY.
the class TransactionInterceptorTests method determineTransactionManagerWithNoTransactionAttribute.
@Test
public void determineTransactionManagerWithNoTransactionAttribute() {
BeanFactory beanFactory = mock(BeanFactory.class);
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
assertThat(ti.determineTransactionManager(null)).isNull();
}
Aggregations