directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r782255 [1/2] - in /directory/studio/trunk: ./ connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ test-integration-ui/src/mai...
Date Sat, 06 Jun 2009 13:11:12 GMT
Author: seelmann
Date: Sat Jun  6 13:11:11 2009
New Revision: 782255

URL: http://svn.apache.org/viewvc?rev=782255&view=rev
Log:
DIRSTUDIO-263:
o Fixes for certificate validation
o UI-Tests for certificate validation, actually ignored till DIRSERVER-1373 is fixed
o Refactored some UI tests, using helper bots now
o Added wait conditions in Import/Export tests



Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java   (with props)
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java   (with props)
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java   (with props)
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java   (with props)
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/WizardBot.java
Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioTrustManager.java
    directory/studio/trunk/pom.xml
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java?rev=782255&r1=782254&r2=782255&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioSSLSocketFactory.java Sat Jun  6 13:11:11 2009
@@ -43,25 +43,19 @@
 public class StudioSSLSocketFactory extends SSLSocketFactory
 {
 
-    /** The default instance. */
-    private static StudioSSLSocketFactory instance;
-
-
     /**
-     * Gets the default instance.
+     * Gets the default instance. In fact just creates a new
+     * instance on each call to make sure the underlying
+     * TrustManagers are newly initialized. 
      * 
-     * Note: This method is invoked from the JNDI (Sun) when 
+     * Note: This method is invoked from Sun JNDI when 
      * creating a ldaps:// connection. Must be public static!
      * 
      * @return the default instance
      */
     public static SSLSocketFactory getDefault()
     {
-        if ( instance == null )
-        {
-            instance = new StudioSSLSocketFactory();
-        }
-        return instance;
+        return new StudioSSLSocketFactory();
     }
 
     /** The delegate. */
@@ -74,8 +68,8 @@
     /**
      * Creates a new instance of StudioSSLSocketFactory.
      * 
-     * Note: This method is invoked from the JNDI (Apache Harmony) when 
-     * creating a ldaps:// connection. Must be public!
+     * Note: This default constructor is invoked from Apache Harmony JNDI 
+     * when creating a ldaps:// connection. Must be public!
      */
     public StudioSSLSocketFactory()
     {

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioTrustManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioTrustManager.java?rev=782255&r1=782254&r2=782255&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioTrustManager.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/StudioTrustManager.java Sat Jun  6 13:11:11 2009
@@ -152,6 +152,22 @@
                 {
                     failCauses.add( FailCause.NoValidCertificationPath );
                 }
+                
+                try
+                {
+                    chain[0].checkValidity();
+                }
+                catch ( CertificateException ve )
+                {
+                    if ( ve instanceof CertificateExpiredException )
+                    {
+                        failCauses.add( FailCause.CertificateExpired );
+                    }
+                    else if ( ve instanceof CertificateNotYetValidException )
+                    {
+                        failCauses.add( FailCause.CertificateNotYetValid );
+                    }
+                }
             }
         }
 

Modified: directory/studio/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/pom.xml?rev=782255&r1=782254&r2=782255&view=diff
==============================================================================
--- directory/studio/trunk/pom.xml (original)
+++ directory/studio/trunk/pom.xml Sat Jun  6 13:11:11 2009
@@ -1000,7 +1000,7 @@
       <dependency>
         <groupId>org.apache.mina</groupId>
         <artifactId>mina-core</artifactId>
-        <version>2.0.0-M4</version>
+        <version>2.0.0-M6</version>
       </dependency>
       <dependency>
         <groupId>xerces</groupId>

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java?rev=782255&r1=782254&r2=782255&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java Sat Jun  6 13:11:11 2009
@@ -42,6 +42,7 @@
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.junit.After;
@@ -99,7 +100,7 @@
     public void testExportImportLdifWithGermanUmlautInDN() throws Exception
     {
         URL url = Platform.getInstanceLocation().getURL();
-        String file = url.getFile() + "ImportExportTest.ldif";
+        final String file = url.getFile() + "ImportExportTest.ldif";
 
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( eBot );
 
@@ -113,6 +114,22 @@
         eBot.comboBoxWithLabel( "LDIF File:" ).setText( file );
         eBot.button( "Finish" ).click();
 
+        // wait till LDIF file exists
+        eBot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                File f = new File( file );
+                return f.exists() && f.length() > 200; // is actually 217 bytes
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "LDIF File " + file + " not found.";
+            }
+        } );
+
         List<String> lines = FileUtils.readLines( new File( file ) );
         // verify that the first line of exported LDIF is "version: 1"
         assertEquals( "LDIF must start with version: 1", lines.get( 0 ), "version: 1" );
