use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.
the class TransactionImpleUnitTest method testEnlist.
@Test
public void testEnlist() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
tx.setRollbackOnly();
try {
tx.enlistResource(null);
fail();
} catch (final SystemException ex) {
}
try {
tx.enlistResource(new DummyXA(false));
fail();
} catch (final RollbackException ex) {
}
try {
tx.commit();
fail();
} catch (final RollbackException ex) {
}
try {
tx.enlistResource(new DummyXA(false));
fail();
} catch (final IllegalStateException ex) {
}
Control suspend = OTSImpleManager.current().suspend();
tx = new TransactionImple();
DummyXA res = new DummyXA(false);
tx.enlistResource(res);
tx.delistResource(res, XAResource.TMSUSPEND);
tx.enlistResource(res);
tx.commit();
}
use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.
the class TransactionImpleUnitTest method testDelist.
@Test
public void testDelist() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
try {
tx.delistResource(null, XAResource.TMSUCCESS);
fail();
} catch (final SystemException ex) {
}
DummyXA xares = new DummyXA(false);
try {
assertFalse(tx.delistResource(xares, XAResource.TMSUCCESS));
} catch (final Throwable ex) {
fail();
}
tx.enlistResource(xares);
assertTrue(tx.delistResource(xares, XAResource.TMSUCCESS));
tx.commit();
try {
tx.delistResource(xares, XAResource.TMSUCCESS);
fail();
} catch (final IllegalStateException ex) {
}
}
use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testRecovery.
@Test
public void testRecovery() throws Exception {
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
DummyXAResourceRecord xares = new DummyXAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
assertEquals(xares.getRecoveryCoordinator(), null);
assertEquals(xares.recover(), XARecoveryResource.FAILED_TO_RECOVER);
xares.setXAResource(null);
}
use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testPackUnpack.
@Test
public void testPackUnpack() 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 DummyXA(false), new XidImple(new Uid()), params);
OutputObjectState os = new OutputObjectState();
assertTrue(xares.saveState(os));
xares = new XAResourceRecord();
InputObjectState is = new InputObjectState(os);
assertTrue(xares.restoreState(is));
}
use of com.hp.mwtests.ts.jta.jts.common.DummyXA in project narayana by jbosstm.
the class XAResourceRecordUnitTest method test.
@Test
public void test() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
XAResourceRecord xares = new XAResourceRecord();
DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
Object[] params = new Object[1];
params[XAResourceRecord.XACONNECTION] = rc;
xares = new XAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
xares.merge(null);
xares.alter(null);
assertTrue(xares.type() != null);
assertTrue(xares.toString() != null);
assertTrue(xares.get_uid().notEquals(Uid.nullUid()));
}
Aggregations