use of org.springframework.transaction.interceptor.TransactionAttribute in project spring-framework by spring-projects.
the class AnnotationTransactionAttributeSourceTests method customMethodAttributeWithReadOnlyOverrideDetected.
@Test
public void customMethodAttributeWithReadOnlyOverrideDetected() throws Exception {
Method method = TestBean8.class.getMethod("getAge");
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
TransactionAttribute actual = atas.getTransactionAttribute(method, TestBean8.class);
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute();
rbta.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));
assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
assertTrue(actual.isReadOnly());
}
use of org.springframework.transaction.interceptor.TransactionAttribute in project spring-framework by spring-projects.
the class AnnotationTransactionAttributeSourceTests method transactionAttributeDeclaredOnClassWithEjb3.
@Test
public void transactionAttributeDeclaredOnClassWithEjb3() throws Exception {
Method getAgeMethod = ITestBean.class.getMethod("getAge");
Method getNameMethod = ITestBean.class.getMethod("getName");
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
TransactionAttribute getAgeAttr = atas.getTransactionAttribute(getAgeMethod, Ejb3AnnotatedBean2.class);
assertEquals(TransactionAttribute.PROPAGATION_REQUIRED, getAgeAttr.getPropagationBehavior());
TransactionAttribute getNameAttr = atas.getTransactionAttribute(getNameMethod, Ejb3AnnotatedBean2.class);
assertEquals(TransactionAttribute.PROPAGATION_SUPPORTS, getNameAttr.getPropagationBehavior());
}
use of org.springframework.transaction.interceptor.TransactionAttribute in project spring-framework by spring-projects.
the class AnnotationTransactionAttributeSourceTests method customMethodAttributeDetected.
@Test
public void customMethodAttributeDetected() throws Exception {
Method method = TestBean6.class.getMethod("getAge");
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
TransactionAttribute actual = atas.getTransactionAttribute(method, TestBean6.class);
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute();
rbta.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));
assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
}
use of org.springframework.transaction.interceptor.TransactionAttribute in project spring-framework by spring-projects.
the class AnnotationTransactionAttributeSourceTests method transactionAttributeDeclaredOnInterfaceWithJta.
@Test
public void transactionAttributeDeclaredOnInterfaceWithJta() throws Exception {
Method getAgeMethod = ITestEjb.class.getMethod("getAge");
Method getNameMethod = ITestEjb.class.getMethod("getName");
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
TransactionAttribute getAgeAttr = atas.getTransactionAttribute(getAgeMethod, JtaAnnotatedBean3.class);
assertEquals(TransactionAttribute.PROPAGATION_REQUIRED, getAgeAttr.getPropagationBehavior());
TransactionAttribute getNameAttr = atas.getTransactionAttribute(getNameMethod, JtaAnnotatedBean3.class);
assertEquals(TransactionAttribute.PROPAGATION_SUPPORTS, getNameAttr.getPropagationBehavior());
}
use of org.springframework.transaction.interceptor.TransactionAttribute in project spring-framework by spring-projects.
the class AnnotationTransactionAttributeSourceTests method defaultsToClassTransactionAttribute.
/**
* Test that transaction attribute is inherited from class
* if not specified on method.
*/
@Test
public void defaultsToClassTransactionAttribute() throws Exception {
Method method = TestBean4.class.getMethod("getAge");
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
TransactionAttribute actual = atas.getTransactionAttribute(method, TestBean4.class);
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute();
rbta.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));
assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
}
Aggregations