@@ -151,7 +168,7 @@
     public void testExportImportDsmlWithGermanUmlautInDN() throws Exception
     {
         URL url = Platform.getInstanceLocation().getURL();
-        String file = url.getFile() + "ImportExportTest.dsml";
+        final String file = url.getFile() + "ImportExportTest.dsml";
 
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( eBot );
 
@@ -166,6 +183,22 @@
         eBot.radio( "DSML Request" ).click();
         eBot.button( "Finish" ).click();
 
+        // wait till DSML file exists
+        eBot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                File f = new File( file );
+                return f.exists() && f.length() > 600; // is actually 651 bytes
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "DSML File " + file + " not found.";
+            }
+        } );
+
         // verify that exported DSML contains the Base64 encoded DN
         String content = FileUtils.readFileToString( new File( file ), "UTF-8" );
         assertTrue( "DSML must contain DN with umlaut.", content

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java?rev=782255&r1=782254&r2=782255&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java Sat Jun  6 13:11:11 2009
@@ -25,25 +25,52 @@
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
 
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.math.BigInteger;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.integ.Level;
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
 import org.apache.directory.server.integ.SiRunner;
 import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.client.ClientModification;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.apache.directory.studio.connection.core.ConnectionManager;
 import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.apache.directory.studio.test.integration.ui.bots.CertificateTrustDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.ErrorDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.NewConnectionWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.apache.mina.util.AvailablePortFinder;
+import org.bouncycastle.x509.X509V1CertificateGenerator;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -55,19 +82,46 @@
  * @version $Rev$, $Date$
  */
 @RunWith(SiRunner.class)
-@CleanupLevel(Level.SUITE)
+@CleanupLevel(Level.CLASS)
 public class NewConnectionWizardTest
 {
     public static LdapService ldapService;
+    public static LdapService ldapsService;
+    private File ksFile;
+
+    private StudioBot studioBot;
+    private ConnectionsViewBot connectionsViewBot;
+    private NewConnectionWizardBot wizardBot;
 
-    private SWTWorkbenchBot bot;
+
+    @Before
+    public void setUpLdaps() throws Exception
+    {
+        if ( ldapsService == null )
+        {
+            ldapsService = new LdapService();
+            ldapsService.setDirectoryService( ldapService.getDirectoryService() );
+            int port = AvailablePortFinder.getNextAvailable( ldapService.getPort() + 10 );
+            ldapsService.setTcpTransport( new TcpTransport( port ) );
+            ldapsService.setEnabled( true );
+            ldapsService.setEnableLdaps( true );
+            ldapsService.setConfidentialityRequired( true );
+            ldapsService.start();
+        }
+    }
 
 
     @Before
     public void setUp() throws Exception
     {
-        bot = new SWTWorkbenchBot();
-        SWTBotUtils.openLdapPerspective( bot );
+        studioBot = new StudioBot();
+        studioBot.resetLdapPerspective();
+        connectionsViewBot = studioBot.getConnectionView();
+
+        // open the new connection wizard
+        wizardBot = connectionsViewBot.openNewConnectionWizard();
+
+        //ErrorDialog.AUTOMATED_MODE = false;
     }
 
 
@@ -75,78 +129,200 @@
     public void tearDown() throws Exception
     {
         SWTBotUtils.deleteTestConnections();
-        bot = null;
+        studioBot = null;
+        connectionsViewBot = null;
+        wizardBot = null;
+
+        // delete old key store
+        if ( ksFile != null && ksFile.exists() )
+        {
+            ksFile.delete();
+        }
+
+        // delete custom trust stores
+        X509Certificate[] permanentCertificates = ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager()
+            .getCertificates();
+        for ( X509Certificate certificate : permanentCertificates )
+        {
+            ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().removeCertificate( certificate );
+        }
+        X509Certificate[] temporaryCertificates = ConnectionCorePlugin.getDefault().getSessionTrustStoreManager()
+            .getCertificates();
+        for ( X509Certificate certificate : temporaryCertificates )
+        {
+            ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().removeCertificate( certificate );
+        }
+
+        // delete custom JNDI key store settings
+        System.getProperties().remove( "javax.net.ssl.trustStore" );
+        System.getProperties().remove( "javax.net.ssl.keyStore" );
+        System.getProperties().remove( "javax.net.ssl.keyStorePassword" );
     }
 
 
     /**
-     * Creates a new connection using the new connection wizard.
-     * 
-     * @throws Exception
-     *             the exception
+     * Tests enabled and disabled widgets, depending on the provided input.
      */
     @Test
-    public void testCreateConnection() throws Exception
+    public void testEnabledDisabledWidgets()
     {
-        // Select "Connections" view, ensure no connections exists yet
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        assertEquals( 0, connectionsTree.rowCount() );
+        assertTrue( wizardBot.isVisible() );
 
-        // open "New Connection" wizard
-        SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
-        newConnectionMenu.click();
+        // ensure "Next >" and "Finish" buttons are disabled
+        assertFalse( wizardBot.isBackButtonEnabled() );
+        assertFalse( wizardBot.isNextButtonEnabled() );
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
 
-        // get buttons
-        SWTBotButton backButton = bot.button( "< Back" );
-        SWTBotButton nextButton = bot.button( "Next >" );
-        SWTBotButton finishButton = bot.button( "Finish" );
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        // ensure "Next >" button is enabled
+        assertFalse( wizardBot.isBackButtonEnabled() );
+        assertTrue( wizardBot.isNextButtonEnabled() );
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        // clear host
+        wizardBot.typeHost( "" );
+        // ensure "Next >" is disabled
+        assertFalse( wizardBot.isBackButtonEnabled() );
+        assertFalse( wizardBot.isNextButtonEnabled() );
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        // enter host again
+        wizardBot.typeHost( "localhost" );
+        // ensure "Next >" button is enabled
+        assertFalse( wizardBot.isBackButtonEnabled() );
+        assertTrue( wizardBot.isNextButtonEnabled() );
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        wizardBot.clickNextButton();
+
+        // check default settings
+        assertTrue( wizardBot.isSimpleAuthenticationSelected() );
+        assertTrue( wizardBot.isUserEnabled() );
+        assertTrue( wizardBot.isPasswordEnabled() );
+        assertFalse( wizardBot.isRealmEnabled() );
+        assertTrue( wizardBot.isSavePasswordSelected() );
+        // ensure "<Back" is enabled, "Next >" and "Finish" is disabled
+        assertTrue( wizardBot.isBackButtonEnabled() );
+        assertFalse( wizardBot.isNextButtonEnabled() );
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
 
-        // 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( ldapService.getPort() ) );
-
-        // ensure "Next >" button is enabled, "Finish" button is disabled
-        assertFalse( backButton.isEnabled() );
-        assertTrue( nextButton.isEnabled() );
-        assertFalse( finishButton.isEnabled() );
+        // enter authentication parameters
+        wizardBot.selectSimpleAuthentication();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+        // ensure "<Back" is enabled, "Next >" and "Finish" is enabled
+        assertTrue( wizardBot.isBackButtonEnabled() );
+        assertTrue( wizardBot.isNextButtonEnabled() );
+        assertTrue( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        // clear user
+        wizardBot.typeUser( "" );
+        // ensure "<Back" is enabled, "Next >" and "Finish" is disabled
+        assertTrue( wizardBot.isBackButtonEnabled() );
+        assertFalse( wizardBot.isNextButtonEnabled() );
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        // enter user again 
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        // ensure "<Back" is enabled, "Next >" and "Finish" is enabled
+        assertTrue( wizardBot.isBackButtonEnabled() );
+        assertTrue( wizardBot.isNextButtonEnabled() );
+        assertTrue( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        // deselect password save
+        wizardBot.deselectSavePassword();
+        // ensure password field is disabled
+        assertFalse( wizardBot.isPasswordEnabled() );
+
+        // select password save
+        wizardBot.selectSavePassword();
+        // ensure password field is enabled
+        assertTrue( wizardBot.isPasswordEnabled() );
+
+        // select no authentication
+        wizardBot.selectNoAuthentication();
+        // ensure authentication parameter input fields are disabled
+        assertTrue( wizardBot.isNoAuthenticationSelected() );
+        assertFalse( wizardBot.isUserEnabled() );
+        assertFalse( wizardBot.isPasswordEnabled() );
+        assertFalse( wizardBot.isRealmEnabled() );
+        assertFalse( wizardBot.isSavePasswordEnabled() );
+
+        // select DIGEST-MD5
+        wizardBot.selectDigestMD5Authentication();
+        // ensure authentication parameter input fields are enabled, including SASL Realm field
+        assertTrue( wizardBot.isDigestMD5AuthenticationSelected() );
+        assertTrue( wizardBot.isUserEnabled() );
+        assertTrue( wizardBot.isPasswordEnabled() );
+        assertTrue( wizardBot.isRealmEnabled() );
+        assertTrue( wizardBot.isSavePasswordEnabled() );
+
+        // select CRAM-MD5
+        wizardBot.selectCramMD5Authentication();
+        // ensure authentication parameter input fields are enabled, excluding SASL Realm field
+        assertTrue( wizardBot.isCramMD5AuthenticationSelected() );
+        assertTrue( wizardBot.isUserEnabled() );
+        assertTrue( wizardBot.isPasswordEnabled() );
+        assertFalse( wizardBot.isRealmEnabled() );
+        assertTrue( wizardBot.isSavePasswordEnabled() );
+
+        wizardBot.clickNextButton();
+
+        // check default settings
+        assertTrue( wizardBot.isGetBaseDnsFromRootDseSelected() );
+        assertFalse( wizardBot.isBaseDnEnabled() );
+        // ensure "<Back" and "Finish" is enabled, "Next >" disabled
+        assertTrue( wizardBot.isBackButtonEnabled() );
+        assertFalse( wizardBot.isNextButtonEnabled() );
+        assertTrue( wizardBot.isFinishButtonEnabled() );
+        assertTrue( wizardBot.isCancelButtonEnabled() );
+
+        // deselect get base DNs from Root DSE
+        wizardBot.deselectGetBaseDnsFromRootDse();
+        assertFalse( wizardBot.isGetBaseDnsFromRootDseSelected() );
+        assertTrue( wizardBot.isBaseDnEnabled() );
+
+        // select get base DNs from Root DSE
+        wizardBot.selectGetBaseDnsFromRootDse();
+        assertTrue( wizardBot.isGetBaseDnsFromRootDseSelected() );
+        assertFalse( wizardBot.isBaseDnEnabled() );
 
-        // jump to auth page
-        nextButton.click();
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Creates a new connection using the new connection wizard.
+     */
+    @Test
+    public void testCreateConnection()
+    {
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
 
-        // 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.comboBoxInGroup( "Authentication Method" );
-        assertEquals( "Simple Authentication", authMethodCombo.selection() );
+        // jump to auth page
+        wizardBot.clickNextButton();
 
         // 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() );
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
 
         // finish dialog
-        finishButton.click();
-        bot.sleep( 2000 );
+        wizardBot.clickFinishButton();
+        connectionsViewBot.waitForConnection( "NewConnectionWizardTest" );
 
         // ensure connection was created
         ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
@@ -161,114 +337,815 @@
         assertEquals( "secret", connection.getBindPassword() );
 
         // ensure connection is visible in Connections view
-        assertEquals( 1, connectionsTree.rowCount() );
+        assertEquals( 1, connectionsViewBot.getConnectionCount() );
 
         // close connection
-        connectionsTree.select( "NewConnectionWizardTest" );
-        SWTBotMenu contextMenu = connectionsTree.contextMenu( "Close Connection" );
-        contextMenu.click();
+        connectionsViewBot.closeSelectedConnections();
     }
 
 
     /**
      * Tests the "Check Network Parameter" button.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testCheckNetworkParameterButtonOK() throws Exception
+    public void testCheckNetworkParameterButtonOK()
     {
-        // Select "Connections" view, ensure no connections exists yet
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        assertEquals( 0, connectionsTree.rowCount() );
+        // enter connection parameter with host name
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
 
-        // open "New Connection" wizard
-        SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
-        newConnectionMenu.click();
+        // click "Check Network Parameter" button
+        String result1 = wizardBot.clickCheckNetworkParameterButton();
+        assertNull( "Expected OK", result1 );
 
-        // 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( ldapService.getPort() ) );
+        // enter connection parameter with IPv4 address
+        wizardBot.typeHost( "127.0.0.1" );
+        wizardBot.typePort( ldapService.getPort() );
 
         // click "Check Network Parameter" button
-        SWTBotButton checkButton = bot.button( "Check Network Parameter" );
-        checkButton.click();
-        bot.sleep( 1000 );
-        bot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.activeShell().getText().equals( "Check Network Parameter" ) && bot.button( "OK" ) != null;
-            }
+        String result2 = wizardBot.clickCheckNetworkParameterButton();
+        assertNull( "Expected OK", result2 );
+
+        //
+        // Don't know why this doesn't work with SWTBot.
+        // When testing manually it works.
+        //
+        // // enter connection parameter with IPv6 address
+        // wizardBot.typeHost( "[::1]" );
+        // wizardBot.typePort( ldapService.getPort() );
+        //
+        // // click "Check Network Parameter" button
+        // String result3 = wizardBot.clickCheckNetworkParameterButton();
+        // assertNull( "Expected OK", result3 );
+
+        wizardBot.clickCancelButton();
+    }
 
 
-            public String getFailureMessage()
-            {
-                return "Expected an dialog box 'Check Network Parameter' with an 'OK' button.";
-            }
-        } );
+    /**
+     * Tests the "Check Network Parameter" button.
+     */
+    @Test
+    public void testCheckNetworkParameterButtonNotOK()
+    {
+        // enter connection parameter with invalid port
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        int port = ldapService.getPort() + 1;
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( port );
+
+        // click "Check Network Parameter" button and get the result
+        String result1 = wizardBot.clickCheckNetworkParameterButton();
+        assertNotNull( "Expected Error", result1 );
+        assertTrue( "'Connection refused' message must occur in error message", result1.contains( "Connection refused" ) );
+        assertTrue( "Invalid port number must occur in error message", result1.contains( "" + port ) );
+
+        // enter connection parameter with invalid host name
+        String hostname = "qwertzuiop.asdfghjkl.yxcvbnm";
+        wizardBot.typeHost( hostname );
+        wizardBot.typePort( ldapService.getPort() );
+
+        // click "Check Network Parameter" button and get the result
+        String result2 = wizardBot.clickCheckNetworkParameterButton();
+        assertNotNull( "Expected Error", result2 );
+        assertTrue( "'Unknown Host' message must occur in error message", result2.contains( "Unknown Host" ) );
+        assertTrue( "Unknown host name must occur in error message", result2.contains( hostname ) );
+
+        // enter connection parameter with non-routed IP address
+        String ipAddress = "10.11.12.13";
+        wizardBot.typeHost( ipAddress );
+        wizardBot.typePort( ldapService.getPort() );
+
+        // click "Check Network Parameter" button and get the result
+        String result3 = wizardBot.clickCheckNetworkParameterButton();
+        assertNotNull( "Expected Error", result3 );
+        assertTrue( "'No route to host' message must occur in error message", result3.contains( "No route to host" ) );
+        assertTrue( "IP address must occur in error message", result3.contains( ipAddress ) );
 
-        bot.button( "OK" ).click();
-        bot.button( "Cancel" ).click();
+        wizardBot.clickCancelButton();
     }
 
 
     /**
      * Tests the "Check Network Parameter" button.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testCheckNetworkParameterButtonNOK() throws Exception
+    public void testCheckAuthenticationButtonOK()
     {
-        // we expect the error dialog here, so set flag to false
-        boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
-        ErrorDialog.AUTOMATED_MODE = false;
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.clickNextButton();
+
+        // enter correct authentication parameter
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // click "Check Network Parameter" button
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK", result );
 
-        // Select "Connections" view, ensure no connections exists yet
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        assertEquals( 0, connectionsTree.rowCount() );
+        wizardBot.clickCancelButton();
+    }
 
-        // open "New Connection" wizard
-        SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
-        newConnectionMenu.click();
 
+    /**
+     * Tests the "Check Authentication" button.
+     */
+    @Test
+    public void testCheckAuthenticationButtonNotOK()
+    {
         // 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( ldapService.getPort() + 1 ) );
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.clickNextButton();
+
+        // enter incorrect authentication parameter
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret45" );
 
         // click "Check Network Parameter" button
-        SWTBotButton checkButton = bot.button( "Check Network Parameter" );
-        checkButton.click();
-        bot.sleep( 1000 );
-        bot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.activeShell().getText().equals( "Error" ) && bot.button( "OK" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Expected an dialog box 'Error' with an 'OK' button.";
-            }
-        } );
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNotNull( "Expected Error", result );
+        assertTrue( "'error code 49' message must occur in error message", result.contains( "error code 49" ) );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests StartTLS with an valid certificate. This is simulated 
+     * by putting the self-signed certificate into a temporary key store
+     * and using this key store for JNDI
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateValidationOK() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=localhost", "cn=localhost", startDate, endDate );
+
+        // prepare key store
+        installKeyStoreWithCertificate();
+
+        // let JNDI use the key store
+        System.setProperty( "javax.net.ssl.trustStore", ksFile.getAbsolutePath() );
+        System.setProperty( "javax.net.ssl.keyStore", ksFile.getAbsolutePath() );
+        System.setProperty( "javax.net.ssl.keyStorePassword", "changeit" );
+
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+
+        // check the certificate, should be OK
+        String result = wizardBot.clickCheckNetworkParameterButton();
+        assertNull( "Expected OK, valid and trusted certificate", result );
+
+        // enter correct authentication parameter
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check the certificate again, should be OK
+        String result2 = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK, valid and trusted certificate", result2 );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests StartTLS with an expired certificate.
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateValidationExpired() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        updateCertificate( "cn=localhost", "cn=localhost", startDate, endDate );
+
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+
+        // check the certificate, expecting the trust dialog
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isSelfSigned() );
+        assertTrue( trustDialogBot.isExpired() );
+        assertFalse( trustDialogBot.isNotYetValid() );
+        assertFalse( trustDialogBot.isHostNameMismatch() );
+        assertFalse( trustDialogBot.isIssuerUnkown() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        assertTrue( errorBot.getErrorMessage().contains( "Untrusted certificate" ) );
+        errorBot.clickOkButton();
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests SSL with an not yet valid certificate.
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateValidationNotYetValid() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS + YEAR_MILLIS );
+        updateCertificate( "cn=localhost", "cn=localhost", startDate, endDate );
+
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+
+        // check the certificate, expecting the trust dialog
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isSelfSigned() );
+        assertTrue( trustDialogBot.isNotYetValid() );
+        assertFalse( trustDialogBot.isExpired() );
+        assertFalse( trustDialogBot.isHostNameMismatch() );
+        assertFalse( trustDialogBot.isIssuerUnkown() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        assertTrue( errorBot.getErrorMessage().contains( "Untrusted certificate" ) );
+        errorBot.clickOkButton();
+
+        wizardBot.clickCancelButton();
+    }
 
-        bot.button( "OK" ).click();
-        bot.button( "Cancel" ).click();
 
-        // reset flag
-        ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
+    /**
+     * Tests StartTLS with an invalid certificate (unknown issuer).
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateValidationIssuerUnknown() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost", startDate, endDate );
+
+        // enter connection parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+
+        // check the certificate, expecting the trust dialog
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isIssuerUnkown() );
+        assertFalse( trustDialogBot.isHostNameMismatch() );
+        assertFalse( trustDialogBot.isSelfSigned() );
+        assertFalse( trustDialogBot.isNotYetValid() );
+        assertFalse( trustDialogBot.isExpired() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        assertTrue( errorBot.getErrorMessage().contains( "Untrusted certificate" ) );
+        errorBot.clickOkButton();
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests StartTLS with an certificate, where the certificate's host name
+     * doesn't match the server's host name (localhost)
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateValidationHostnameMismatch() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=ldap.example.com", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check the certificate, expecting the trust dialog
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isHostNameMismatch() );
+        assertTrue( trustDialogBot.isIssuerUnkown() );
+        assertFalse( trustDialogBot.isSelfSigned() );
+        assertFalse( trustDialogBot.isNotYetValid() );
+        assertFalse( trustDialogBot.isExpired() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        assertTrue( errorBot.getErrorMessage().contains( "Untrusted certificate" ) );
+        errorBot.clickOkButton();
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests that when selecting "Don't trust" the certificate is not trusted
+     * and not added to any key store.
+     *
+     * @throws Exception
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateDontTrust() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+
+        // check trust, expect trust dialog, select don't trust
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        // check trust again, expect trust dialog, select don't trust
+        trustDialogBot = wizardBot.clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        // certificate must not be added to a trust store
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+
+        // enter authentication parameter
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check trust again, expect trust dialog, select don't trust
+        trustDialogBot = wizardBot.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        // click finish, that opens the connection
+        wizardBot.clickFinishButton();
+
+        // expecting trust dialog again.
+        trustDialogBot = new CertificateTrustDialogBot();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+    }
+
+
+    /**
+     * Tests that when selecting "Trust temporary" the certificate is trusted
+     * and added to the session key store.
+     *
+     * @throws Exception
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateTrustTemporary() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost2", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check trust, expect trust dialog, select trust temporary
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectTrustTemporary();
+        trustDialogBot.clickOkButton();
+
+        // TODO: expect ok dialog
+        trustDialogBot.clickOkButton();
+
+        // certificate must be added to the temporary trust store
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 1, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+
+        // check trust again, now the certificate is already trusted
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK, valid and trusted certificate", result );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests that when selecting "Trust permanent" the certificate is trusted
+     * and added to the permanent key store.
+     *
+     * @throws Exception
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testStartTlsCertificateTrustPermanent() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost3", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapService.getPort() );
+        wizardBot.selectStartTlsEncryption();
+
+        // check trust, expect trust dialog, select trust temporary
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectTrustPermanent();
+        trustDialogBot.clickOkButton();
+
+        // TODO: expect ok dialog
+        trustDialogBot.clickOkButton();
+
+        // certificate must be added to the temporary trust store
+        assertEquals( 1, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+
+        // check trust again, now the certificate is already trusted
+        String result = wizardBot.clickCheckNetworkParameterButton();
+        assertNull( "Expected OK, valid and trusted certificate", result );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests ldaps:// with an valid certificate. This is simulated 
+     * by putting the self-signed certificate into a temporary key store
+     * and using this key store for JNDI
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testLdapsCertificateValidationOK() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=localhost", "cn=localhost", startDate, endDate );
+
+        // prepare key store
+        installKeyStoreWithCertificate();
+
+        // let JNDI use the key store
+        System.setProperty( "javax.net.ssl.trustStore", ksFile.getAbsolutePath() );
+        System.setProperty( "javax.net.ssl.keyStore", ksFile.getAbsolutePath() );
+        System.setProperty( "javax.net.ssl.keyStorePassword", "changeit" );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapsService.getPort() );
+        wizardBot.selectLdapsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check the certificate, should be OK
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK, valid and trusted certificate", result );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testLdapsCertificateValidationNotOK() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS + YEAR_MILLIS );
+        updateCertificate( "cn=localhost", "cn=localhost", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapsService.getPort() );
+        wizardBot.selectLdapsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check the certificate, expecting the trust dialog
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isSelfSigned() );
+        assertTrue( trustDialogBot.isNotYetValid() );
+        assertFalse( trustDialogBot.isExpired() );
+        assertFalse( trustDialogBot.isHostNameMismatch() );
+        assertFalse( trustDialogBot.isIssuerUnkown() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        assertTrue( errorBot.getErrorMessage().contains( "failed" ) );
+        errorBot.clickOkButton();
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests that when selecting "Don't trust" the certificate is not trusted
+     * and not added to any key store.
+     *
+     * @throws Exception
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testLdapsCertificateDontTrust() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost4", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapsService.getPort() );
+        wizardBot.selectLdapsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check trust, expect trust dialog, select don't trust
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        // check trust again, expect trust dialog, select don't trust
+        trustDialogBot = wizardBot.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        // certificate must not be added to a trust store
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+
+        // click finish, that opens the connection
+        wizardBot.clickFinishButton();
+
+        // expecting trust dialog again.
+        trustDialogBot = new CertificateTrustDialogBot();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectDontTrust();
+        errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
+        errorBot.clickOkButton();
+
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+    }
+
+
+    /**
+     * Tests that when selecting "Trust temporary" the certificate is trusted
+     * and added to the session key store.
+     *
+     * @throws Exception
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testLdapsCertificateTrustTemporary() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost5", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapsService.getPort() );
+        wizardBot.selectLdapsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check trust, expect trust dialog, select trust temporary
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectTrustTemporary();
+        trustDialogBot.clickOkButton();
+
+        // TODO: expect ok dialog
+        trustDialogBot.clickOkButton();
+
+        // certificate must be added to the temporary trust store
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 1, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+
+        // check trust again, now the certificate is already trusted
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK, valid and trusted certificate", result );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    /**
+     * Tests that when selecting "Trust permanent" the certificate is trusted
+     * and added to the permanent key store.
+     *
+     * @throws Exception
+     */
+    @Test
+    @Ignore // till DIRSERVER-1373 is fixed
+    public void testLdapsCertificateTrustPermanent() throws Exception
+    {
+        // prepare certificate 
+        Date startDate = new Date( System.currentTimeMillis() - YEAR_MILLIS );
+        Date endDate = new Date( System.currentTimeMillis() + YEAR_MILLIS );
+        updateCertificate( "cn=TheUnknownStuntman", "cn=localhost6", startDate, endDate );
+
+        // enter connection parameter and authentication parameter
+        wizardBot.typeConnectionName( "NewConnectionWizardTest" );
+        wizardBot.typeHost( "localhost" );
+        wizardBot.typePort( ldapsService.getPort() );
+        wizardBot.selectLdapsEncryption();
+        wizardBot.clickNextButton();
+        wizardBot.typeUser( "uid=admin,ou=system" );
+        wizardBot.typePassword( "secret" );
+
+        // check trust, expect trust dialog, select trust temporary
+        CertificateTrustDialogBot trustDialogBot = wizardBot
+            .clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
+        assertTrue( trustDialogBot.isVisible() );
+        trustDialogBot.selectTrustPermanent();
+        trustDialogBot.clickOkButton();
+
+        // TODO: expect ok dialog
+        trustDialogBot.clickOkButton();
+
+        // certificate must be added to the temporary trust store
+        assertEquals( 1, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
+        assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
+
+        // check trust again, now the certificate is already trusted
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK, valid and trusted certificate", result );
+
+        wizardBot.clickCancelButton();
+    }
+
+    /* 
+     * Eventually we have to make several of these parameters configurable,
+     * however note to pass export restrictions we must use a key size of
+     * 512 or less here as the default.  Users can configure this setting
+     * later based on their own legal situations.  This is required to 
+     * classify ApacheDS in the ECCN 5D002 category.  Please see the following
+     * page for more information:
+     * 
+     *    http://www.apache.org/dev/crypto.html
+     * 
+     * Also ApacheDS must be classified on the following page:
+     * 
+     *    http://www.apache.org/licenses/exports
+     */
+    private static final int KEY_SIZE = 512;
+    private static final long YEAR_MILLIS = 365L * 24L * 3600L * 1000L;
+    private static final String PRIVATE_KEY_AT = "privateKey";
+    private static final String PUBLIC_KEY_AT = "publicKey";
+    private static final String KEY_ALGORITHM_AT = "keyAlgorithm";
+    private static final String PRIVATE_KEY_FORMAT_AT = "privateKeyFormat";
+    private static final String PUBLIC_KEY_FORMAT_AT = "publicKeyFormat";
+    private static final String USER_CERTIFICATE_AT = "userCertificate";
+    private static final String PRINCIPAL = "uid=admin,ou=system";
+
+
+    /**
+     * 
+     */
+    private void updateCertificate( String issuerDN, String subjectDN, Date startDate, Date expiryDate )
+        throws Exception
+    {
+        LdapDN dn = new LdapDN( PRINCIPAL );
+        List<Modification> modifications = new ArrayList<Modification>();
+
+        // Get old key algorithm
+        ClonedServerEntry entry = ldapService.getDirectoryService().getAdminSession().lookup( dn );
+        String keyAlgo = entry.get( KEY_ALGORITHM_AT ).getString();
+
+        // Generate key pair
+        KeyPairGenerator generator = KeyPairGenerator.getInstance( keyAlgo );
+        generator.initialize( KEY_SIZE );
+        KeyPair keypair = generator.genKeyPair();
+
+        // Generate the private key attributes 
+        PrivateKey privateKey = keypair.getPrivate();
+        modifications.add( new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute(
+            PRIVATE_KEY_AT, privateKey.getEncoded() ) ) );
+        modifications.add( new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute(
+            PRIVATE_KEY_FORMAT_AT, privateKey.getFormat() ) ) );
+
+        // Generate public key
+        PublicKey publicKey = keypair.getPublic();
+        modifications.add( new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute(
+            PUBLIC_KEY_AT, publicKey.getEncoded() ) ) );
+        modifications.add( new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute(
+            PUBLIC_KEY_FORMAT_AT, publicKey.getFormat() ) ) );
+
+        // Generate the self-signed certificate
+        BigInteger serialNumber = BigInteger.valueOf( System.currentTimeMillis() );
+        X509V1CertificateGenerator certGen = new X509V1CertificateGenerator();
+        X500Principal issuerName = new X500Principal( issuerDN );
+        X500Principal subjectName = new X500Principal( subjectDN );
+        certGen.setSerialNumber( serialNumber );
+        certGen.setIssuerDN( issuerName );
+        certGen.setNotBefore( startDate );
+        certGen.setNotAfter( expiryDate );
+        certGen.setSubjectDN( subjectName );
+        certGen.setPublicKey( publicKey );
+        certGen.setSignatureAlgorithm( "SHA1With" + keyAlgo );
+        X509Certificate cert = certGen.generate( privateKey, "BC" );
+        modifications.add( new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute(
+            USER_CERTIFICATE_AT, cert.getEncoded() ) ) );
+
+        // Write the modifications
+        ldapService.getDirectoryService().getAdminSession().modify( dn, modifications );
+        
+        // TODO: activate when DIRSERVER-1373 is fixed
+        //ldapService.reloadSslContext();
+        //ldapsService.reloadSslContext();
+    }
+
+
+    private void installKeyStoreWithCertificate() throws Exception
+    {
+        if ( ksFile != null && ksFile.exists() )
+        {
+            ksFile.delete();
+        }
+        ksFile = File.createTempFile( "testStore", "ks" );
+
+        CoreSession session = ldapService.getDirectoryService().getAdminSession();
+        ClonedServerEntry entry = session.lookup( new LdapDN( "uid=admin,ou=system" ), new String[]
+            { USER_CERTIFICATE_AT } );
+        byte[] userCertificate = entry.get( USER_CERTIFICATE_AT ).getBytes();
+        assertNotNull( userCertificate );
+
+        ByteArrayInputStream in = new ByteArrayInputStream( userCertificate );
+        CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
+        Certificate cert = factory.generateCertificate( in );
+        KeyStore ks = KeyStore.getInstance( KeyStore.getDefaultType() );
+        ks.load( null, null );
+        ks.setCertificateEntry( "apacheds", cert );
+        ks.store( new FileOutputStream( ksFile ), "changeit".toCharArray() );
     }
 }

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java?rev=782255&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java Sat Jun  6 13:11:11 2009
@@ -0,0 +1,89 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+
+
+public class BotUtils
+{
+    private static SWTBot bot = new SWTBot();
+
+
+    /**
+     * Waits for a shell with any of the given labels.
+     *
+     * @param labels
+     * @return
+     */
+    static SWTBotShell shell( final Runnable runnable, final String... labels )
+    {
+        // we expect the error dialog here, so set flag to false
+        boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
+        ErrorDialog.AUTOMATED_MODE = false;
+
+        try
+        {
+            runnable.run();
+            bot.waitUntil( new DefaultCondition()
+            {
+                public boolean test() throws Exception
+                {
+                    String shellText = bot.activeShell().getText();
+                    for ( String label : labels )
+                    {
+                        if ( shellText.equals( label ) && bot.button( "OK" ) != null )
+                        {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+
+
+                public String getFailureMessage()
+                {
+                    List<String> asList = Arrays.asList( labels );
+                    return "Expected a dialog with any label " + asList + " with an 'OK' button.";
+                }
+            } );
+        }
+        finally
+        {
+            // reset flag
+            ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
+        }
+
+        return bot.activeShell();
+    }
+
+
+    public static void sleep( long millis )
+    {
+        bot.sleep( millis );
+    }
+}

Propchange: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java?rev=782255&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java Sat Jun  6 13:11:11 2009
@@ -0,0 +1,145 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel;
+
+
+public class CertificateTrustDialogBot extends DialogBot
+{
+
+    public boolean isVisible()
+    {
+        return super.isVisible( "Certificate Trust" );
+    }
+
+
+    public boolean isSelfSigned()
+    {
+        return isErrorMessage( "self-signed" );
+    }
+
+
+    public boolean isHostNameMismatch()
+    {
+        return isErrorMessage( "host name" );
+    }
+
+
+    public boolean isExpired()
+    {
+        return isErrorMessage( "expired" );
+    }
+
+
+    public boolean isNotYetValid()
+    {
+        return isErrorMessage( "not yet valid" );
+    }
+
+
+    public boolean isIssuerUnkown()
+    {
+        return isErrorMessage( "issuer certificate is unknown" );
+    }
+
+
+    private boolean isErrorMessage( String needle )
+    {
+        List<String> errorMessages = getErrorMessages();
+        for ( String string : errorMessages )
+        {
+            if ( string.contains( needle ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    private List<String> getErrorMessages()
+    {
+        List<String> messages = new ArrayList<String>();
+
+        for ( int i = 1;; i++ )
+        {
+            SWTBotLabel label = bot.label( i );
+            if ( label.getText().startsWith( "-" ) )
+            {
+                messages.add( label.getText() );
+            }
+            else
+            {
+                break;
+            }
+        }
+
+        return messages;
+    }
+
+
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+
+
+    protected void clickViewCertificateButton()
+    {
+        super.clickButton( "View Certificate..." );
+    }
+
+
+    public void selectDontTrust()
+    {
+        bot.radio( "Don't trust this certificate." ).click();
+    }
+
+
+    public void selectTrustTemporary()
+    {
+        bot.radio( "Trust this certificate for this session." ).click();
+    }
+
+
+    public void selectTrustPermanent()
+    {
+        bot.radio( "Always trust this certificate." ).click();
+    }
+
+
+    public ErrorDialogBot clickOkButtonExpectingErrorDialog()
+    {
+        BotUtils.shell( new Runnable()
+        {
+            public void run()
+            {
+                clickOkButton();
+            }
+        }, "Error", "Problem Occurred" );
+
+        return new ErrorDialogBot();
+    }
+}

Propchange: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java?rev=782255&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java Sat Jun  6 13:11:11 2009
@@ -0,0 +1,91 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import org.apache.directory.studio.test.integration.ui.ContextMenuHelper;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+
+public class ConnectionsViewBot
+{
+    private SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+
+    public NewConnectionWizardBot openNewConnectionWizard()
+    {
+        ContextMenuHelper.clickContextMenu( getConnectionsTree(), "New Connection..." );
+        return new NewConnectionWizardBot();
+    }
+
+
+    public void closeSelectedConnections()
+    {
+        getConnectionsTree().contextMenu( "Close Connection" ).click();
+    }
+
+
+    public int getConnectionCount()
+    {
+        return getConnectionsTree().rowCount();
+    }
+
+
+    private SWTBotTree getConnectionsTree()
+    {
+        SWTBotView view = bot.viewByTitle( "Connections" );
+        view.show();
+        SWTBotTree tree = view.bot().tree();
+        return tree;
+    }
+
+
+    public void waitForConnection( final String connectionName )
+    {
+        bot.waitUntil( new DefaultCondition()
+        {
+
+            public boolean test() throws Exception
+            {
+                for ( SWTBotTreeItem item : getConnectionsTree().getAllItems() )
+                {
+                    String text = item.getText();
+                    if ( text.startsWith( connectionName ) )
+                    {
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Connection " + connectionName + " not visible in connectoins view.";
+            }
+        } );
+
+    }
+
+}

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java?rev=782255&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java Sat Jun  6 13:11:11 2009
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+
+
+public abstract class DialogBot
+{
+
+    protected SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+
+    protected boolean isVisible( String dialogTitle )
+    {
+        return bot.shell( dialogTitle ).isVisible();
+    }
+
+
+    protected void clickButton( String buttonTitle )
+    {
+        bot.button( buttonTitle ).click();
+    }
+
+}

Propchange: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java?rev=782255&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java Sat Jun  6 13:11:11 2009
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+public class ErrorDialogBot extends DialogBot
+{
+
+    public String getErrorMessage()
+    {
+        return bot.label( 1 ).getText();
+    }
+
+
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+
+}

Propchange: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message