directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r888751 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: ApacheDSPluginTest.java bots/ApacheDSServersViewBot.java bots/DeleteDialogBot.java
Date Wed, 09 Dec 2009 09:50:38 GMT
Author: pamarcelot
Date: Wed Dec  9 09:50:37 2009
New Revision: 888751

URL: http://svn.apache.org/viewvc?rev=888751&view=rev
Log:
Added a full house test for the Apache DS plugin:
  - create server
  - start server
  - stop server
  - delete server

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/DeleteDialogBot.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=888751&r1=888750&r2=888751&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
Wed Dec  9 09:50:37 2009
@@ -21,7 +21,13 @@
 package org.apache.directory.studio.test.integration.ui;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.studio.apacheds.model.ServersHandler;
 import org.apache.directory.studio.test.integration.ui.bots.ApacheDSServersViewBot;
+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.junit.Before;
@@ -49,23 +55,46 @@
     }
 
 
+    /**
+     * Run the following tests:
+     * <ul>
+     *      <li>Creates a new server</li>
+     *      <li>Runs the server</li>
+     *      <li>Stops the server (after waiting for the server to be completely started)</li>
+     *      <li>Deletes the server</li>
+     * </ul>
+     */
     @Test
-    public void basicTest() throws InterruptedException
+    public void serverCreationAndDeletion()
     {
         // 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 );
@@ -74,6 +103,30 @@
         serversViewBot.stopServer( serverName );
         serversViewBot.waitForServerStop( serverName );
 
-        // Ensure the server was created
+        // 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
+     *      the servers count found in the core of the plugin
+     */
+    public int getCoreServersCount()
+    {
+        ServersHandler serversHandler = ServersHandler.getDefault();
+        if ( serversHandler != null )
+        {
+            return serversHandler.getServersList().size();
+        }
+
+        return 0;
     }
 }

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=888751&r1=888750&r2=888751&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
Wed Dec  9 09:50:37 2009
@@ -44,12 +44,21 @@
     }
 
 
+    /**
+     * Shows the view.
+     */
     public void show()
     {
         view.show();
     }
 
 
+    /**
+     * Opens the 'New Server' wizard.
+     *
+     * @return
+     *      a bot associated with the 'New Server' wizard
+     */
     public NewApacheDSServerWizardBot openNewServerWizard()
     {
         ContextMenuHelper.clickContextMenu( getServersTree(), "New", "New &Server" );
@@ -57,6 +66,25 @@
     }
 
 
+    /**
+     * Opens the 'Delete' dialog.
+     *
+     * @return
+     *      a bot associated with the 'Delete' dialog
+     */
+    public DeleteDialogBot openDeleteServerDialog()
+    {
+        ContextMenuHelper.clickContextMenu( getServersTree(), "Delete" );
+        return new DeleteDialogBot( DeleteDialogBot.DELETE_SERVER );
+    }
+
+
+    /**
+     * Gets the tree associated with the 'Servers' view.
+     *
+     * @return
+     *      the tree associated with the 'Servers' view
+     */
     private SWTBotTree getServersTree()
     {
         view.show();
@@ -65,12 +93,24 @@
     }
 
 
+    /**
+     * Selects the server associated with the given name.
+     *
+     * @param serverName
+     *      the name of the server
+     */
     public void selectServer( String serverName )
     {
         getServersTree().select( serverName );
     }
 
 
+    /**
+     * Starts the server associated with the given name.
+     *
+     * @param serverName
+     *      the name of the server
+     */
     public void runServer( String serverName )
     {
         getServersTree().select( serverName );
@@ -78,6 +118,12 @@
     }
 
 
+    /**
+     * Stops the server associated with the given name.
+     *
+     * @param serverName
+     *      the name of the server
+     */
     public void stopServer( String serverName )
     {
         getServersTree().select( serverName );
@@ -85,6 +131,13 @@
     }
 
 
+    /**
+     * Waits until the server associated with the given name appears in 
+     * the 'servers' view.
+     *
+     * @param serverName
+     *      the name of the server
+     */
     public void waitForServer( final String serverName )
     {
         bot.waitUntil( new DefaultCondition()
@@ -111,6 +164,12 @@
     }
 
 
+    /**
+     * Waits until the server associated with the given name is started.
+     *
+     * @param serverName
+     *      the server name
+     */
     public void waitForServerStart( final String serverName )
     {
         bot.waitUntil( new DefaultCondition()
@@ -135,6 +194,12 @@
     }
 
 
+    /**
+     * Waits until the server associated with the given name is stopped.
+     *
+     * @param serverName
+     *      the name of the server
+     */
     public void waitForServerStop( final String serverName )
     {
         bot.waitUntil( new DefaultCondition()
@@ -159,6 +224,15 @@
     }
 
 
+    /**
+     * Gets the server associated with the given name.
+     *
+     * @param serverName
+     *      the name of the server
+     * @return
+     *      the server associated with the given name,
+     *      or <code>null</code> if none was found.
+     */
     private Server getServer( String serverName )
     {
         for ( Server server : ServersHandler.getDefault().getServersList() )
@@ -171,4 +245,22 @@
 
         return null;
     }
+
+
+    /**
+     * Gets the servers count found in the 'Servers' view.
+     *
+     * @return
+     *      the servers count found in the 'Servers' view
+     */
+    public int getServersCount()
+    {
+        SWTBotTree tree = getServersTree();
+        if ( tree != null )
+        {
+            return tree.rowCount();
+        }
+
+        return 0;
+    }
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java?rev=888751&r1=888750&r2=888751&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
Wed Dec  9 09:50:37 2009
@@ -25,6 +25,7 @@
     public static final String DELETE_ENTRY_TITLE = "Delete Entry";
     public static final String DELETE_ENTRIES_TITLE = "Delete Entries";
     public static final String DELETE_VALUE_TITLE = "Delete Value";
+    public static final String DELETE_SERVER = "Delete Server";
     private String title;
 
 
@@ -50,5 +51,4 @@
     {
         super.clickButton( "Cancel" );
     }
-
 }



Mime
View raw message