use of com.hp.mwtests.ts.jta.common.RecoveryXAResource 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.hp.mwtests.ts.jta.common.RecoveryXAResource in project narayana by jbosstm.
the class XARecoveryModuleUnitTest method testXAResourceOrphanFilter.
@Test
public void testXAResourceOrphanFilter() throws Exception {
XAResourceOrphanFilter xaResourceOrphanFilter = new DummyXAResourceOrphanFilter(XAResourceOrphanFilter.Vote.ROLLBACK);
XARecoveryModule xarm = new XARecoveryModule();
xarm.addXAResourceOrphanFilter(xaResourceOrphanFilter);
Class[] parameterTypes = new Class[2];
parameterTypes[0] = XAResource.class;
parameterTypes[1] = Xid.class;
Method m = xarm.getClass().getDeclaredMethod("handleOrphan", parameterTypes);
m.setAccessible(true);
Object[] parameters = new Object[2];
parameters[0] = new RecoveryXAResource();
parameters[1] = new XidImple();
m.invoke(xarm, parameters);
}
use of com.hp.mwtests.ts.jta.common.RecoveryXAResource 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(0);
assertTrue(tx.enlistResource(new RecoveryXAResource()));
assertEquals(tx.doPrepare(), TwoPhaseOutcome.PREPARE_OK);
r.add("com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r);
XARecoveryModule xarm = new XARecoveryModule();
assertNull(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null)));
for (int i = 0; i < 11; i++) {
xarm.periodicWorkFirstPass();
xarm.periodicWorkSecondPass();
}
assertTrue(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(new Uid()), null)) == null);
assertNull(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null)));
}
use of com.hp.mwtests.ts.jta.common.RecoveryXAResource 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();
}
}
Aggregations