use of cn.taketoday.aop.framework.ProxyFactory in project today-infrastructure by TAKETODAY.
the class ReactiveTransactionInterceptorTests method advised.
@Override
protected Object advised(Object target, ReactiveTransactionManager ptm, TransactionAttributeSource[] tas) {
TransactionInterceptor ti = new TransactionInterceptor();
ti.setTransactionManager(ptm);
ti.setTransactionAttributeSources(tas);
ProxyFactory pf = new ProxyFactory(target);
pf.addAdvice(0, ti);
return pf.getProxy();
}
use of cn.taketoday.aop.framework.ProxyFactory in project today-infrastructure by TAKETODAY.
the class AnnotationTransactionInterceptorTests method withMultiMethodOverride.
@Test
public void withMultiMethodOverride() {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithMultiMethodOverride());
proxyFactory.addAdvice(this.ti);
TestWithMultiMethodOverride proxy = (TestWithMultiMethodOverride) proxyFactory.getProxy();
proxy.doSomething();
assertGetTransactionAndCommitCount(1);
proxy.doSomethingElse();
assertGetTransactionAndCommitCount(2);
proxy.doSomethingCompletelyElse();
assertGetTransactionAndCommitCount(3);
proxy.doSomething();
assertGetTransactionAndCommitCount(4);
}
use of cn.taketoday.aop.framework.ProxyFactory in project today-infrastructure by TAKETODAY.
the class AnnotationTransactionInterceptorTests method withSingleMethodOverride.
@Test
public void withSingleMethodOverride() {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithSingleMethodOverride());
proxyFactory.addAdvice(this.ti);
TestWithSingleMethodOverride proxy = (TestWithSingleMethodOverride) proxyFactory.getProxy();
proxy.doSomething();
assertGetTransactionAndCommitCount(1);
proxy.doSomethingElse();
assertGetTransactionAndCommitCount(2);
proxy.doSomethingCompletelyElse();
assertGetTransactionAndCommitCount(3);
proxy.doSomething();
assertGetTransactionAndCommitCount(4);
}
use of cn.taketoday.aop.framework.ProxyFactory in project today-infrastructure by TAKETODAY.
the class AnnotationTransactionInterceptorTests method classLevelOnly.
@Test
public void classLevelOnly() {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestClassLevelOnly());
proxyFactory.addAdvice(this.ti);
TestClassLevelOnly proxy = (TestClassLevelOnly) proxyFactory.getProxy();
proxy.doSomething();
assertGetTransactionAndCommitCount(1);
proxy.doSomethingElse();
assertGetTransactionAndCommitCount(2);
proxy.doSomething();
assertGetTransactionAndCommitCount(3);
proxy.doSomethingElse();
assertGetTransactionAndCommitCount(4);
}
use of cn.taketoday.aop.framework.ProxyFactory in project today-infrastructure by TAKETODAY.
the class AnnotationTransactionInterceptorTests method withCommitOnCheckedException.
@Test
public void withCommitOnCheckedException() {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTarget(new TestWithExceptions());
proxyFactory.addAdvice(this.ti);
TestWithExceptions proxy = (TestWithExceptions) proxyFactory.getProxy();
assertThatExceptionOfType(Exception.class).isThrownBy(proxy::doSomethingElseWithCheckedException).satisfies(ex -> assertGetTransactionAndCommitCount(1));
}
Aggregations