Search in sources :

Example 1 with TransactionContext

use of org.teiid.dqp.service.TransactionContext in project teiid by teiid.

the class TestTransactionServer method testGlobalPrepare.

@Test
public void testGlobalPrepare() throws Exception {
    server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
    TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
    server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
    server.prepare(THREAD1, XID1, false);
    Mockito.verify(xaTerminator).prepare(tc.getXid());
    server.commit(THREAD1, XID1, true, false);
}
Also used : TransactionContext(org.teiid.dqp.service.TransactionContext) Test(org.junit.Test)

Example 2 with TransactionContext

use of org.teiid.dqp.service.TransactionContext in project teiid by teiid.

the class TestTransactionServer method testRequestCommit.

@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();
}
Also used : TransactionContext(org.teiid.dqp.service.TransactionContext) Test(org.junit.Test)

Example 3 with TransactionContext

use of org.teiid.dqp.service.TransactionContext in project teiid by teiid.

the class TestTransactionServer method testGlobalOnePhaseCommit_force_prepare.

@Test
public void testGlobalOnePhaseCommit_force_prepare() throws Exception {
    server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
    TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
    server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
    server.commit(THREAD1, XID1, true, false);
    // since there are two sources the commit is not single phase
    Mockito.verify(xaTerminator).prepare(tc.getXid());
    Mockito.verify(xaTerminator).commit(tc.getXid(), false);
}
Also used : TransactionContext(org.teiid.dqp.service.TransactionContext) Test(org.junit.Test)

Example 4 with TransactionContext

use of org.teiid.dqp.service.TransactionContext in project teiid by teiid.

the class TestTransactionServer method testGlobalOnePhaseCommit_force_prepare_through.

@Test
public void testGlobalOnePhaseCommit_force_prepare_through() throws Exception {
    server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
    TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
    server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
    server.commit(THREAD1, XID1, true, false);
    Mockito.verify(xaTerminator).prepare(tc.getXid());
    Mockito.verify(xaTerminator).commit(tc.getXid(), false);
}
Also used : TransactionContext(org.teiid.dqp.service.TransactionContext) Test(org.junit.Test)

Example 5 with TransactionContext

use of org.teiid.dqp.service.TransactionContext in project teiid by teiid.

the class TestTransactionServer method testGlobalOnePhase_teiid_multiple.

@Test
public void testGlobalOnePhase_teiid_multiple() throws Exception {
    server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
    TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
    server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
    server.prepare(THREAD1, XID1, false);
    server.commit(THREAD1, XID1, true, false);
    // since there are two sources the commit is not single phase
    Mockito.verify(xaTerminator).commit(tc.getXid(), false);
}
Also used : TransactionContext(org.teiid.dqp.service.TransactionContext) Test(org.junit.Test)

Aggregations

TransactionContext (org.teiid.dqp.service.TransactionContext)34 Test (org.junit.Test)15 CommandContext (org.teiid.query.util.CommandContext)7 TransactionService (org.teiid.dqp.service.TransactionService)6 XATransactionException (org.teiid.client.xa.XATransactionException)5 TeiidProcessingException (org.teiid.core.TeiidProcessingException)5 VariableContext (org.teiid.query.sql.util.VariableContext)5 List (java.util.List)4 SystemException (javax.transaction.SystemException)4 Transaction (javax.transaction.Transaction)4 TeiidComponentException (org.teiid.core.TeiidComponentException)4 TupleBatch (org.teiid.common.buffer.TupleBatch)3 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)3 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)3 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)3 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)3 Command (org.teiid.query.sql.lang.Command)3 ArrayList (java.util.ArrayList)2 RollbackException (javax.transaction.RollbackException)2 Synchronization (javax.transaction.Synchronization)2