use of com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter in project narayana by jbosstm.
the class XAResourceOrphanFilterTest method testJTAActionStatusServiceXAResourceOrphanFilterSubordinate.
@Test
public void testJTAActionStatusServiceXAResourceOrphanFilterSubordinate() throws HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException, SystemException, RollbackException, XAException {
XAResourceOrphanFilter orphanFilter = new SubordinationManagerXAResourceOrphanFilter();
List<String> xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
List<String> recoveryNodes = new LinkedList<String>();
recoveryNodes.add("1");
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
final List<String> recoveryExtensions = new ArrayList<String>();
recoveryExtensions.add(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateAtomicActionRecoveryModule.class.getName());
recoveryExtensions.add(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.class.getName());
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModuleClassNames(recoveryExtensions);
int recoveryBackoffPeriod = recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryBackoffPeriod();
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
RecoveryManager.manager().scan();
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(recoveryBackoffPeriod);
try {
Xid xid = XATxConverter.getXid(Uid.nullUid(), false, XATxConverter.FORMAT_ID);
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(xid));
SubordinateTransaction subordinateTransaction = SubordinationManager.getTransactionImporter().importTransaction(xid);
final List<Xid> xids = new ArrayList<Xid>();
XAResource xar = new SimpleXAResource() {
@Override
public void start(Xid xid, int flags) throws XAException {
super.start(xid, flags);
xids.add(xid);
}
};
subordinateTransaction.enlistResource(xar);
try {
assertEquals(XAResourceOrphanFilter.Vote.LEAVE_ALONE, orphanFilter.checkXid(xids.get(0)));
} finally {
subordinateTransaction.doRollback();
}
assertEquals(XAResourceOrphanFilter.Vote.LEAVE_ALONE, orphanFilter.checkXid(xids.get(0)));
SubordinationManager.getTransactionImporter().removeImportedTransaction(xid);
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xids.get(0)));
} finally {
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xaRecoveryNodes);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModuleClassNames(null);
}
}
Aggregations