directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r683169 - /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/
Date Wed, 06 Aug 2008 08:43:14 GMT
Author: seelmann
Date: Wed Aug  6 01:43:13 2008
New Revision: 683169

URL: http://svn.apache.org/viewvc?rev=683169&view=rev
Log:
Fixed race conditions in tests. When expanding a node in the browser tree we fetch the entries
in a background thread. Added some wait conditions to make sure we wait till the child entries
are initialized.

Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java

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=683169&r1=683168&r2=683169&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
Wed Aug  6 01:43:13 2008
@@ -227,21 +227,20 @@
         // click "Check Network Parameter" button
         SWTBotButton checkButton = bot.button( "Check Network Parameter" );
         checkButton.click();
-        bot.sleep( 2000 );
-//SWTBotTestCase.assertEnabled( widget );
-//        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.";
-//            }
-//        } );
+        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.";
+            }
+        } );
         
         bot.button( "OK" ).click();
         bot.button( "Cancel" ).click();

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java?rev=683169&r1=683168&r2=683169&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
Wed Aug  6 01:43:13 2008
@@ -91,9 +91,7 @@
     public void testCreateOrganizationEntry() throws Exception
     {
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root
DSE", "ou=system" );
-        systemNode.expand();
-        systemNode.expand();
+        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
 
         // open "New Entry" wizard
         SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
@@ -147,6 +145,7 @@
                 return "Could not find widget";
             }
         } );
+        bot.sleep( 1000 );
     }
 
 
@@ -158,9 +157,7 @@
     public void testCreatePersonEntry() throws Exception
     {
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root
DSE", "ou=system" );
-        systemNode.expand();
-        systemNode.expand();
+        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
 
         // open "New Entry" wizard
         SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
@@ -202,8 +199,8 @@
         tree.select( "sn" );
         bot.text( "" ).setText( "test" );
         // click to finish editing of sn
-        SWTBotTreeItem cnNode = SWTBotUtils.selectNode( bot, tree, "sn" );
-        cnNode.click();
+        SWTBotTreeItem snNode = tree.getTreeItem( "sn" );
+        snNode.click();
 
         // click finish to create the entry
         bot.button( "Finish" ).click();
@@ -222,6 +219,7 @@
                 return "Could not find widget";
             }
         } );
+        bot.sleep( 1000 );
     }
 
 
@@ -236,9 +234,7 @@
     public void testCreateUpperCaseOrganizationEntries() throws Exception
     {
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root
DSE", "ou=system" );
-        systemNode.expand();
-        systemNode.expand();
+        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
 
         // open "New Entry" wizard
         SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
@@ -292,6 +288,7 @@
                 return "Could not find widget";
             }
         } );
+        bot.sleep( 1000 );
 
         // Now create a second entry under the previously created entry 
         // to ensure that the selected parent is also upper case.
@@ -353,6 +350,7 @@
                 return "Could not find widget";
             }
         } );
+        bot.sleep( 1000 );
     }
 
 
@@ -366,7 +364,7 @@
     public void testCreateEntryWithSlash() throws Exception
     {
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root
DSE", "ou=system" );
+        SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, true, "DIT",
"Root DSE", "ou=system" );
         systemNode.expand();
         systemNode.expand();
 
@@ -407,9 +405,13 @@
             }
         } );
 
-        // click to finish editing of sn
         SWTBotTree tree = bot.tree( 0 );
-        SWTBotTreeItem krbNode = SWTBotUtils.selectNode( bot, tree, "krb5PrincipalName" );
+        SWTBotTreeItem krbNode = tree.getTreeItem( "krb5PrincipalName" );
+
+        // enter cn value
+        tree.select( "cn" );
+        bot.text( "" ).setText( "test" );
+        // click to finish editing of cn
         krbNode.click();
 
         // enter sn value
@@ -418,12 +420,6 @@
         // click to finish editing of sn
         krbNode.click();
 
