use of org.springframework.transaction.testfixture.CallCountingTransactionManager in project spring-framework by spring-projects.
the class EnableTransactionManagementTests method spr14322FindsOnInterfaceWithInterfaceProxy.
@Test
public void spr14322FindsOnInterfaceWithInterfaceProxy() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigA.class);
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
bean.saveFoo();
bean.saveBar();
assertThat(txManager.begun).isEqualTo(2);
assertThat(txManager.commits).isEqualTo(2);
assertThat(txManager.rollbacks).isEqualTo(0);
ctx.close();
}
use of org.springframework.transaction.testfixture.CallCountingTransactionManager in project spring-framework by spring-projects.
the class LookUpTxMgrViaTransactionManagementConfigurerWithSingleTxMgrBeanTests method transactionalTest.
@Test
void transactionalTest() {
assertThat(txManager.begun).isEqualTo(0);
assertThat(txManager.inflight).isEqualTo(0);
assertThat(txManager.commits).isEqualTo(0);
assertThat(txManager.rollbacks).isEqualTo(0);
CallCountingTransactionManager annotationDriven = config.annotationDriven;
assertThat(annotationDriven.begun).isEqualTo(1);
assertThat(annotationDriven.inflight).isEqualTo(1);
assertThat(annotationDriven.commits).isEqualTo(0);
assertThat(annotationDriven.rollbacks).isEqualTo(0);
}
use of org.springframework.transaction.testfixture.CallCountingTransactionManager in project spring-framework by spring-projects.
the class LookUpTxMgrViaTransactionManagementConfigurerWithSingleTxMgrBeanTests method afterTransaction.
@AfterTransaction
void afterTransaction() {
assertThat(txManager.begun).isEqualTo(0);
assertThat(txManager.inflight).isEqualTo(0);
assertThat(txManager.commits).isEqualTo(0);
assertThat(txManager.rollbacks).isEqualTo(0);
CallCountingTransactionManager annotationDriven = config.annotationDriven;
assertThat(annotationDriven.begun).isEqualTo(1);
assertThat(annotationDriven.inflight).isEqualTo(0);
assertThat(annotationDriven.commits).isEqualTo(0);
assertThat(annotationDriven.rollbacks).isEqualTo(1);
}
use of org.springframework.transaction.testfixture.CallCountingTransactionManager in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testCglibTransactionProxyImplementsNoInterfaces.
@Test
public void testCglibTransactionProxyImplementsNoInterfaces() {
ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces");
assertThat(AopUtils.isCglibProxy(ini)).as("testBean is CGLIB advised").isTrue();
boolean condition = ini instanceof TransactionalProxy;
assertThat(condition).isTrue();
String newName = "Gordon";
// Install facade
CallCountingTransactionManager ptm = new CallCountingTransactionManager();
PlatformTransactionManagerFacade.delegate = ptm;
ini.setName(newName);
assertThat(ini.getName()).isEqualTo(newName);
assertThat(ptm.commits).isEqualTo(2);
}
use of org.springframework.transaction.testfixture.CallCountingTransactionManager in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testDynamicTargetSource.
/**
* Test that we can set the target to a dynamic TargetSource.
*/
@Test
public void testDynamicTargetSource() {
// Install facade
CallCountingTransactionManager txMan = new CallCountingTransactionManager();
PlatformTransactionManagerFacade.delegate = txMan;
TestBean tb = (TestBean) factory.getBean("hotSwapped");
assertThat(tb.getAge()).isEqualTo(666);
int newAge = 557;
tb.setAge(newAge);
assertThat(tb.getAge()).isEqualTo(newAge);
TestBean target2 = new TestBean();
target2.setAge(65);
HotSwappableTargetSource ts = (HotSwappableTargetSource) factory.getBean("swapper");
ts.swap(target2);
assertThat(tb.getAge()).isEqualTo(target2.getAge());
tb.setAge(newAge);
assertThat(target2.getAge()).isEqualTo(newAge);
assertThat(txMan.inflight).isEqualTo(0);
assertThat(txMan.commits).isEqualTo(2);
assertThat(txMan.rollbacks).isEqualTo(0);
}
Aggregations