Search in sources :

Example 6 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testInvalid.

@Test
public void testInvalid() throws Exception {
    XAResourceRecord xares = new XAResourceRecord();
    assertEquals(xares.getXid(), null);
    assertEquals(xares.value(), null);
    assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
    assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
    assertEquals(xares.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
    assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.FINISH_ERROR);
}
Also used : XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) Test(org.junit.Test)

Example 7 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method test.

@Test
public void test() throws Exception {
    XAResourceRecord xares = new XAResourceRecord();
    Object obj = new Object();
    xares.setValue(obj);
    assertTrue(xares.value() != obj);
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
    assertTrue(xares.type() != null);
    xares.merge(xares);
    xares.replace(xares);
    assertTrue(xares.toString() != 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.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) Test(org.junit.Test)

Example 8 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testNested.

@Test
public void testNested() throws Exception {
    XAResourceRecord xares = new XAResourceRecord();
    assertEquals(xares.nestedOnePhaseCommit(), TwoPhaseOutcome.FINISH_ERROR);
    assertEquals(xares.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
    assertEquals(xares.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
    assertEquals(xares.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
}
Also used : XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) Test(org.junit.Test)

Example 9 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testReadonly.

@Test
public void testReadonly() throws Exception {
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(0), new TestResource(true), new XidImple(new Uid()), params);
    assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.NOT_PREPARED);
    assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
}
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.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) TestResource(com.hp.mwtests.ts.jta.common.TestResource) Test(org.junit.Test)

Example 10 with XAResourceRecord

use of com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord in project narayana by jbosstm.

the class XAResourceRecordBean method activate.

public boolean activate() {
    boolean ok = super.activate();
    className = rec.getClass().getName();
    if (rec instanceof XAResourceRecord) {
        XAResourceRecord xarec = (XAResourceRecord) rec;
        eisProductName = xarec.getProductName();
        eisProductVersion = xarec.getProductVersion();
        jndiName = xarec.getJndiName();
    }
    if (rec.value() != null) {
        XAResource xar = (XAResource) rec.value();
        className = xar.getClass().getName();
        try {
            timeout = xar.getTransactionTimeout();
        } catch (Exception e) {
        }
    }
    return ok;
}
Also used : XAResource(javax.transaction.xa.XAResource) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) MBeanException(javax.management.MBeanException) IOException(java.io.IOException)

Aggregations

XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)16 Test (org.junit.Test)15 XidImple (com.arjuna.ats.jta.xa.XidImple)9 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)7 Uid (com.arjuna.ats.arjuna.common.Uid)5 XAResource (javax.transaction.xa.XAResource)5 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)4 DummyXA (com.hp.mwtests.ts.jta.common.DummyXA)4 FailureXAResource (com.hp.mwtests.ts.jta.common.FailureXAResource)4 Xid (javax.transaction.xa.Xid)4 DummyRecoverableXAConnection (com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection)3 SubordinateAtomicAction (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction)2 ArrayList (java.util.ArrayList)2 XAException (javax.transaction.xa.XAException)2 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1 RecoverAtomicAction (com.arjuna.ats.arjuna.recovery.RecoverAtomicAction)1 RecoveryManager (com.arjuna.ats.arjuna.recovery.RecoveryManager)1 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)1 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1