-        // enter cn value
-        tree.select( "cn" );
-        bot.text( "" ).setText( "test" );
-        // click to finish editing of cn
-        krbNode.click();
-
         // click finish to create the entry
         bot.button( "Finish" ).click();
 
@@ -442,6 +438,7 @@
                 return "Could not find entry 'krb5Principal=kadmin/changepw@DOMAIN'";
             }
         } );
+        bot.sleep( 1000 );
     }
 
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java?rev=683169&r1=683168&r2=683169&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
Wed Aug  6 01:43:13 2008
@@ -86,8 +86,11 @@
 
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
 
+        // select ou=system, don't expand yet
+        final SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, false,
"DIT", "Root DSE",
+            "ou=system" );
+
         // expand ou=system, that reads the referral and opens the referral dialog
-        final SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT",
"Root DSE", "ou=system" );
         UIThreadRunnable.asyncExec( bot.getDisplay(), new UIThreadRunnable.VoidResult()
         {
             public void run()
@@ -99,14 +102,13 @@
 
         // click OK in the referral dialog
         bot.button( "OK" ).click();
-        systemNode.expand();
-        bot.sleep( 1000 );
+        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
 
         // ensure that the referral URL and target is visible
         SWTBotTreeItem referralNode = systemNode.getNode( "ldap://localhost:" + ldapServer.getIpPort()
             + "/ou=users,ou=system" );
         assertNotNull( referralNode );
-        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system", "ldap://localhost:"
+        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"ldap://localhost:"
             + ldapServer.getIpPort() + "/ou=users,ou=system" );
 
     }
@@ -132,8 +134,11 @@
 
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
 
+        // select ou=system, don't expand yet
+        final SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, false,
"DIT", "Root DSE",
+            "ou=system" );
+
         // expand ou=system, that reads the referral and opens the referral dialog
-        final SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT",
"Root DSE", "ou=system" );
         UIThreadRunnable.asyncExec( bot.getDisplay(), new UIThreadRunnable.VoidResult()
         {
             public void run()
@@ -145,8 +150,7 @@
 
         // click Cancel in the referral dialog
         bot.button( "Cancel" ).click();
-        systemNode.expand();
-        bot.sleep( 1000 );
+        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
 
         // ensure that the referral URL and target is not visible
         SWTBotTreeItem referralNode = systemNode.getNode( "ldap://localhost:" + ldapServer.getIpPort()
@@ -172,18 +176,16 @@
         // create the referral entry
         createReferralEntry();
 
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        // expand ou=system, that reads the referral and opens the referral dialog
-        final SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT",
"Root DSE", "ou=system" );
-        systemNode.expand();
-        systemNode.expand();
-        bot.sleep( 1000 );
+        // expand ou=system, the referral must be ignored, no referral dialog expected
+        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+        SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, true, "DIT",
"Root DSE", "ou=system" );
 
         // ensure that the referral entry is not visible
-        SWTBotTreeItem referralNode = systemNode.getNode( "ldap://localhost:" + ldapServer.getIpPort()
+        SWTBotTreeItem referralNode1 = systemNode.getNode( "ldap://localhost:" + ldapServer.getIpPort()
             + "/ou=users,ou=system" );
-        assertNull( referralNode );
+        assertNull( referralNode1 );
+        SWTBotTreeItem referralNode2 = systemNode.getNode( "cn=referralDialogTest" );
+        assertNull( referralNode2 );
     }
 
 
@@ -204,18 +206,14 @@
         // create the referral entry
         createReferralEntry();
 
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        // expand ou=system, that reads the referral and opens the referral dialog
-        final SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT",
"Root DSE", "ou=system" );
-        systemNode.expand();
-        systemNode.expand();
-        bot.sleep( 1000 );
+        // expand ou=system, the referral is managed, no referral dialog expected
+        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+        SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, true, "DIT",
"Root DSE", "ou=system" );
 
         // ensure that the referral entry is visible
         SWTBotTreeItem referralNode = systemNode.getNode( "cn=referralDialogTest" );
         assertNotNull( referralNode );
