/** * local cannot be nested */ @Test public void testTransactionExclusion4() throws Exception { server.begin(THREAD1); try { server.begin(THREAD1); fail("exception expected"); //$NON-NLS-1$ } catch (XATransactionException ex) { assertEquals("TEIID30517 Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$ ex.getMessage()); } }
@Test public void testLocalCancel() throws Exception { server.begin(THREAD1); server.cancelTransactions(THREAD1, false); Mockito.verify(txn).setRollbackOnly(); }
@Test public void testRequestCommit() throws Exception{ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.begin(tc); server.commit(tc); assertEquals(TransactionContext.Scope.NONE, tc.getTransactionType()); Mockito.verify(tm).commit(); }
@Test public void testRequestCancel() throws Exception{ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.begin(tc); server.cancelTransactions(THREAD1, true); Mockito.verify(txn).setRollbackOnly(); } }
@Test public void testLocalCommit() throws Exception { server.begin(THREAD1); server.commit(THREAD1); Mockito.verify(tm).commit(); try { server.commit(THREAD1); } catch (XATransactionException e) { assertEquals("TEIID30526 javax.transaction.InvalidTransactionException: No transaction found for client abc1.", e.getMessage()); //$NON-NLS-1$ } }
@Test public void testLocalRollback() throws Exception { server.begin(THREAD1); server.rollback(THREAD1); Mockito.verify(tm).rollback(); try { server.rollback(THREAD1); } catch (XATransactionException e) { assertEquals("TEIID30526 javax.transaction.InvalidTransactionException: No transaction found for client abc1.", e.getMessage()); //$NON-NLS-1$ } }
@Test public void testRequestRollback() throws Exception{ TransactionContext tc = server.getOrCreateTransactionContext(THREAD1); server.begin(tc); server.rollback(tc); assertEquals(TransactionContext.Scope.NONE, tc.getTransactionType()); Mockito.verify(tm).rollback(); }
@Test public void testGetTransactions() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false); server.begin(THREAD2); assertEquals(2, server.getTransactions().size()); server.commit(THREAD2); assertEquals(1, server.getTransactions().size()); Transaction t = server.getTransactions().iterator().next(); assertEquals(THREAD1, t.getAssociatedSession()); assertNotNull(t.getId()); }
/** * once in a global, cannot start a local */ @Test public void testTransactionExclusion1() throws Exception { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false); try { server.begin(THREAD1); fail("exception expected"); //$NON-NLS-1$ } catch (XATransactionException ex) { assertEquals("TEIID30517 Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$ ex.getMessage()); } }
/** * once in a local, cannot start a global */ @Test public void testTransactionExclusion() throws Exception { server.begin(THREAD1); try { server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false); fail("exception expected"); //$NON-NLS-1$ } catch (XATransactionException ex) { assertEquals("TEIID30517 Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.", //$NON-NLS-1$ ex.getMessage()); } }