Search in sources :

Example 1 with DummyXA

use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.

the class TransactionImpleUnitTest method testEnlist.

@Test
public void testEnlist() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    tx.setRollbackOnly();
    try {
        tx.enlistResource(null);
        fail();
    } catch (final SystemException ex) {
    }
    try {
        tx.enlistResource(new DummyXA(false));
        fail();
    } catch (final RollbackException ex) {
    }
    try {
        tx.commit();
        fail();
    } catch (final RollbackException ex) {
    }
    try {
        tx.enlistResource(new DummyXA(false));
        fail();
    } catch (final IllegalStateException ex) {
    }
    Control suspend = OTSImpleManager.current().suspend();
    tx = new TransactionImple();
    DummyXA res = new DummyXA(false);
    tx.enlistResource(res);
    tx.delistResource(res, XAResource.TMSUSPEND);
    tx.enlistResource(res);
    tx.commit();
}
Also used : Control(org.omg.CosTransactions.Control) DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) SystemException(javax.transaction.SystemException) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 2 with DummyXA

use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.

the class TransactionImpleUnitTest method testDelist.

@Test
public void testDelist() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    TransactionImple tx = new TransactionImple();
    try {
        tx.delistResource(null, XAResource.TMSUCCESS);
        fail();
    } catch (final SystemException ex) {
    }
    DummyXA xares = new DummyXA(false);
    try {
        assertFalse(tx.delistResource(xares, XAResource.TMSUCCESS));
    } catch (final Throwable ex) {
        fail();
    }
    tx.enlistResource(xares);
    assertTrue(tx.delistResource(xares, XAResource.TMSUCCESS));
    tx.commit();
    try {
        tx.delistResource(xares, XAResource.TMSUCCESS);
        fail();
    } catch (final IllegalStateException ex) {
    }
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) SystemException(javax.transaction.SystemException) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 3 with DummyXA

use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testRecovery.

@Test
public void testRecovery() throws Exception {
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    DummyXAResourceRecord xares = new DummyXAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
    assertEquals(xares.getRecoveryCoordinator(), null);
    assertEquals(xares.recover(), XARecoveryResource.FAILED_TO_RECOVER);
    xares.setXAResource(null);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 4 with DummyXA

use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testPackUnpack.

@Test
public void testPackUnpack() 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 DummyXA(false), new XidImple(new Uid()), params);
    OutputObjectState os = new OutputObjectState();
    assertTrue(xares.saveState(os));
    xares = new XAResourceRecord();
    InputObjectState is = new InputObjectState(os);
    assertTrue(xares.restoreState(is));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) 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) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 5 with DummyXA

use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.

the class XAResourceRecordUnitTest method test.

@Test
public void test() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares = new XAResourceRecord();
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
    xares.merge(null);
    xares.alter(null);
    assertTrue(xares.type() != null);
    assertTrue(xares.toString() != null);
    assertTrue(xares.get_uid().notEquals(Uid.nullUid()));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) 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)

Aggregations

DummyXA (com.hp.mwtests.ts.jta.jts.common.DummyXA)12 Test (org.junit.Test)12 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)9 Uid (com.arjuna.ats.arjuna.common.Uid)5 XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)4 XidImple (com.arjuna.ats.jta.xa.XidImple)3 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)3 SystemException (javax.transaction.SystemException)2 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)1 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule)1 XARecoveryResourceImple (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryResourceImple)1 XARecoveryResourceManagerImple (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryResourceManagerImple)1 LastResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.LastResourceRecord)1 InitialContext (javax.naming.InitialContext)1 RollbackException (javax.transaction.RollbackException)1 XAException (javax.transaction.xa.XAException)1 Control (org.omg.CosTransactions.Control)1