public void testAbortSupplyCause() throws Exception { Exception abortCause = new Exception("The cause"); txn.abort(abortCause); assertAborted(abortCause); try { txn.abort(new IllegalArgumentException()); fail("Expected TransactionNotActiveException"); } catch (TransactionNotActiveException e) { System.err.println(e); assertEquals(abortCause, e.getCause()); } assertAborted(abortCause); try { txn.abort(abortXcp); fail("Expected TransactionNotActiveException"); } catch (TransactionNotActiveException e) { System.err.println(e); assertEquals(abortCause, e.getCause()); } assertAborted(abortCause); handle.getTransaction(); try { handle.commit(); fail("Expected TransactionNotActiveException"); } catch (TransactionNotActiveException e) { System.err.println(e); assertEquals(abortCause, e.getCause()); } assertAborted(abortCause); }
public void testCommitAbortedWithNonRetryableCause() throws Exception { Exception abortCause = new IllegalArgumentException(); txn.abort(abortCause); try { handle.commit(); fail("Expected TransactionNotActiveException"); } catch (TransactionNotActiveException e) { System.err.println(e); assertFalse(retryable(e)); assertEquals(abortCause, e.getCause()); } assertAborted(abortCause); }
public void testAbortAbortedWithRetryableCause() throws Exception { Exception abortCause = new TransactionAbortedException("Aborted"); txn.abort(abortCause); try { txn.abort(new IllegalArgumentException()); fail("Expected TransactionNotActiveException"); } catch (TransactionNotActiveException e) { System.err.println(e); assertTrue(retryable(e)); assertEquals(abortCause, e.getCause()); } assertAborted(abortCause); }
public void testJoinAbortedWithNonRetryableCause() throws Exception { DummyTransactionParticipant participant = new DummyTransactionParticipant(); Exception abortCause = new IllegalArgumentException(); txn.abort(abortCause); try { txn.join(participant); fail("Expected TransactionNotActiveException"); } catch (TransactionNotActiveException e) { System.err.println(e); assertFalse(retryable(e)); assertEquals(abortCause, e.getCause()); } assertAborted(abortCause); }