|
|
|
@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.aop.framework.Advised; |
|
|
|
import org.springframework.aop.framework.Advised; |
|
|
|
import org.springframework.aop.framework.ProxyFactory; |
|
|
|
import org.springframework.aop.framework.ProxyFactory; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.BeanNameAware; |
|
|
|
import org.springframework.core.annotation.AliasFor; |
|
|
|
import org.springframework.core.annotation.AliasFor; |
|
|
|
import org.springframework.core.annotation.AnnotationUtils; |
|
|
|
import org.springframework.core.annotation.AnnotationUtils; |
|
|
|
import org.springframework.core.testfixture.io.SerializationTestUtils; |
|
|
|
import org.springframework.core.testfixture.io.SerializationTestUtils; |
|
|
|
@ -59,6 +60,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
|
|
|
|
|
|
|
|
private final AnnotationTransactionAttributeSource attributeSource = new AnnotationTransactionAttributeSource(); |
|
|
|
private final AnnotationTransactionAttributeSource attributeSource = new AnnotationTransactionAttributeSource(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void serializable() throws Exception { |
|
|
|
void serializable() throws Exception { |
|
|
|
TestBean1 tb = new TestBean1(); |
|
|
|
TestBean1 tb = new TestBean1(); |
|
|
|
@ -123,6 +125,10 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
void transactionAttributeDeclaredOnInterfaceMethodOnly() { |
|
|
|
void transactionAttributeDeclaredOnInterfaceMethodOnly() { |
|
|
|
TransactionAttribute actual = getTransactionAttribute(TestBean2.class, ITestBean2.class, "getAge"); |
|
|
|
TransactionAttribute actual = getTransactionAttribute(TestBean2.class, ITestBean2.class, "getAge"); |
|
|
|
assertThat(actual).satisfies(hasNoRollbackRule()); |
|
|
|
assertThat(actual).satisfies(hasNoRollbackRule()); |
|
|
|
|
|
|
|
actual = getTransactionAttribute(TestBean2.class, ITestBean2X.class, "getAge"); |
|
|
|
|
|
|
|
assertThat(actual).satisfies(hasNoRollbackRule()); |
|
|
|
|
|
|
|
actual = getTransactionAttribute(ITestBean2X.class, ITestBean2X.class, "getAge"); |
|
|
|
|
|
|
|
assertThat(actual).satisfies(hasNoRollbackRule()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -249,6 +255,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
assertThat(actual.isReadOnly()).isTrue(); |
|
|
|
assertThat(actual.isReadOnly()).isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nested |
|
|
|
@Nested |
|
|
|
class JtaAttributeTests { |
|
|
|
class JtaAttributeTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -276,6 +283,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
assertThat(getNameAttr.getPropagationBehavior()).isEqualTo(TransactionAttribute.PROPAGATION_SUPPORTS); |
|
|
|
assertThat(getNameAttr.getPropagationBehavior()).isEqualTo(TransactionAttribute.PROPAGATION_SUPPORTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class JtaAnnotatedBean1 implements ITestBean1 { |
|
|
|
static class JtaAnnotatedBean1 implements ITestBean1 { |
|
|
|
|
|
|
|
|
|
|
|
private String name; |
|
|
|
private String name; |
|
|
|
@ -305,7 +313,6 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@jakarta.transaction.Transactional(jakarta.transaction.Transactional.TxType.SUPPORTS) |
|
|
|
@jakarta.transaction.Transactional(jakarta.transaction.Transactional.TxType.SUPPORTS) |
|
|
|
static class JtaAnnotatedBean2 implements ITestBean1 { |
|
|
|
static class JtaAnnotatedBean2 implements ITestBean1 { |
|
|
|
|
|
|
|
|
|
|
|
@ -362,7 +369,6 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@jakarta.transaction.Transactional(jakarta.transaction.Transactional.TxType.SUPPORTS) |
|
|
|
@jakarta.transaction.Transactional(jakarta.transaction.Transactional.TxType.SUPPORTS) |
|
|
|
interface ITestJta { |
|
|
|
interface ITestJta { |
|
|
|
|
|
|
|
|
|
|
|
@ -375,9 +381,9 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
|
|
|
|
|
|
|
|
void setName(String name); |
|
|
|
void setName(String name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nested |
|
|
|
@Nested |
|
|
|
class Ejb3AttributeTests { |
|
|
|
class Ejb3AttributeTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -448,7 +454,6 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@jakarta.ejb.TransactionAttribute(TransactionAttributeType.SUPPORTS) |
|
|
|
@jakarta.ejb.TransactionAttribute(TransactionAttributeType.SUPPORTS) |
|
|
|
static class Ejb3AnnotatedBean2 implements ITestBean1 { |
|
|
|
static class Ejb3AnnotatedBean2 implements ITestBean1 { |
|
|
|
|
|
|
|
|
|
|
|
@ -506,6 +511,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nested |
|
|
|
@Nested |
|
|
|
class GroovyTests { |
|
|
|
class GroovyTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -519,6 +525,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
assertThat(attributeSource.getTransactionAttribute(getMetaClassMethod, GroovyTestBean.class)).isNull(); |
|
|
|
assertThat(attributeSource.getTransactionAttribute(getMetaClassMethod, GroovyTestBean.class)).isNull(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
static class GroovyTestBean implements ITestBean1, GroovyObject { |
|
|
|
static class GroovyTestBean implements ITestBean1, GroovyObject { |
|
|
|
|
|
|
|
|
|
|
|
@ -571,6 +578,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Consumer<TransactionAttribute> hasRollbackRules(RollbackRuleAttribute... rollbackRuleAttributes) { |
|
|
|
private Consumer<TransactionAttribute> hasRollbackRules(RollbackRuleAttribute... rollbackRuleAttributes) { |
|
|
|
return transactionAttribute -> { |
|
|
|
return transactionAttribute -> { |
|
|
|
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute(); |
|
|
|
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute(); |
|
|
|
@ -626,7 +634,12 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface ITestBean2X extends ITestBean2 { |
|
|
|
interface ITestBean2X extends ITestBean2, BeanNameAware { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
|
|
|
int getAge(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setAge(int age); |
|
|
|
|
|
|
|
|
|
|
|
String getName(); |
|
|
|
String getName(); |
|
|
|
|
|
|
|
|
|
|
|
@ -735,6 +748,10 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
this.age = age; |
|
|
|
this.age = age; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void setBeanName(String name) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getName() { |
|
|
|
public String getName() { |
|
|
|
return name; |
|
|
|
return name; |
|
|
|
@ -917,6 +934,7 @@ class AnnotationTransactionAttributeSourceTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(label = {"retryable", "long-running"}) |
|
|
|
@Transactional(label = {"retryable", "long-running"}) |
|
|
|
static class TestBean11 { |
|
|
|
static class TestBean11 { |
|
|
|
|
|
|
|
|
|
|
|
|