public TestConnection(String name) {
super(name);
}
public static ConnectionImpl getMMConnection() {
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);
}
stub(mock.getService(DQP.class)).toReturn(dqp);
Properties props = new Properties();
props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
return new ConnectionImpl(mock, props, serverUrl);
}