Search in sources :

Example 16 with TransactionInterceptor

use of org.springframework.transaction.interceptor.TransactionInterceptor in project spring-framework by spring-projects.

the class AnnotationTransactionInterceptorTests method withMonoSuccess.

@Test
public void withMonoSuccess() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithReactive());
    proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
    TestWithReactive proxy = (TestWithReactive) proxyFactory.getProxy();
    StepVerifier.withVirtualTime(proxy::monoSuccess).thenAwait(Duration.ofSeconds(10)).verifyComplete();
    assertReactiveGetTransactionAndCommitCount(1);
}
Also used : TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) ProxyFactory(org.springframework.aop.framework.ProxyFactory) Test(org.junit.jupiter.api.Test)

Example 17 with TransactionInterceptor

use of org.springframework.transaction.interceptor.TransactionInterceptor in project spring-framework by spring-projects.

the class AnnotationTransactionInterceptorTests method withFluxRollback.

@Test
public void withFluxRollback() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithReactive());
    proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
    TestWithReactive proxy = (TestWithReactive) proxyFactory.getProxy();
    StepVerifier.withVirtualTime(proxy::fluxSuccess).thenAwait(Duration.ofSeconds(1)).thenCancel().verify();
    assertReactiveGetTransactionAndRollbackCount(1);
}
Also used : TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) ProxyFactory(org.springframework.aop.framework.ProxyFactory) Test(org.junit.jupiter.api.Test)

Example 18 with TransactionInterceptor

use of org.springframework.transaction.interceptor.TransactionInterceptor in project spring-framework by spring-projects.

the class AnnotationTransactionInterceptorTests method withFluxSuccess.

@Test
public void withFluxSuccess() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithReactive());
    proxyFactory.addAdvice(new TransactionInterceptor(rtm, this.source));
    TestWithReactive proxy = (TestWithReactive) proxyFactory.getProxy();
    StepVerifier.withVirtualTime(proxy::fluxSuccess).thenAwait(Duration.ofSeconds(10)).expectNextCount(1).verifyComplete();
    assertReactiveGetTransactionAndCommitCount(1);
}
Also used : TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) ProxyFactory(org.springframework.aop.framework.ProxyFactory) Test(org.junit.jupiter.api.Test)

Example 19 with TransactionInterceptor

use of org.springframework.transaction.interceptor.TransactionInterceptor in project spring-framework by spring-projects.

the class ProxyTransactionManagementConfiguration method transactionInterceptor.

@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionInterceptor transactionInterceptor(TransactionAttributeSource transactionAttributeSource) {
    TransactionInterceptor interceptor = new TransactionInterceptor();
    interceptor.setTransactionAttributeSource(transactionAttributeSource);
    if (this.txManager != null) {
        interceptor.setTransactionManager(this.txManager);
    }
    return interceptor;
}
Also used : TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) Role(org.springframework.context.annotation.Role) Bean(org.springframework.context.annotation.Bean)

Aggregations

TransactionInterceptor (org.springframework.transaction.interceptor.TransactionInterceptor)19 Test (org.junit.jupiter.api.Test)8 ProxyFactory (org.springframework.aop.framework.ProxyFactory)7 Test (org.junit.Test)4 TransactionAttributeSource (org.springframework.transaction.interceptor.TransactionAttributeSource)4 TransactionInterceptorBuilder (org.springframework.integration.transaction.TransactionInterceptorBuilder)3 NameMatchTransactionAttributeSource (org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource)3 Advised (org.springframework.aop.framework.Advised)2 Bean (org.springframework.context.annotation.Bean)2 Role (org.springframework.context.annotation.Role)2 DelayHandler (org.springframework.integration.handler.DelayHandler)2 MatchAlwaysTransactionAttributeSource (org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Advice (org.aopalliance.aop.Advice)1 Advisor (org.springframework.aop.Advisor)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)1 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)1