-        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system", "cn=referralDialogTest"
);
+        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"cn=referralDialogTest" );
     }
 
 

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java?rev=683169&r1=683168&r2=683169&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java
Wed Aug  6 01:43:13 2008
@@ -68,9 +68,10 @@
     {
         final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
 
-        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system", "ou=users",
+        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"ou=users",
             "cn=Barbara Jensen+uid=bjensen" );
 
+        bot.sleep( 2000 );
         SWTBotMenu contextMenu = browserTree.contextMenu( "Rename Entry..." );
         contextMenu.click();
 
@@ -78,7 +79,8 @@
         bot.text( "bjensen" ).setText( "babsjens" );
         bot.button( "OK" ).click();
 
-        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system", "ou=users",
+        // ensure that the entry with the new name exists
+        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"ou=users",
             "cn=Babs Jensen+uid=babsjens" );
     }
 

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java?rev=683169&r1=683168&r2=683169&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
Wed Aug  6 01:43:13 2008
@@ -27,12 +27,16 @@
 
 import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
 import net.sf.swtbot.eclipse.finder.widgets.SWTBotView;
+import net.sf.swtbot.finder.ControlFinder;
+import net.sf.swtbot.finder.UIThreadRunnable;
+import net.sf.swtbot.matcher.ClassMatcher;
 import net.sf.swtbot.wait.DefaultCondition;
 import net.sf.swtbot.widgets.SWTBotButton;
 import net.sf.swtbot.widgets.SWTBotMenu;
 import net.sf.swtbot.widgets.SWTBotTable;
 import net.sf.swtbot.widgets.SWTBotTree;
 import net.sf.swtbot.widgets.SWTBotTreeItem;
+import net.sf.swtbot.widgets.WidgetNotFoundException;
 
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
@@ -42,6 +46,7 @@
 import org.apache.directory.studio.connection.core.ConnectionParameter;
 import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
 import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
+import org.eclipse.swt.widgets.Tree;
 
 
 /**
@@ -96,49 +101,13 @@
 
 
     /**
-     * Opens the Sleak (SWT leak) view.
+     * Creates the test connection.
      * 
      * @param bot the bot
+     * @param name the name of the connection
+     * @param port the port to use
      * 
-     * @throws Exception the exception
-     */
-    public static void openSleakView( final SWTEclipseBot eBot ) throws Exception
-    {
-        // open "Show View" dialog
-        SWTBotMenu windowMenu = eBot.menu( "Window" );
-        windowMenu.click();
-        SWTBotMenu viewMenu = windowMenu.menu( "Show View" );
-        viewMenu.click();
-        SWTBotMenu otherMenu = viewMenu.menu( "Other..." );
-        otherMenu.click();
-
-        // select "Sleak"
-        SWTBotTree tree = eBot.tree();
-        SWTBotUtils.selectNode( eBot, tree, "SWT Tools", "Sleak" );
-
-        // press "OK"
-        SWTBotButton okButton = eBot.button( "OK" );
-        okButton.click();
-
-        // wait till Connections view become visible
-        eBot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return eBot.view( "Sleak" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-    }
-
-
-    /**
-     * Creates the test connection.
+     * @return the connection
      * 
      * @throws Exception the exception
      */
@@ -184,88 +153,194 @@
     }
 
 
+    /**
+     * Gets the connections tree.
+     * 
+     * @param bot the bot
+     * 
+     * @return the connections tree
+     * 
+     * @throws Exception the exception
+     */
     public static SWTBotTree getConnectionsTree( SWTEclipseBot bot ) throws Exception
     {
         SWTBotView view = bot.view( "Connections" );
         view.show();
-        SWTBotTree connectionsTree = bot.tree( 0 );
-        return connectionsTree;
+
+        List<Tree> findControls = new ControlFinder().findControls( view.widget, new
ClassMatcher( Tree.class ), true );
+        if ( findControls.isEmpty() )
+        {
+            throw new WidgetNotFoundException( "Could not find Connections tree" );
+        }
+        return new SWTBotTree( findControls.get( 0 ) );
     }
 
 
