use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class XARecoveryModuleUnitTest method testRecover.
@Test
public void testRecover() throws Exception {
ArrayList<String> r = new ArrayList<String>();
TransactionImple tx = new TransactionImple();
assertTrue(tx.enlistResource(new RecoveryXAResource()));
SubordinateAtomicTransaction sat = new SubordinateAtomicTransaction(tx.get_uid(), tx.getTxId(), 0);
assertEquals(sat.doPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
r.add("com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r);
XARecoveryModule xarm = new XARecoveryModule();
for (int i = 0; i < 11; i++) {
xarm.periodicWorkFirstPass();
xarm.periodicWorkSecondPass();
}
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class XARecoveryModuleUnitTest method testEmptyResourceEnlistmentParams.
/**
* Test which uses method {@link TransactionImple#enlistResource(XAResource, Object[])} could be used
* with empty object array and still works.
*/
@Test
public void testEmptyResourceEnlistmentParams() throws Exception {
final Uid uid = new Uid();
final Xid xid = XidUtils.getXid(uid, true);
SubordinateTransaction subordinateTransaction = SubordinationManager.getTransactionImporter().importTransaction(xid);
TransactionImple subordinateTransactionImple = (TransactionImple) subordinateTransaction;
TestXAResourceWrapper xar = new TestXAResourceWrapper("narayana", "narayana", "java:/test1");
subordinateTransactionImple.enlistResource(xar, new Object[] {});
int statusPrepare = subordinateTransaction.doPrepare();
subordinateTransaction.doCommit();
assertEquals("transaction should be prepared", TwoPhaseOutcome.PREPARE_OK, statusPrepare);
assertEquals("XAResource can't be rolled-back", 0, xar.rollbackCount());
assertEquals("XAResource has to be committed", 1, xar.commitCount());
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class WorkUnitTest method testWorkSynchronization.
@Test
public void testWorkSynchronization() throws Exception {
Transaction tx = new TransactionImple();
Synchronization ws = new WorkSynchronization(tx);
DummyWork work = new DummyWork();
TxWorkManager.addWork(work, tx);
try {
ws.beforeCompletion();
fail();
} catch (final IllegalStateException ex) {
}
ws.afterCompletion(Status.STATUS_COMMITTED);
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class WorkUnitTest method testWorkManager.
@Test
public void testWorkManager() throws Exception {
DummyWork work = new DummyWork();
Transaction tx = new TransactionImple();
TxWorkManager.addWork(work, tx);
try {
TxWorkManager.addWork(new DummyWork(), tx);
fail();
} catch (final Throwable ex) {
}
assertTrue(TxWorkManager.hasWork(tx));
assertEquals(work, TxWorkManager.getWork(tx));
TxWorkManager.removeWork(work, tx);
assertEquals(TxWorkManager.getWork(tx), null);
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class LastResourceRecordUnitTest method test.
@Test
public void test() throws Exception {
TransactionImple tx = new TransactionImple();
LastResourceRecord rec = new LastResourceRecord(tx, new DummyXA(false), tx.getTxId(), null);
rec.commit();
assertEquals(rec.prepare(), Vote.VoteCommit);
assertTrue(rec.toString() != null);
assertFalse(rec.saveRecord());
assertTrue(rec.type() != null);
}
Aggregations