Search in sources :

Example 16 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class TransactionImpleUnitTest method testSynchronization.

@Test
public void testSynchronization() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    tx.registerSynchronization(new Synchronization());
    assertTrue(tx.getSynchronizations().size() == 1);
    tx.setRollbackOnly();
    try {
        tx.registerSynchronization(new Synchronization());
        fail();
    } catch (final RollbackException ex) {
    }
    tx.rollback();
}
Also used : TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Synchronization(com.hp.mwtests.ts.jta.jts.common.Synchronization) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 17 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class TransactionImpleUnitTest method test.

@Test
public void test() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    DummyXA res = new DummyXA(false);
    tx.enlistResource(res);
    tx.delistResource(res, XAResource.TMSUSPEND);
    assertTrue(tx.getResources() != null);
    assertTrue(tx.getTimeout() != -1);
    tx.commit();
    assertTrue(TransactionImple.getTransactions() != null);
    assertEquals(TransactionImple.getTransactions().size(), 0);
    try {
        tx = (TransactionImple) TransactionManager.transactionManager(new InitialContext());
        fail();
    } catch (final Throwable ex) {
    }
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 18 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testReadonly.

@Test
public void testReadonly() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(), new TestResource(true), new XidImple(new Uid()), params);
    try {
        xares.commit();
        fail();
    } catch (final NotPrepared ex) {
    }
    assertEquals(xares.prepare(), Vote.VoteReadOnly);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) TestResource(com.hp.mwtests.ts.jta.common.TestResource) NotPrepared(org.omg.CosTransactions.NotPrepared) Test(org.junit.Test)

Example 19 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testValid1PC.

@Test
public void testValid1PC() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    DummyXA res = new DummyXA(false);
    XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
    xares.commit_one_phase();
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 20 with TransactionImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testCommitFailure.

@Test
public void testCommitFailure() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    FailureXAResource fxa = new FailureXAResource(FailureXAResource.FailLocation.commit);
    TransactionImple tx = new TransactionImple();
    XAResourceRecord xares = new XAResourceRecord(tx, fxa, tx.getTxId(), null);
    assertEquals(xares.prepare(), Vote.VoteCommit);
    try {
        xares.commit();
        fail();
    } catch (final HeuristicMixed ex) {
    }
    xares.forget();
}
Also used : XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) FailureXAResource(com.hp.mwtests.ts.jta.common.FailureXAResource) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) Test(org.junit.Test)

Aggregations

TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)28 Test (org.junit.Test)23 DummyXA (com.hp.mwtests.ts.jta.jts.common.DummyXA)9 Uid (com.arjuna.ats.arjuna.common.Uid)7 XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)7 Transaction (javax.transaction.Transaction)5 XidImple (com.arjuna.ats.jta.xa.XidImple)4 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)4 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)3 FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)3 Synchronization (javax.transaction.Synchronization)3 SystemException (javax.transaction.SystemException)3 WorkSynchronization (com.arjuna.ats.internal.jta.transaction.jts.jca.WorkSynchronization)2 FailureXAResource (com.hp.mwtests.ts.jta.tools.FailureXAResource)2 RollbackException (javax.transaction.RollbackException)2 XAException (javax.transaction.xa.XAException)2 Xid (javax.transaction.xa.Xid)2 Control (org.omg.CosTransactions.Control)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1