directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r889134 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: ./ bots/
Date Thu, 10 Dec 2009 08:27:01 GMT
Author: pamarcelot
Date: Thu Dec 10 08:26:59 2009
New Revision: 889134

URL: http://svn.apache.org/viewvc?rev=889134&view=rev
Log:
Added one last test to verify the creation of a connection associated to a server. The connection
is also verified in the browser.

Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java
Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java?rev=889134&r1=889133&r2=889134&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
Thu Dec 10 08:26:59 2009
@@ -26,10 +26,19 @@
 import static org.junit.Assert.assertTrue;
 
 import org.apache.directory.studio.apacheds.model.ServersHandler;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.core.ConnectionFolder;
+import org.apache.directory.studio.connection.core.ConnectionFolderManager;
+import org.apache.directory.studio.connection.core.ConnectionManager;
 import org.apache.directory.studio.test.integration.ui.bots.ApacheDSServersViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.ConnectionFromServerDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.NewApacheDSServerWizardBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -44,6 +53,7 @@
 {
     private StudioBot studioBot;
     private ApacheDSServersViewBot serversViewBot;
+    private ConnectionsViewBot connectionsViewBot;
 
 
     @Before
@@ -52,6 +62,7 @@
         studioBot = new StudioBot();
         studioBot.resetLdapPerspective();
         serversViewBot = studioBot.getApacheDSServersViewBot();
+        connectionsViewBot = studioBot.getConnectionView();
     }
 
 
@@ -178,6 +189,90 @@
 
 
     /**
+     * Checks the creation of a connection from a server.
+     */
+    @Test
+    public void connectionCreationFromServer()
+    {
+        // Showing view
+        serversViewBot.show();
+
+        // Verifying the servers count is 0
+        assertEquals( 0, getCoreServersCount() );
+        assertEquals( 0, serversViewBot.getServersCount() );
+
+        // Opening wizard
+        NewApacheDSServerWizardBot wizardBot = serversViewBot.openNewServerWizard();
+
+        // Verifying the wizard can't be finished yet
+        assertFalse( wizardBot.isFinishButtonEnabled() );
+
+        // Filling fields of the wizard
+        String serverName = "NewServerWizardTest";
+        wizardBot.typeServerName( serverName );
+
+        // Verifying the wizard can now be finished
+        assertTrue( wizardBot.isFinishButtonEnabled() );
+
+        // Closing wizard
+        wizardBot.clickFinishButton();
+        serversViewBot.waitForServer( serverName );
+
+        // Verifying the servers count is now 1
+        assertEquals( 1, getCoreServersCount() );
+        assertEquals( 1, serversViewBot.getServersCount() );
+
+        // Starting the server
+        serversViewBot.runServer( serverName );
+        serversViewBot.waitForServerStart( serverName );
+
+        // Verifying the connections count is 0
+        assertEquals( 0, getBrowserConnectionsCount() );
+
+        // Creating a connection associated with the server
+        ConnectionFromServerDialogBot connectionFromServerDialogBot = serversViewBot.createConnectionFromServer();
+        connectionFromServerDialogBot.clickOkButton();
+
+        // Verifying the connections count is now 1
+        assertEquals( 1, getBrowserConnectionsCount() );
+
+        // Opening the connection
+        connectionsViewBot.selectConnection( serverName );
+        connectionsViewBot.openSelectedConnection();
+
+        // Getting the associated connection object
+        Connection connection = getBrowserConnection();
+
+        // Checking if the connection is open
+        waitForConnectionOpened( connection );
+        assertTrue( connection.getJNDIConnectionWrapper().isConnected() );
+
+        // Closing the connection
+        connectionsViewBot.selectConnection( serverName );
+        connectionsViewBot.closeSelectedConnections();
+
+        // Checking if the connection is closed
+        waitForConnectionClosed( connection );
+        assertFalse( connection.getJNDIConnectionWrapper().isConnected() );
+
+        // Deleting the connection
+        connectionsViewBot.deleteTestConnections();
+
+        // Stopping the server
+        serversViewBot.stopServer( serverName );
+        serversViewBot.waitForServerStop( serverName );
+
+        // Deleting the server
+        DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
+        deleteDialogBot.clickOkButton();
+
+        // Verifying the servers count is back to 0
+        assertEquals( 0, getCoreServersCount() );
+        assertEquals( 0, serversViewBot.getServersCount() );
+    }
+
+
+    /**
      * Gets the servers count found in the core of the plugin.
      *
      * @return
@@ -193,4 +288,99 @@
 
         return 0;
     }
+
+
+    /**
+     * Get the connections count found in the LDAP Browser.
+     *
+     * @return
+     *      the connections count found in the LDAP Browser
+     */
+    public int getBrowserConnectionsCount()
+    {
+        ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
+            .getConnectionFolderManager();
+        if ( connectionFolderManager != null )
+        {
+            ConnectionFolder rootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
+            if ( rootConnectionFolder != null )
+            {
+                return rootConnectionFolder.getConnectionIds().size();
+            }
+        }
+
+        return 0;
+    }
+
+
+    /**
+     * Get the connections count found in the LDAP Browser.
+     *
+     * @return
+     *      the connections count found in the LDAP Browser
+     */
+    public Connection getBrowserConnection()
+    {
+        ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
+            .getConnectionFolderManager();
+        ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
+        if ( connectionFolderManager != null )
+        {
+            ConnectionFolder rootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
+            if ( rootConnectionFolder != null )
+            {
+                return connectionManager.getConnectionById( rootConnectionFolder.getConnectionIds().get(
0 ) );
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Waits until the given connection is opened.
+     *
+     * @param connection
+     *      the connection
+     */
+    public void waitForConnectionOpened( final Connection connection )
+    {
+        new SWTWorkbenchBot().waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return connection.getJNDIConnectionWrapper().isConnected();
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Connection " + connection.getName() + " not opened in connections
view.";
+            }
+        } );
+    }
+
+
+    /**
+     * Waits until the given connection is closed.
+     *
+     * @param connection
+     *      the connection
+     */
+    public void waitForConnectionClosed( final Connection connection )
+    {
+        new SWTWorkbenchBot().waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return !connection.getJNDIConnectionWrapper().isConnected();
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Connection " + connection.getName() + " not closed in connections
view.";
+            }
+        } );
+    }
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java?rev=889134&r1=889133&r2=889134&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java
Thu Dec 10 08:26:59 2009
@@ -67,6 +67,19 @@
 
 
     /**
+     * Opens the 'LDAP Browser' > 'Create a Connection' action of the context menu.
+     *
+     * @return
+     *      a bot associated with the dialog
+     */
+    public ConnectionFromServerDialogBot createConnectionFromServer()
+    {
+        ContextMenuHelper.clickContextMenu( getServersTree(), "LDAP Browser", "Create a Connection"
);
+        return new ConnectionFromServerDialogBot();
+    }
+
+
+    /**
      * Opens the 'Delete' dialog.
      *
      * @return

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java?rev=889134&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java
Thu Dec 10 08:26:59 2009
@@ -0,0 +1,29 @@
+/*
+ *  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 ConnectionFromServerDialogBot extends DialogBot
+{
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+}

Modified: 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=889134&r1=889133&r2=889134&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
Thu Dec 10 08:26:59 2009
@@ -51,6 +51,11 @@
         return new NewConnectionWizardBot();
     }
 
+    public void openSelectedConnection()
+    {
+        getConnectionsTree().contextMenu( "Open Connection" ).click();
+    }
+    
 
     public void closeSelectedConnections()
     {



Mime
View raw message