Search in sources :

Example 1 with InactiveTransactionException

use of com.arjuna.ats.jta.exceptions.InactiveTransactionException in project narayana by jbosstm.

the class ExceptionsUnitTest method test.

@Test
public void test() throws Exception {
    InactiveTransactionException ex = new InactiveTransactionException();
    ex = new InactiveTransactionException("foobar");
    NotImplementedException exp = new NotImplementedException();
    exp = new NotImplementedException("foobar");
    exp = new NotImplementedException("foobar", new NullPointerException());
    exp = new NotImplementedException(new NullPointerException());
    RollbackException exp2 = new RollbackException();
    exp2 = new RollbackException("foobar");
    exp2 = new RollbackException("foobar", new NullPointerException());
    exp2 = new RollbackException(new NullPointerException());
    UnexpectedConditionException ex2 = new UnexpectedConditionException();
    ex2 = new UnexpectedConditionException("foobar");
}
Also used : NotImplementedException(com.arjuna.ats.jta.exceptions.NotImplementedException) UnexpectedConditionException(com.arjuna.ats.jta.exceptions.UnexpectedConditionException) RollbackException(com.arjuna.ats.jta.exceptions.RollbackException) InactiveTransactionException(com.arjuna.ats.jta.exceptions.InactiveTransactionException) Test(org.junit.Test)

Example 2 with InactiveTransactionException

use of com.arjuna.ats.jta.exceptions.InactiveTransactionException in project narayana by jbosstm.

the class TransactionImpleUnitTest method test.

@Test
public void test() throws Exception {
    OTSImpleManager.current().begin();
    TransactionImple tx = new TransactionImple(new SubordinateAtomicTransaction(new ServerControlWrapper(OTSImpleManager.current().get_control())));
    assertFalse(tx.equals(null));
    assertTrue(tx.equals(tx));
    assertFalse(tx.equals(new TransactionImple(new AtomicTransaction())));
    assertFalse(tx.equals(new Object()));
    assertTrue(tx.toString() != null);
    try {
        tx.commit();
        fail();
    } catch (final InvalidTerminationStateException ex) {
    }
    try {
        tx.rollback();
        fail();
    } catch (final InvalidTerminationStateException ex) {
    }
    tx.doBeforeCompletion();
    tx.doPrepare();
    try {
        tx.doCommit();
        fail();
    } catch (final Throwable ex) {
    }
    try {
        tx.doRollback();
        fail();
    } catch (final Throwable ex) {
    }
    try {
        tx.doOnePhaseCommit();
        fail();
    } catch (final Throwable ex) {
    }
    tx.doForget();
    OTSImpleManager.current().rollback();
    DummyTransactionImple dummy = new DummyTransactionImple(new AtomicTransaction());
    try {
        dummy.commitAndDisassociate();
    } catch (final InactiveTransactionException ex) {
    }
    try {
        dummy.rollbackAndDisassociate();
    } catch (final InactiveTransactionException ex) {
    }
}
Also used : ServerControlWrapper(com.arjuna.ats.internal.jts.interposition.ServerControlWrapper) SubordinateAtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.subordinate.SubordinateAtomicTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.subordinate.TransactionImple) SubordinateAtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.subordinate.SubordinateAtomicTransaction) AtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.AtomicTransaction) InvalidTerminationStateException(com.arjuna.ats.jta.exceptions.InvalidTerminationStateException) InactiveTransactionException(com.arjuna.ats.jta.exceptions.InactiveTransactionException) Test(org.junit.Test)

Example 3 with InactiveTransactionException

use of com.arjuna.ats.jta.exceptions.InactiveTransactionException in project narayana by jbosstm.

the class TransactionImple method rollback.

public void rollback() throws java.lang.IllegalStateException, java.lang.SecurityException, javax.transaction.SystemException {
    if (jtaxLogger.logger.isTraceEnabled()) {
        jtaxLogger.logger.trace("TransactionImple.rollback");
    }
    boolean endSuspendedFailed = false;
    if (_theTransaction != null) {
        try {
            if ((getStatus() != Status.STATUS_ACTIVE) && (getStatus() != Status.STATUS_MARKED_ROLLBACK))
                throw new NoTransaction();
            /*
	                         * Call end on any suspended resources. If this fails, then there's
	                         * not a lot else we can do because the transaction is about to roll
	                         * back anyway!
	                         */
            endSuspendedFailed = !endSuspendedRMs();
            if (endSuspendedFailed) {
                jtaxLogger.i18NLogger.warn_jtax_transaction_jts_endsuspendfailed1();
            }
            _theTransaction.abort();
        } catch (WrongTransaction e1) {
            InactiveTransactionException inactiveTransactionException = new InactiveTransactionException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_wrongstatetx());
            inactiveTransactionException.initCause(e1);
            throw inactiveTransactionException;
        } catch (org.omg.CORBA.NO_PERMISSION e2) {
            throw new SecurityException(e2);
        } catch (INVALID_TRANSACTION e3) {
            InactiveTransactionException inactiveTransactionException = new InactiveTransactionException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_invalidtx2());
            inactiveTransactionException.initCause(e3);
            throw inactiveTransactionException;
        } catch (NoTransaction e4) {
            throw new IllegalStateException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_notx(), e4);
        } catch (org.omg.CORBA.SystemException e5) {
            javax.transaction.SystemException systemException = new javax.transaction.SystemException(e5.toString());
            systemException.initCause(e5);
            throw systemException;
        } finally {
            TransactionImple.removeTransaction(this);
        }
        if (endSuspendedFailed)
            throw new InvalidTerminationStateException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_endsuspendfailed2());
    } else
        throw new IllegalStateException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_inactivetx());
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) InvalidTerminationStateException(com.arjuna.ats.jta.exceptions.InvalidTerminationStateException) WrongTransaction(org.omg.CORBA.WrongTransaction) InactiveTransactionException(com.arjuna.ats.jta.exceptions.InactiveTransactionException)

Aggregations

InactiveTransactionException (com.arjuna.ats.jta.exceptions.InactiveTransactionException)3 InvalidTerminationStateException (com.arjuna.ats.jta.exceptions.InvalidTerminationStateException)2 Test (org.junit.Test)2 AtomicTransaction (com.arjuna.ats.internal.jta.transaction.jts.AtomicTransaction)1 SubordinateAtomicTransaction (com.arjuna.ats.internal.jta.transaction.jts.subordinate.SubordinateAtomicTransaction)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.subordinate.TransactionImple)1 ServerControlWrapper (com.arjuna.ats.internal.jts.interposition.ServerControlWrapper)1 NotImplementedException (com.arjuna.ats.jta.exceptions.NotImplementedException)1 RollbackException (com.arjuna.ats.jta.exceptions.RollbackException)1 UnexpectedConditionException (com.arjuna.ats.jta.exceptions.UnexpectedConditionException)1 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)1 WrongTransaction (org.omg.CORBA.WrongTransaction)1 NoTransaction (org.omg.CosTransactions.NoTransaction)1