use of org.teiid.client.security.ILogon in project teiid by teiid.
the class SocketServerConnection method connect.
private ILogon connect(HostInfo hostInfo) throws CommunicationException, IOException {
hostInfo.setSsl(secure);
this.serverInstance = connectionFactory.getServerInstance(hostInfo);
this.logonResult = logonResults.get(hostInfo);
ILogon newLogon = this.serverInstance.getService(ILogon.class);
if (this.logonResult != null) {
try {
newLogon.assertIdentity(logonResult.getSessionToken());
} catch (TeiidException e) {
// session is no longer valid
disconnect();
}
}
return newLogon;
}
use of org.teiid.client.security.ILogon in project teiid by teiid.
the class TestSocketServerConnection method testRetry.
/**
* Since the original instance is still open, this will be a transparent retry
*/
@Test
public void testRetry() throws Exception {
SocketServerConnection connection = createConnection(new SingleInstanceCommunicationException());
connection.setFailOver(true);
connection.setFailOverPingInterval(50);
ILogon logon = connection.getService(ILogon.class);
Thread.sleep(70);
logon.ping();
}
use of org.teiid.client.security.ILogon in project teiid by teiid.
the class TestSocketServerConnection method testImmediateFail.
@Test(expected = CommunicationException.class)
public void testImmediateFail() throws Exception {
SocketServerConnection connection = createConnection(new CommunicationException());
ILogon logon = connection.getService(ILogon.class);
logon.ping();
}
use of org.teiid.client.security.ILogon in project teiid by teiid.
the class TestSocketServerInstanceImpl method testSuccessfulHandshake.
@Test
public void testSuccessfulHandshake() throws Exception {
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(new Handshake(), new SocketTimeoutException()));
SocketServerInstanceImpl instance = createInstance(channel);
// no remote server is hooked up, so this will timeout
ILogon logon = instance.getService(ILogon.class);
try {
logon.logon(new Properties());
// $NON-NLS-1$
fail("Exception expected");
} catch (SingleInstanceCommunicationException e) {
assertTrue(e.getCause() instanceof TimeoutException);
}
}
use of org.teiid.client.security.ILogon in project teiid by teiid.
the class TestSocketRemoting method testMethodInvocation.
@Test
public void testMethodInvocation() throws Exception {
ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl() {
@Override
public ClassLoader getCallerClassloader() {
return getClass().getClassLoader();
}
};
csr.registerClientService(ILogon.class, new ILogon() {
public ResultsFuture<?> logoff() throws InvalidSessionException {
ResultsFuture<?> result = new ResultsFuture<Void>();
// $NON-NLS-1$
result.getResultsReceiver().exceptionOccurred(new TeiidComponentException("some exception"));
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 {
}
@Override
public LogonResult neogitiateGssLogin(Properties connectionProperties, byte[] serviceToken, boolean createSession) throws LogonException {
return null;
}
}, // $NON-NLS-1$
"foo");
// $NON-NLS-1$
csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo");
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);
// $NON-NLS-1$
fail("exception expected");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof TeiidComponentException);
}
FakeService service = connection.getService(FakeService.class);
Future<Integer> asynchInteger = service.asynchResult();
assertEquals(new Integer(5), asynchInteger.get(0, TimeUnit.MILLISECONDS));
try {
service.exceptionMethod();
// $NON-NLS-1$
fail("exception expected");
} catch (TeiidProcessingException e) {
}
DQP dqp = connection.getService(DQP.class);
try {
ResultsFuture<?> future = dqp.begin();
future.get();
// $NON-NLS-1$
fail("exception expected");
} catch (Exception e) {
// $NON-NLS-1$
assertTrue(e.getMessage().indexOf("Component not found:") != -1);
}
}
Aggregations