use of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple in project narayana by jbosstm.
the class ObjStoreBrowserTest method testMBeanHeuristic.
/**
* Test that resources that generate heuristics are instrumented correctly
* @throws Exception
*/
@Test
public void testMBeanHeuristic() throws Exception {
// generates a heuristic on commit
FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
getHeuristicMBean(osb, new TransactionImple(1000000000), failureXAResource);
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method testThreadIsActive.
@Test
public void testThreadIsActive() throws Exception {
ThreadActionData.purgeActions();
Class[] parameterTypes = new Class[1];
TransactionImple tx = new TransactionImple(0);
tx.enlistResource(new RecoveryXAResource());
parameterTypes[0] = XAResource.class;
Method m = tx.getClass().getDeclaredMethod("threadIsActive", parameterTypes);
m.setAccessible(true);
Object[] parameters = new Object[1];
parameters[0] = new RecoveryXAResource();
Boolean res = (Boolean) m.invoke(tx, parameters);
assertFalse(res.booleanValue());
tx.rollback();
ThreadActionData.purgeActions();
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method test.
@Test
public void test() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
TxImpleOverride.put(tx);
assertEquals(tx, TransactionImple.getTransaction(tx.get_uid()));
DummyXA res = new DummyXA(false);
tx.enlistResource(res);
tx.delistResource(res, XAResource.TMSUSPEND);
assertTrue(tx.isAlive());
tx.commit();
assertTrue(tx.getRemainingTimeoutMills() != -1);
assertTrue(tx.getTimeout() != -1);
assertEquals(tx.getSynchronizations().size(), 0);
assertEquals(tx.getResources().size(), 1);
TxImpleOverride.remove(tx);
assertTrue(TransactionImple.getTransactions() != null);
assertEquals(TransactionImple.getTransaction(tx.get_uid()), null);
try {
tx = (TransactionImple) TransactionManager.transactionManager(new InitialContext());
fail();
} catch (final Throwable ex) {
}
assertNull(TransactionImple.getTransaction(null));
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method testFailure.
@Test
public void testFailure() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
assertFalse(tx.equals(null));
assertTrue(tx.equals(tx));
tx.enlistResource(new FailureXAResource(FailLocation.commit));
try {
tx.commit();
fail();
} catch (final HeuristicMixedException ex) {
}
assertEquals(tx.getStatus(), Status.STATUS_COMMITTED);
try {
tx.registerSynchronization(null);
fail();
} catch (final SystemException ex) {
}
try {
tx.commit();
fail();
} catch (final IllegalStateException ex) {
}
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method testDelist.
@Test
public void testDelist() throws Exception {
ThreadActionData.purgeActions();
TransactionImple tx = new TransactionImple(0);
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) {
}
}
Aggregations