public void testConnectFailures()
{
StudioProgressMonitor monitor = null;
ConnectionParameter connectionParameter = null;
Connection connection = null;
ConnectionWrapper connectionWrapper = null;
// invalid port
monitor = getProgressMonitor();
connectionParameter = new ConnectionParameter( null, "localhost", ldapServer.getPort() + 1,
EncryptionMethod.NONE, NetworkProvider.JNDI, AuthenticationMethod.NONE, null, null, null, true, null );
connection = new Connection( connectionParameter );
connectionWrapper = connection.getConnectionWrapper();
connectionWrapper.connect( monitor );
assertFalse( connectionWrapper.isConnected() );
assertNotNull( monitor.getException() );
assertTrue( monitor.getException() instanceof CommunicationException );
assertNotNull( monitor.getException().getCause() );
assertTrue( monitor.getException().getCause() instanceof ConnectException );
// unknown host
monitor = getProgressMonitor();
connectionParameter = new ConnectionParameter( null, "555.555.555.555", ldapServer.getPort(),
EncryptionMethod.NONE, NetworkProvider.JNDI, AuthenticationMethod.NONE, null, null, null, true, null );
connection = new Connection( connectionParameter );
connectionWrapper = connection.getConnectionWrapper();
connectionWrapper.connect( monitor );
assertFalse( connectionWrapper.isConnected() );
assertNotNull( monitor.getException() );
assertTrue( monitor.getException() instanceof CommunicationException );
assertNotNull( monitor.getException().getCause() );
assertTrue( monitor.getException().getCause() instanceof UnknownHostException );