XAExceptionFactory extends AbstractExceptionFactory<XAException> { @Override public boolean correctHeuristic(XAException exception, Phase phase) { switch (phase) { case COMMIT: { return exception.errorCode == XAException.XA_HEURCOM; } case ROLLBACK: { return exception.errorCode == XAException.XA_HEURRB; } default: { return false; } } } XAExceptionFactory(); @Override XAException createException(String message); @Override boolean equals(XAException exception1, XAException exception2); @Override boolean indicatesFailure(XAException exception, Dialect dialect); @Override ExceptionType getType(); @Override boolean correctHeuristic(XAException exception, Phase phase);  }
@Test public void correctHeuristic() { assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBBASE), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBCOMMFAIL), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBDEADLOCK), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBEND), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBINTEGRITY), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBOTHER), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBPROTO), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBROLLBACK), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBTIMEOUT), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_RBTRANSIENT), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_INVAL), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_NOTA), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_PROTO), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMERR), Phase.PREPARE)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMFAIL), Phase.PREPARE)); assertTrue(this.factory.correctHeuristic(new XAException(XAException.XA_HEURCOM), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_HEURHAZ), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_HEURMIX), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_HEURRB), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_INVAL), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_NOTA), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_PROTO), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMERR), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMFAIL), Phase.COMMIT)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_HEURCOM), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_HEURHAZ), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XA_HEURMIX), Phase.ROLLBACK)); assertTrue(this.factory.correctHeuristic(new XAException(XAException.XA_HEURRB), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_INVAL), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_NOTA), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_PROTO), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMERR), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMFAIL), Phase.ROLLBACK)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_INVAL), Phase.FORGET)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_NOTA), Phase.FORGET)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_PROTO), Phase.FORGET)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMERR), Phase.FORGET)); assertFalse(this.factory.correctHeuristic(new XAException(XAException.XAER_RMFAIL), Phase.FORGET)); }