Search in sources :

Example 1 with RecoveryXids

use of com.arjuna.ats.internal.jta.recovery.arjunacore.RecoveryXids in project narayana by jbosstm.

the class RecoveryXidsUnitTest method test.

@Test
public void test() {
    TestResource tr = new TestResource();
    RecoveryXids rxids = new RecoveryXids(tr);
    Xid[] xids = new XidImple[2];
    xids[0] = new XidImple(new Uid());
    xids[1] = new XidImple(new Uid());
    RecoveryXids dup1 = new RecoveryXids(new DummyXA(false));
    RecoveryXids dup2 = new RecoveryXids(tr);
    assertFalse(rxids.equals(dup1));
    assertTrue(rxids.equals(dup2));
    rxids.nextScan(xids);
    rxids.nextScan(xids);
    xids[1] = new XidImple(new Uid());
    rxids.nextScan(xids);
    Object[] trans = rxids.toRecover();
    assertEquals(0, trans.length);
    try {
        Thread.sleep(20010);
    } catch (InterruptedException e) {
    }
    // force cleanup.
    rxids.nextScan(xids);
    trans = rxids.toRecover();
    assertEquals(2, trans.length);
    assertTrue(trans[0].equals(xids[0]) || trans[1].equals(xids[0]));
    assertTrue(trans[0].equals(xids[1]) || trans[1].equals(xids[1]));
    assertTrue(rxids.contains(xids[0]));
    assertFalse(rxids.updateIfEquivalentRM(new TestResource(), null));
    assertTrue(rxids.updateIfEquivalentRM(new TestResource(), xids));
    assertFalse(rxids.isSameRM(new TestResource()));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) RecoveryXids(com.arjuna.ats.internal.jta.recovery.arjunacore.RecoveryXids) TestResource(com.hp.mwtests.ts.jta.common.TestResource) Test(org.junit.Test)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)1 RecoveryXids (com.arjuna.ats.internal.jta.recovery.arjunacore.RecoveryXids)1 XidImple (com.arjuna.ats.jta.xa.XidImple)1 DummyXA (com.hp.mwtests.ts.jta.common.DummyXA)1 TestResource (com.hp.mwtests.ts.jta.common.TestResource)1 Xid (javax.transaction.xa.Xid)1 Test (org.junit.Test)1