+    /**
+     * Gets the ldap browser tree.
+     * 
+     * @param bot the bot
+     * 
+     * @return the ldap browser tree
+     * 
+     * @throws Exception the exception
+     */
     public static SWTBotTree getLdapBrowserTree( SWTEclipseBot bot ) throws Exception
     {
         SWTBotView view = bot.view( "LDAP Browser" );
         view.show();
-        SWTBotTree browserTree = bot.tree( 1 );
-        return browserTree;
+
+        List<Tree> findControls = new ControlFinder().findControls( view.widget, new
ClassMatcher( Tree.class ), true );
+        if ( findControls.isEmpty() )
+        {
+            throw new WidgetNotFoundException( "Could not find LDAP Browser tree" );
+        }
+        return new SWTBotTree( findControls.get( 0 ) );
     }
 
 
-    public static SWTBotTreeItem selectNode( SWTEclipseBot bot, SWTBotTree browserTree, String...
path )
-        throws Exception
+    /**
+     * Selects an entry in the browser tree and optionally expands the selected entry.
+     * Takes care that all attributes and child entries are initialized so 
+     * that there are no pending background actions and event notifications. 
+     * This is necessary to avoid race conditions.
+     * 
+     * @param bot the SWT bot
+     * @param tree the browser tree
+     * @param expandChild true to expand the child entry
+     * @param path the path to the entry
+     * 
+     * @return the selected entry as SWTBotTreeItem
+     * 
+     * @throws Exception the exception
+     */
+    public static SWTBotTreeItem selectEntry( final SWTEclipseBot bot, final SWTBotTree tree,
+        final boolean expandChild, final String... path ) throws Exception
     {
         List<String> pathList = new ArrayList<String>( Arrays.asList( path )
);
-        String currentPath = pathList.remove( 0 );
-
-        SWTBotTreeItem child = browserTree.getTreeItem( currentPath );
-        child.select();
+        SWTBotTreeItem entry = null;
 
-        if ( !pathList.isEmpty() )
-        {
-            child.expand();
-            return selectNode( bot, child, pathList );
-        }
-        else
+        while ( !pathList.isEmpty() )
         {
-            return child;
+            String currentPath = pathList.remove( 0 );
+
+            if ( entry == null )
+            {
+                entry = tree.getTreeItem( currentPath );
+            }
+            else
+            {
+                // adjust current path, because the label is decorated with the number of
children
+                currentPath = adjustNodeName( entry, currentPath );
+                entry = entry.getNode( currentPath );
+            }
+
+            entry.select();
+
+            if ( !pathList.isEmpty() || expandChild )
+            {
+                // expand entry and wait till 
+                // - children are displayed
+                // - next child is visible
+
+                final String nextName = !pathList.isEmpty() ? pathList.get( 0 ) : null;
+                expandEntry( bot, entry, nextName );
+                
+//                final SWTBotTreeItem child = entry;
+//
+//                UIThreadRunnable.asyncExec( bot.getDisplay(), new UIThreadRunnable.VoidResult()
+//                {
+//                    public void run()
+//                    {
+//                        child.expand();
+//                    }
+//                } );
+//
+//                bot.waitUntil( new DefaultCondition()
+//                {
+//                    public boolean test() throws Exception
+//                    {
+//                        if ( nextName != null )
+//                        {
+//                            String adjustedNodeName = nextName != null ? adjustNodeName(
child, nextName ) : null;
+//                            SWTBotTreeItem node = child.getNode( adjustedNodeName );
+//                            if ( node == null )
+//                            {
+//                                return false;
+//                            }
+//                        }
+//                        return !child.getNodes().contains( "Fetching Entries..." );
+//                    }
+//
+//
+//                    public String getFailureMessage()
+//                    {
+//                        return "Could not find entry " + child.getText() + " -> " +
nextName;
+//                    }
+//                } );
+            }
+
         }
+        return entry;
     }
 
