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);
}
Aggregations