Package org.springframework.transaction.jta

Examples of org.springframework.transaction.jta.JtaTransactionManager


    UserTransaction ut = (UserTransaction) utControl.getMock();
    ut.getStatus();
    utControl.setReturnValue(Status.STATUS_ACTIVE, 1);
    utControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    try {
      tt.execute(new TransactionCallbackWithoutResult() {
View Full Code Here


    ut.getStatus();
    utControl.setReturnValue(Status.STATUS_NO_TRANSACTION, 1);
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
View Full Code Here

    ut.getStatus();
    utControl.setThrowable(new SystemException("system exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
        }
View Full Code Here

    utControl.setVoidCallable(1);
    ut.commit();
    utControl.setVoidCallable(1);
    utControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        // something transactional
View Full Code Here

    ut.begin();
    utControl.setThrowable(new NotSupportedException("not supported"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
View Full Code Here

    ut.begin();
    utControl.setThrowable(new UnsupportedOperationException("not supported"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
View Full Code Here

    ut.begin();
    utControl.setThrowable(new SystemException("system exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
        }
View Full Code Here

    ut.commit();
    utControl.setThrowable(new RollbackException("unexpected rollback"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
View Full Code Here

      ut.commit();
    }
    utControl.setVoidCallable(1);
    utControl.replay();

    JtaTransactionManager tm = newJtaTransactionManager(ut);
    if (failEarly) {
      tm.setFailEarlyOnGlobalRollbackOnly(true);
    }

    TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition());
    boolean outerTransactionBoundaryReached = false;
    try {
      assertTrue("Is new transaction", ts.isNewTransaction());

      TransactionTemplate tt = new TransactionTemplate(tm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            public void afterCompletion(int status) {
              assertTrue("Correct completion status", status == TransactionSynchronization.STATUS_ROLLED_BACK);
            }
          });
        }
      });

      outerTransactionBoundaryReached = true;
      tm.commit(ts);

      fail("Should have thrown UnexpectedRollbackException");
    }
    catch (UnexpectedRollbackException ex) {
      // expected
      if (!outerTransactionBoundaryReached) {
        tm.rollback(ts);
      }
      if (failEarly) {
        assertFalse(outerTransactionBoundaryReached);
      }
      else {
View Full Code Here

    ut.commit();
    utControl.setThrowable(new HeuristicMixedException("heuristic exception"));
    utControl.replay();

    try {
      JtaTransactionManager ptm = newJtaTransactionManager(ut);
      TransactionTemplate tt = new TransactionTemplate(ptm);
      tt.execute(new TransactionCallbackWithoutResult() {
        protected void doInTransactionWithoutResult(TransactionStatus status) {
          // something transactional
          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
View Full Code Here

TOP

Related Classes of org.springframework.transaction.jta.JtaTransactionManager

Copyright © 2018 www.massapicom. 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.