-
-    public static SWTBotTreeItem selectNode( SWTEclipseBot bot, final SWTBotTreeItem item,
List<String> pathList )
-        throws Exception
+    /**
+     * Expands the entry.
+     * Takes care that all attributes and child entries are initialized so 
+     * that there are no pending background actions and event notifications. 
+     * This is necessary to avoid race conditions.
+     * 
+     * @param bot the bot
+     * @param entry the entry to expand
+     * @param nextName the name of the entry that must become visible, may be null
+     * 
+     * @throws Exception the exception
+     */
+    public static void expandEntry( final SWTEclipseBot bot, final SWTBotTreeItem entry,
final String nextName ) throws Exception
     {
-        final String[] currentPath = new String[]
-            { pathList.remove( 0 ) };
+        UIThreadRunnable.asyncExec( bot.getDisplay(), new UIThreadRunnable.VoidResult()
+        {
+            public void run()
+            {
+                entry.expand();
+            }
+        } );
 
-        // wait till node becomes visible
         bot.waitUntil( new DefaultCondition()
         {
             public boolean test() throws Exception
             {
-                List<String> nodes = item.getNodes();
-                for ( String node : nodes )
+                if ( nextName != null )
                 {
-                    if ( node.toUpperCase().startsWith( currentPath[0].toUpperCase() ) )
+                    String adjustedNodeName = nextName != null ? adjustNodeName( entry, nextName
) : null;
+                    SWTBotTreeItem node = entry.getNode( adjustedNodeName );
+                    if ( node == null )
                     {
-                        currentPath[0] = node;
-                        return true;
+                        return false;
                     }
                 }
-                return false;
+                return !entry.getNodes().contains( "Fetching Entries..." );
             }
 
 
             public String getFailureMessage()
             {
-                return "Could not find widget";
+                return "Could not find entry " + entry.getText() + " -> " + nextName;
             }
         } );
+    }
 
-        SWTBotTreeItem child = item.getNode( currentPath[0] );
-        child.select();
-
-        if ( !pathList.isEmpty() )
-        {
-            child.expand();
-            child.expand();
-            return selectNode( bot, child, pathList );
-        }
-        else
+    private static String adjustNodeName( SWTBotTreeItem child, String nodeName )
+    {
+        List<String> nodes = child.getNodes();
+        for ( String node : nodes )
         {
-            return child;
+            if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+            {
+                return node;
+            }
         }
+        return null;
     }
 
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java?rev=683169&r1=683168&r2=683169&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
Wed Aug  6 01:43:13 2008
@@ -29,7 +29,6 @@
 import net.sf.swtbot.widgets.SWTBotMenu;
 import net.sf.swtbot.widgets.SWTBotText;
 import net.sf.swtbot.widgets.SWTBotTree;
-import net.sf.swtbot.widgets.SWTBotTreeItem;
 
 import org.apache.directory.server.unit.AbstractServerTest;
 import org.eclipse.swt.graphics.DeviceData;
@@ -51,7 +50,6 @@
         super.setUp();
         bot = new SWTEclipseBot();
         SWTBotUtils.openLdapPerspective( bot );
-        SWTBotUtils.openSleakView( bot );
         SWTBotUtils.createTestConnection( bot, "SwtResourcesTest", ldapServer.getIpPort()
);
     }
 
@@ -131,11 +129,7 @@
 
     private void createAndDeleteEntry( final SWTBotTree browserTree, final String name )
throws Exception
     {
-        SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root
DSE", "ou=system" );
-        systemNode.expand();
-        systemNode.expand();
-
-        //        bot.sleep( 1000 );
+        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
         SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
         contextMenu.click();
 
@@ -182,9 +176,10 @@
                 return "Could not select 'o=" + name + "'";
             }
         } );
+        bot.sleep( 1000 );
 
         // delete the entry
-        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system", "o=" +
name );
+        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"o=" + name );
         contextMenu = browserTree.contextMenu( "Delete Entry" );
         contextMenu.click();
         bot.button( "OK" ).click();



Mime
View raw message