}
@Test
public void testMethodInvocation() throws Exception {
ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
csr.registerClientService(ILogon.class, new ILogon() {
public ResultsFuture<?> logoff()
throws InvalidSessionException {
ResultsFuture<?> result = new ResultsFuture<Void>();
result.getResultsReceiver().exceptionOccurred(new TeiidComponentException("some exception")); //$NON-NLS-1$
return result;
}
public LogonResult logon(Properties connectionProperties)
throws LogonException, TeiidComponentException {
return new LogonResult();
}
// tests asynch where we don't care about the result
public ResultsFuture<?> ping() throws InvalidSessionException,
TeiidComponentException {
return null;
}
@Override
public ResultsFuture<?> ping(Collection<String> sessions)
throws TeiidComponentException, CommunicationException {
return null;
}
@Override
public void assertIdentity(SessionToken sessionId)
throws InvalidSessionException,
TeiidComponentException {
}
}, "foo"); //$NON-NLS-1$
csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo"); //$NON-NLS-1$
final FakeClientServerInstance serverInstance = new FakeClientServerInstance(csr);
SocketServerConnection connection = createFakeConnection(serverInstance);
ILogon logon = connection.getService(ILogon.class);
Future<?> result = logon.ping();
assertNull(result.get(0, TimeUnit.MILLISECONDS));
result = logon.logoff();
try {
result.get(0, TimeUnit.MICROSECONDS);
fail("exception expected"); //$NON-NLS-1$
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof TeiidComponentException);