Search in sources :

Example 41 with Transaction

use of javax.transaction.Transaction in project geode by apache.

the class TransactionManagerImpl method getGlobalTransaction.

/**
   * Get the Global Transaction associated with the calling thread
   */
GlobalTransaction getGlobalTransaction() throws SystemException {
    Transaction txn = getTransaction();
    if (txn == null) {
        return null;
    }
    GlobalTransaction gtx = (GlobalTransaction) globalTransactionMap.get(txn);
    return gtx;
}
Also used : Transaction(javax.transaction.Transaction)

Example 42 with Transaction

use of javax.transaction.Transaction in project geode by apache.

the class ExceptionJUnitTest method testAddNullTransaction.

@Test
public void testAddNullTransaction() throws Exception {
    try {
        utx.begin();
        GlobalTransaction gtx = tm.getGlobalTransaction();
        Transaction txn = null;
        gtx.addTransaction(txn);
        utx.commit();
        fail("SystemException not thrown on adding null transaction");
    } catch (SystemException e) {
        utx.commit();
    }
}
Also used : Transaction(javax.transaction.Transaction) UserTransaction(javax.transaction.UserTransaction) SystemException(javax.transaction.SystemException) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 43 with Transaction

use of javax.transaction.Transaction in project geode by apache.

the class GlobalTransactionJUnitTest method testSuspend.

@Test
public void testSuspend() throws Exception {
    utx.begin();
    tm.suspend();
    Transaction txn1 = tm.getTransaction();
    if (txn1 != null)
        fail("suspend failed to suspend the transaction");
}
Also used : Transaction(javax.transaction.Transaction) UserTransaction(javax.transaction.UserTransaction) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 44 with Transaction

use of javax.transaction.Transaction in project geode by apache.

the class GlobalTransactionJUnitTest method testSetRollbackOnly.

@Test
public void testSetRollbackOnly() throws Exception {
    utx.begin();
    utx.setRollbackOnly();
    Transaction txn = tm.getTransaction();
    if (txn.getStatus() != Status.STATUS_MARKED_ROLLBACK) {
        utx.rollback();
        fail("testSetRollbackonly failed");
    }
    utx.rollback();
}
Also used : Transaction(javax.transaction.Transaction) UserTransaction(javax.transaction.UserTransaction) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 45 with Transaction

use of javax.transaction.Transaction in project wildfly by wildfly.

the class StatelessBean method testTransaction.

public void testTransaction() throws RemoteException, SystemException {
    log.trace("Method stateless #testTransaction called");
    Transaction txn;
    txn = tm.getTransaction();
    TxTestUtil.enlistTestXAResource(txn, checker);
    TxTestUtil.enlistTestXAResource(txn, checker);
}
Also used : Transaction(javax.transaction.Transaction)

Aggregations

Transaction (javax.transaction.Transaction)160 SystemException (javax.transaction.SystemException)55 Test (org.junit.Test)42 RollbackException (javax.transaction.RollbackException)26 TransactionManager (javax.transaction.TransactionManager)24 UserTransaction (javax.transaction.UserTransaction)19 NotInTransactionException (org.neo4j.graphdb.NotInTransactionException)14 NotSupportedException (javax.transaction.NotSupportedException)13 Synchronization (javax.transaction.Synchronization)10 XAResource (javax.transaction.xa.XAResource)10 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)10 HazelcastXAResource (com.hazelcast.transaction.HazelcastXAResource)8 InvalidTransactionException (javax.transaction.InvalidTransactionException)7 TransactionContext (com.hazelcast.transaction.TransactionContext)6 RemoteException (java.rmi.RemoteException)6 ResourceException (javax.resource.ResourceException)6 ManagedConnection (javax.resource.spi.ManagedConnection)6 SQLException (java.sql.SQLException)5 HeuristicMixedException (javax.transaction.HeuristicMixedException)5 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)5