// Select "Connections" view, ensure no connections exists yet
SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
assertEquals( 0, connectionsTree.rowCount() );
// open "New Connection" wizard
SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
newConnectionMenu.click();
// get buttons
SWTBotButton backButton = bot.button( "< Back" );
SWTBotButton nextButton = bot.button( "Next >" );
SWTBotButton finishButton = bot.button( "Finish" );
// ensure "Next >" and "Finish" buttons are disabled
assertFalse( backButton.isEnabled() );
assertFalse( nextButton.isEnabled() );
assertFalse( finishButton.isEnabled() );
// enter connection parameter
SWTBotText connText = bot.textWithLabel( "Connection name:" );
connText.setText( "NewConnectionWizardTest" );
SWTBotCombo hostnameCombo = bot.comboBoxWithLabel( "Hostname:" );
hostnameCombo.setText( "localhost" );
SWTBotCombo portCombo = bot.comboBoxWithLabel( "Port:" );
portCombo.setText( Integer.toString( ldapServer.getIpPort() ) );
// ensure "Next >" button is enabled, "Finish" button is disabled
assertFalse( backButton.isEnabled() );
assertTrue( nextButton.isEnabled() );
assertFalse( finishButton.isEnabled() );
// jump to auth page
nextButton.click();
// ensure "< Back" is enabled, "Next >" button is disabled, "Finish" button is disabled
assertTrue( backButton.isEnabled() );
assertFalse( nextButton.isEnabled() );
assertFalse( finishButton.isEnabled() );
// ensure "Simple Authentication" is the default
SWTBotCombo authMethodCombo = bot.comboBoxWithLabel( "Authentication Method" );
assertEquals( "Simple Authentication", authMethodCombo.selection() );
// enter authentication parameters
SWTBotCombo dnCombo = bot.comboBoxWithLabel( "Bind DN or user:" );
dnCombo.setText( "uid=admin,ou=system" );
SWTBotText passwordText = bot.textWithLabel( "Bind password:" );
passwordText.setText( "secret" );
// ensure "< Back" is enabled, "Next >" button is enabled, "Finish" button is enabled
assertTrue( backButton.isEnabled() );
assertTrue( nextButton.isEnabled() );
assertTrue( finishButton.isEnabled() );
// finish dialog
finishButton.click();
bot.sleep( 2000 );
// ensure connection was created
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
assertNotNull( connectionManager.getConnections() );
assertEquals( 1, connectionManager.getConnections().length );
Connection connection = connectionManager.getConnections()[0];
assertEquals( "NewConnectionWizardTest", connection.getName() );
assertEquals( "localhost", connection.getHost() );
assertEquals( ldapServer.getIpPort(), connection.getPort() );
assertEquals( AuthenticationMethod.SIMPLE, connection.getAuthMethod() );
assertEquals( "uid=admin,ou=system", connection.getBindPrincipal() );
assertEquals( "secret", connection.getBindPassword() );
// ensure connection is visible in Connections view
assertEquals( 1, connectionsTree.rowCount() );
// close connection
connectionsTree.select( "NewConnectionWizardTest" );
SWTBotMenu contextMenu = connectionsTree.contextMenu( "Close Connection" );
contextMenu.click();
}