}
public void testOnePhaseCommitSyncWithRollbackOnlyViaXATerminator() throws Exception
{
final Xid xid = new XidImple(new Uid());
final TransactionImple tm = TxImporter.importTransaction(xid);
final TestSynchronization sync = new TestSynchronization();
tm.registerSynchronization(sync);
tm.setRollbackOnly();
final XATerminator xaTerminator = new XATerminatorImple();
try {
xaTerminator.commit(xid, true);
tm.doOnePhaseCommit();
fail("did not get expected rollback exception");
} catch(XAException e) {
assertEquals("javax.transaction.RollbackException", e.getCause().getClass().getName());
assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
// expected - we tried to commit a rollbackonly tx.
}
assertFalse(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
}