Search in sources :

Example 11 with XATransactionException

use of org.teiid.client.xa.XATransactionException in project teiid by teiid.

the class TestConnection method getMMConnection.

public static ConnectionImpl getMMConnection(String url) {
    ServerConnection mock = mock(ServerConnection.class);
    DQP dqp = mock(DQP.class);
    try {
        stub(dqp.start((XidImpl) Mockito.anyObject(), Mockito.anyInt(), Mockito.anyInt())).toAnswer(new Answer() {

            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                return ResultsFuture.NULL_FUTURE;
            }
        });
        stub(dqp.rollback((XidImpl) Mockito.anyObject())).toAnswer(new Answer() {

            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                return ResultsFuture.NULL_FUTURE;
            }
        });
        stub(dqp.rollback()).toAnswer(new Answer() {

            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                return ResultsFuture.NULL_FUTURE;
            }
        });
    } catch (XATransactionException e) {
        throw new RuntimeException(e);
    }
    Properties props = new Properties();
    try {
        new InnerDriver(url).parseUrl(props);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    stub(mock.getService(DQP.class)).toReturn(dqp);
    // $NON-NLS-1$
    stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "admin"), STD_DATABASE_NAME, "fake"));
    return new ConnectionImpl(mock, props, url);
}
Also used : DQP(org.teiid.client.DQP) SQLException(java.sql.SQLException) SessionToken(org.teiid.client.security.SessionToken) LogonResult(org.teiid.client.security.LogonResult) ServerConnection(org.teiid.net.ServerConnection) XATransactionException(org.teiid.client.xa.XATransactionException) Properties(java.util.Properties) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Aggregations

XATransactionException (org.teiid.client.xa.XATransactionException)11 TeiidComponentException (org.teiid.core.TeiidComponentException)6 TransactionContext (org.teiid.dqp.service.TransactionContext)4 TransactionService (org.teiid.dqp.service.TransactionService)3 SystemException (javax.transaction.SystemException)2 Transaction (javax.transaction.Transaction)2 Method (java.lang.reflect.Method)1 SQLException (java.sql.SQLException)1 Properties (java.util.Properties)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 NotSupportedException (javax.resource.NotSupportedException)1 WorkException (javax.resource.spi.work.WorkException)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 DQP (org.teiid.client.DQP)1 LogonResult (org.teiid.client.security.LogonResult)1 SessionToken (org.teiid.client.security.SessionToken)1 DataTierTupleSource (org.teiid.dqp.internal.process.DataTierTupleSource)1 ServerConnection (org.teiid.net.ServerConnection)1