use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class JTAOrder method test.
@Test
public void test() throws Exception {
XAResource theResource = new TestResource();
FirstXAResource first = new FirstXAResource();
LastXAResource last = new LastXAResource();
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
System.out.println("Starting top-level transaction.");
tm.begin();
javax.transaction.Transaction theTransaction = tm.getTransaction();
theTransaction.enlistResource(theResource);
theTransaction.enlistResource(last);
theTransaction.enlistResource(first);
System.out.println("Committing transaction.");
tm.commit();
assertEquals(Status.STATUS_COMMITTED, theTransaction.getStatus());
}
use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class SimpleNestedTest method testEnabled.
@Test
public void testEnabled() throws Exception {
jtaPropertyManager.getJTAEnvironmentBean().setSupportSubtransactions(true);
javax.transaction.TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
transactionManager.begin();
transactionManager.begin();
Transaction currentTrans = transactionManager.getTransaction();
TestResource res1, res2;
currentTrans.enlistResource(res1 = new TestResource());
currentTrans.enlistResource(res2 = new TestResource());
currentTrans.delistResource(res2, XAResource.TMSUCCESS);
currentTrans.delistResource(res1, XAResource.TMSUCCESS);
transactionManager.commit();
transactionManager.commit();
}
use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class SimpleTest method test.
@Test
public void test() throws Exception {
javax.transaction.TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
transactionManager.begin();
Transaction currentTrans = transactionManager.getTransaction();
TestResource res1, res2;
currentTrans.enlistResource(res1 = new TestResource());
currentTrans.enlistResource(res2 = new TestResource());
currentTrans.delistResource(res2, XAResource.TMSUCCESS);
currentTrans.delistResource(res1, XAResource.TMSUCCESS);
transactionManager.commit();
}
use of com.hp.mwtests.ts.jta.common.TestResource 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()));
}
use of com.hp.mwtests.ts.jta.common.TestResource in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testReadonly.
@Test
public void testReadonly() 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 TestResource(true), new XidImple(new Uid()), params);
try {
xares.commit();
fail();
} catch (final NotPrepared ex) {
}
assertEquals(xares.prepare(), Vote.VoteReadOnly);
}
Aggregations