Examples of rollbackOn()


Examples of javax.transaction.Transactional.rollbackOn()

                    Transactional tx = method.getAnnotation(Transactional.class);
                    if (tx == null) {
                        tx = method.getDeclaringClass().getAnnotation(Transactional.class);
                    }
                    if (tx != null) { // TODO: find Bean instead of reflection
                        if (new ExceptionPriotiryRules(tx.rollbackOn(), tx.dontRollbackOn()).accept(error)) {
                            policy.setRollbackOnly();
                        }
                    }
                }
                policy.commit();
View Full Code Here

Examples of org.springframework.transaction.interceptor.RuleBasedTransactionAttribute.rollbackOn()

  public void testNonDefaultRollbackRules() throws Exception {
    TransactionAttributeEditor editor = new TransactionAttributeEditor();
    editor.setAsText("+RuntimeException,+SkippableException");
    RuleBasedTransactionAttribute attr = (RuleBasedTransactionAttribute) editor.getValue();
    attr.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
    assertTrue(attr.rollbackOn(new Exception("")));
    assertFalse(attr.rollbackOn(new RuntimeException("")));
    assertFalse(attr.rollbackOn(new SkippableException("")));
  }

  /**
 
View Full Code Here

Examples of org.springframework.transaction.interceptor.RuleBasedTransactionAttribute.rollbackOn()

    TransactionAttributeEditor editor = new TransactionAttributeEditor();
    editor.setAsText("+RuntimeException,+SkippableException");
    RuleBasedTransactionAttribute attr = (RuleBasedTransactionAttribute) editor.getValue();
    attr.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
    assertTrue(attr.rollbackOn(new Exception("")));
    assertFalse(attr.rollbackOn(new RuntimeException("")));
    assertFalse(attr.rollbackOn(new SkippableException("")));
  }

  /**
   * Scenario: Exception in reader that should not cause rollback
View Full Code Here

Examples of org.springframework.transaction.interceptor.RuleBasedTransactionAttribute.rollbackOn()

    editor.setAsText("+RuntimeException,+SkippableException");
    RuleBasedTransactionAttribute attr = (RuleBasedTransactionAttribute) editor.getValue();
    attr.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
    assertTrue(attr.rollbackOn(new Exception("")));
    assertFalse(attr.rollbackOn(new RuntimeException("")));
    assertFalse(attr.rollbackOn(new SkippableException("")));
  }

  /**
   * Scenario: Exception in reader that should not cause rollback
   */
 
View Full Code Here

Examples of org.springframework.transaction.interceptor.TransactionAttribute.rollbackOn()

    RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute();
    rbta.getRollbackRules().add(new RollbackRuleAttribute("java.lang.Exception"));
    rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));

    assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
    assertTrue(actual.rollbackOn(new Exception()));
    assertFalse(actual.rollbackOn(new IOException()));
   
    actual = atas.getTransactionAttribute(method, method.getDeclaringClass());

    rbta = new RuleBasedTransactionAttribute();
View Full Code Here

Examples of org.springframework.transaction.interceptor.TransactionAttribute.rollbackOn()

    rbta.getRollbackRules().add(new RollbackRuleAttribute("java.lang.Exception"));
    rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));

    assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
    assertTrue(actual.rollbackOn(new Exception()));
    assertFalse(actual.rollbackOn(new IOException()));
   
    actual = atas.getTransactionAttribute(method, method.getDeclaringClass());

    rbta = new RuleBasedTransactionAttribute();
    rbta.getRollbackRules().add(new RollbackRuleAttribute("java.lang.Exception"));
View Full Code Here

Examples of org.springframework.transaction.interceptor.TransactionAttribute.rollbackOn()

    rbta = new RuleBasedTransactionAttribute();
    rbta.getRollbackRules().add(new RollbackRuleAttribute("java.lang.Exception"));
    rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));
   
    assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
    assertTrue(actual.rollbackOn(new Exception()));
    assertFalse(actual.rollbackOn(new IOException()));
  }

  /**
   * Test that transaction attribute is inherited from class
View Full Code Here

Examples of org.springframework.transaction.interceptor.TransactionAttribute.rollbackOn()

    rbta.getRollbackRules().add(new RollbackRuleAttribute("java.lang.Exception"));
    rbta.getRollbackRules().add(new NoRollbackRuleAttribute(IOException.class));
   
    assertEquals(rbta.getRollbackRules(), ((RuleBasedTransactionAttribute) actual).getRollbackRules());
    assertTrue(actual.rollbackOn(new Exception()));
    assertFalse(actual.rollbackOn(new IOException()));
  }

  /**
   * Test that transaction attribute is inherited from class
   * if not specified on method.
View Full Code Here

Examples of org.springframework.transaction.interceptor.TransactionAttribute.rollbackOn()

 
  public void testRollbackRules() {
    TransactionInterceptor txInterceptor = (TransactionInterceptor) context.getBean("txRollbackAdvice");
    TransactionAttributeSource txAttrSource = txInterceptor.getTransactionAttributeSource();
    TransactionAttribute txAttr = txAttrSource.getTransactionAttribute(getAgeMethod,ITestBean.class);
    assertTrue("should be configured to rollback on Exception",txAttr.rollbackOn(new Exception()));
   
    txAttr = txAttrSource.getTransactionAttribute(setAgeMethod, ITestBean.class);
    assertFalse("should not rollback on RuntimeException",txAttr.rollbackOn(new RuntimeException()));
  }
View Full Code Here

Examples of org.springframework.transaction.interceptor.TransactionAttribute.rollbackOn()

    TransactionAttributeSource txAttrSource = txInterceptor.getTransactionAttributeSource();
    TransactionAttribute txAttr = txAttrSource.getTransactionAttribute(getAgeMethod,ITestBean.class);
    assertTrue("should be configured to rollback on Exception",txAttr.rollbackOn(new Exception()));
   
    txAttr = txAttrSource.getTransactionAttribute(setAgeMethod, ITestBean.class);
    assertFalse("should not rollback on RuntimeException",txAttr.rollbackOn(new RuntimeException()));
  }

  private ITestBean getTestBean() {
    return (ITestBean)context.getBean("testBean");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.