use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method testSynchronization.
@Test
public void testSynchronization() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
tx.registerSynchronization(new Synchronization());
assertTrue(tx.getSynchronizations().size() == 1);
tx.setRollbackOnly();
try {
tx.registerSynchronization(new Synchronization());
fail();
} catch (final RollbackException ex) {
}
tx.rollback();
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method test.
@Test
public void test() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
DummyXA res = new DummyXA(false);
tx.enlistResource(res);
tx.delistResource(res, XAResource.TMSUSPEND);
assertTrue(tx.getResources() != null);
assertTrue(tx.getTimeout() != -1);
tx.commit();
assertTrue(TransactionImple.getTransactions() != null);
assertEquals(TransactionImple.getTransactions().size(), 0);
try {
tx = (TransactionImple) TransactionManager.transactionManager(new InitialContext());
fail();
} catch (final Throwable ex) {
}
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple 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);
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testValid1PC.
@Test
public void testValid1PC() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
DummyXA res = new DummyXA(false);
XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
xares.commit_one_phase();
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class XAResourceRecordUnitTest method testCommitFailure.
@Test
public void testCommitFailure() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
FailureXAResource fxa = new FailureXAResource(FailureXAResource.FailLocation.commit);
TransactionImple tx = new TransactionImple();
XAResourceRecord xares = new XAResourceRecord(tx, fxa, tx.getTxId(), null);
assertEquals(xares.prepare(), Vote.VoteCommit);
try {
xares.commit();
fail();
} catch (final HeuristicMixed ex) {
}
xares.forget();
}
Aggregations