Search in sources :

Example 61 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class ResourceManagerFailureUnitTest method getUidsCount.

private int getUidsCount() throws Exception {
    final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    InputObjectState states = new InputObjectState();
    int counter = 0;
    if (recoveryStore.allObjUids(XAResourceRecord.typeName(), states) && states.notempty()) {
        while (UidHelper.unpackFrom(states).notEquals(Uid.nullUid())) {
            counter++;
        }
    }
    return counter;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 62 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class ServerTransactionUnitTest method test.

@Test
public void test() throws Exception {
    ServerTransaction sc = new ServerTransaction(new Uid(), null);
    assertTrue(sc.type() != null);
    assertTrue(ServerTransaction.typeName() != null);
    assertTrue(sc.getSavingUid().notEquals(Uid.nullUid()));
    OutputObjectState os = new OutputObjectState();
    assertTrue(sc.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(sc.restore_state(is, ObjectType.ANDPERSISTENT));
    sc.setRecoveryCoordinator(null);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction) Test(org.junit.Test)

Example 63 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class ResourceRecordUnitTest method test.

@Test
public void test() throws Exception {
    DemoResource res = new DemoResource();
    ResourceRecord rec = new ResourceRecord(false, res.getResource(), new Uid());
    PrintWriter writer = new PrintWriter(new ByteArrayOutputStream());
    rec.print(writer);
    assertTrue(rec.resourceHandle() != null);
    OutputObjectState os = new OutputObjectState();
    assertTrue(rec.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(rec.restore_state(is, ObjectType.ANDPERSISTENT));
}
Also used : DemoResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ResourceRecord(com.arjuna.ats.internal.jts.resources.ResourceRecord) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 64 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class AssumedCompleteHeuristicServerTransactionUnitTest method testSaveAndRestoreState.

@Test
public void testSaveAndRestoreState() throws IOException {
    final OutputObjectState outputObjectState = new OutputObjectState();
    Assert.assertTrue(transaction.save_state(outputObjectState, ObjectType.ANDPERSISTENT));
    final Date lastActiveTime = transaction.getLastActiveTime();
    final InputObjectState inputObjectState = new InputObjectState(outputObjectState);
    Assert.assertTrue(transaction.restore_state(inputObjectState, ObjectType.ANDPERSISTENT));
    Assert.assertEquals(lastActiveTime.getTime(), inputObjectState.unpackLong());
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Date(java.util.Date) Test(org.junit.Test)

Example 65 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class AssumedCompleteUnitTest method testTransaction.

@Test
public void testTransaction() throws Exception {
    AssumedCompleteTransaction tx = new AssumedCompleteTransaction(new Uid());
    assertEquals(tx.getOriginalStatus(), Status.StatusNoTransaction);
    assertTrue(tx.type() != null);
    assertEquals(AssumedCompleteTransaction.typeName(), tx.type());
    assertTrue(tx.toString() != null);
    assertFalse(tx.assumeComplete());
    assertEquals(tx.getLastActiveTime(), null);
    OutputObjectState os = new OutputObjectState();
    assertTrue(tx.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(tx.restore_state(is, ObjectType.ANDPERSISTENT));
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) AssumedCompleteTransaction(com.arjuna.ats.internal.jts.recovery.transactions.AssumedCompleteTransaction) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Aggregations

InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)133 Uid (com.arjuna.ats.arjuna.common.Uid)83 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)55 Test (org.junit.Test)47 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)42 IOException (java.io.IOException)30 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)23 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)17 XidImple (com.arjuna.ats.jta.xa.XidImple)9 XAException (javax.transaction.xa.XAException)9 ArrayList (java.util.ArrayList)8 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)7 Xid (javax.transaction.xa.Xid)6 SubordinateAtomicAction (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction)5 Date (java.util.Date)5 Vector (java.util.Vector)5 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)4 HashedActionStore (com.arjuna.ats.internal.arjuna.objectstore.HashedActionStore)4 NullActionStore (com.arjuna.ats.internal.arjuna.objectstore.NullActionStore)4 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)4