directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r828656 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: ReferralDialogTest.java SWTBotUtils.java bots/BrowserViewBot.java bots/ReferralDialogBot.java
Date Thu, 22 Oct 2009 11:15:19 GMT
Author: seelmann
Date: Thu Oct 22 11:15:18 2009
New Revision: 828656

URL: http://svn.apache.org/viewvc?rev=828656&view=rev
Log:
o simplyfied referral dialog tests
o added test for following referrals manually
o added bots for browser view and referral dialog

Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java
Modified:
    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/SWTBotUtils.java

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=828656&r1=828655&r2=828656&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
Thu Oct 22 11:15:18 2009
@@ -22,8 +22,7 @@
 
 
 import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
 
 import org.apache.directory.server.core.entry.DefaultServerEntry;
@@ -36,12 +35,10 @@
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.ReferralDialogBot;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,9 +57,16 @@
 {
     public static LdapServer ldapServer;
 
+    private ConnectionsViewBot connectionsViewBot;
+    private BrowserViewBot browserViewBot;
+
     private SWTWorkbenchBot bot;
     private Connection connection;
 
+    private String[] parentPath;
+    private String[] referralPath;
+    private String[] targetPath;
+
 
     @Before
     public void setUp() throws Exception
@@ -70,12 +74,32 @@
         bot = new SWTWorkbenchBot();
         SWTBotUtils.openLdapPerspective( bot );
         connection = SWTBotUtils.createTestConnection( bot, "ReferralDialogTest", ldapServer.getPort()
);
+
+        connectionsViewBot = new ConnectionsViewBot();
+        browserViewBot = new BrowserViewBot();
+
+        // create referral entry
+        ServerEntry entry = new DefaultServerEntry( ldapServer.getDirectoryService().getRegistries()
);
+        entry.setDn( new LdapDN( "cn=referralDialogTest,ou=system" ) );
+        entry.add( "objectClass", "top", "referral", "extensibleObject" );
+        entry.add( "cn", "referralDialogTest" );
+        entry.add( "ref", "ldap://localhost:" + ldapServer.getPort() + "/ou=users,ou=system"
);
+        ldapServer.getDirectoryService().getAdminSession().add( entry );
+
+        // get paths
+        parentPath = new String[]
+            { "DIT", "Root DSE", "ou=system" };
+        referralPath = new String[]
+            { "DIT", "Root DSE", "ou=system", "cn=referralDialogTest" };
+        targetPath = new String[]
+            { "DIT", "Root DSE", "ou=system", "ldap://localhost:" + ldapServer.getPort()
+ "/ou=users,ou=system" };
     }
 
 
     @After
     public void tearDown() throws Exception
     {
+        connectionsViewBot.closeSelectedConnections();
         SWTBotUtils.deleteTestConnections();
         bot = null;
     }
@@ -85,12 +109,9 @@
      * Test for DIRSTUDIO-343.
      * 
      * Follows a continuation reference.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testBrowseAndFollowContinuationReference() throws Exception
+    public void testBrowseAndFollowContinuationReference()
     {
         // ensure that referrals handling method is FOLLOW
         connection.getConnectionParameter().setExtendedIntProperty(
@@ -99,37 +120,15 @@
             IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
         assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal
);
 
-        // create the referral entry
-        createReferralEntry();
-
-        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
-        UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
-        {
-            public void run()
-            {
-                systemNode.expand();
-            }
-        } );
-        bot.sleep( 1000 );
-
-        // click OK in the referral dialog
-        bot.button( "OK" ).click();
-        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.getPort()
-            + "/ou=users,ou=system" );
-        assertNotNull( referralNode );
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"ldap://localhost:"
-            + ldapServer.getPort() + "/ou=users,ou=system" );
-
+        // expand ou=system, that reads the referral and opens the referral dialog
+        ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog(
parentPath );
+        assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
+        referralDialogBot.clickOkButton();
+
+        // ensure that the target exists, the referral is not visible
+        assertFalse( browserViewBot.existsEntry( referralPath ) );
+        assertTrue( browserViewBot.existsEntry( targetPath ) );
+        browserViewBot.selectEntry( targetPath );
     }
 
 
@@ -138,12 +137,9 @@
      * 
      * Does not follow a continuation reference by clicking the cancel button in
      * the referral dialog.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testBrowseAndCancelFollowingContinuationReference() throws Exception
+    public void testBrowseAndCancelFollowingContinuationReference()
     {
         // ensure that referrals handling method is FOLLOW
         connection.getConnectionParameter().setExtendedIntProperty(
@@ -152,52 +148,22 @@
             IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
         assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal
);
 
-        // create the referral entry
-        createReferralEntry();
-
-        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
-        UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
-        {
-            public void run()
-            {
-                systemNode.expand();
-            }
-        } );
-        bot.sleep( 1000 );
-
-        // click Cancel in the referral dialog
-        bot.button( "Cancel" ).click();
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // ensure that the referral URL and target is not visible
-        SWTBotTreeItem referralNode = null;
-        try
-        {
-            referralNode = systemNode.getNode( "ldap://localhost:" + ldapServer.getPort()
+ "/ou=users,ou=system" );
-        }
-        catch ( WidgetNotFoundException wnfe )
-        {
-            // that is expected
-        }
-        assertNull( referralNode );
+        // expand ou=system, that reads the referral and opens the referral dialog
+        ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog(
parentPath );
+        assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
+        referralDialogBot.clickCancelButton();
+
+        // ensure that neither the target, nor the referral exist
+        assertFalse( browserViewBot.existsEntry( referralPath ) );
+        assertFalse( browserViewBot.existsEntry( targetPath ) );
     }
 
 
     /**
      * Tests ignore referral by setting the connection property to IGNORE.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testBrowseAndIgnoreReferral() throws Exception
+    public void testBrowseAndIgnoreReferral()
     {
         // ensure that referrals handling method is IGNORE
         connection.getConnectionParameter().setExtendedIntProperty(
@@ -206,48 +172,22 @@
             IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
         assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal
);
 
-        // create the referral entry
-        createReferralEntry();
+        // expand ou=system, no referral dialog expected
+        browserViewBot.expandEntry( parentPath );
 
-        // 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 referralNode1 = null;
-        try
-        {
-            referralNode1 = systemNode.getNode( "ldap://localhost:" + ldapServer.getPort()
+ "/ou=users,ou=system" );
-        }
-        catch ( WidgetNotFoundException wnfe )
-        {
-            // that is expected
-        }
-        assertNull( referralNode1 );
-        SWTBotTreeItem referralNode2 = null;
-        try
-        {
-            referralNode2 = systemNode.getNode( "cn=referralDialogTest" );
-        }
-        catch ( WidgetNotFoundException wnfe )
-        {
-            // that is expected
-        }
-        assertNull( referralNode2 );
+        // ensure that neither the target, nor the referral exist
+        assertFalse( browserViewBot.existsEntry( referralPath ) );
+        assertFalse( browserViewBot.existsEntry( targetPath ) );
     }
 
 
     /**
-     * Tests manage referral entry by setting the connection property to MANAGE.
-     * 
-     * @throws Exception
-     *             the exception
+     * Tests manage referral entry by setting the ManageDsaIT control.
      */
     @Test
-    public void testBrowseAndManageReferralEntry() throws Exception
+    public void testBrowseAndManageReferralEntry()
     {
-        // ensure that referrals handling method is MANAGE
+        // ensure that ManageDsaIT is set
         connection.getConnectionParameter().setExtendedIntProperty(
             IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD, ReferralHandlingMethod.IGNORE.ordinal()
);
         connection.getConnectionParameter().setExtendedBoolProperty(
@@ -259,28 +199,45 @@
         assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal
);
         assertTrue( manageDsaIT );
 
-        // create the referral entry
-        createReferralEntry();
+        // expand ou=system, that reads the referral and opens the referral dialog
+        browserViewBot.expandEntry( parentPath );
 
-        // 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.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"cn=referralDialogTest" );
+        // ensure that the referral entry exists
+        assertTrue( browserViewBot.existsEntry( referralPath ) );
+        assertFalse( browserViewBot.existsEntry( targetPath ) );
+        browserViewBot.selectEntry( referralPath );
     }
 
 
-    private void createReferralEntry() throws Exception
+    /**
+     * Tests manual referral following.
+     */
+    @Test
+    public void testBrowseAndFollowManuallyContinuationReference()
     {
-        ServerEntry entry = new DefaultServerEntry( ldapServer.getDirectoryService().getRegistries()
);
-        entry.setDn( new LdapDN( "cn=referralDialogTest,ou=system" ) );
-        entry.add( "objectClass", "top", "referral", "extensibleObject" );
-        entry.add( "cn", "referralDialogTest" );
-        entry.add( "ref", "ldap://localhost:" + ldapServer.getPort() + "/ou=users,ou=system"
);
-        ldapServer.getDirectoryService().getAdminSession().add( entry );
+        // ensure that referrals handling method is FOLLOW_MANUALLY
+        connection.getConnectionParameter().setExtendedIntProperty(
+            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
+            ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal() );
+        int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
+            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
+        assertEquals( ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal(), referralsHandlingMethodOrdinal
);
+
+        // expand ou=system, no referral dialog expected yet
+        browserViewBot.expandEntry( parentPath );
+
+        // ensure that the target exists, the referral is not visible
+        assertFalse( browserViewBot.existsEntry( referralPath ) );
+        assertTrue( browserViewBot.existsEntry( targetPath ) );
+
+        // select the target, that should popup the referral dialog
+        ReferralDialogBot referralDialogBot = browserViewBot.selectEntryExpectingReferralDialog(
targetPath );
+        assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
+        referralDialogBot.clickOkButton();
+
+        // ensure that the target exists, the referral is not visible
+        assertFalse( browserViewBot.existsEntry( referralPath ) );
+        assertTrue( browserViewBot.existsEntry( targetPath ) );
+        browserViewBot.selectEntry( targetPath );
     }
-}
+}
\ No newline at end of file

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=828656&r1=828655&r2=828656&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
Thu Oct 22 11:15:18 2009
@@ -217,7 +217,7 @@
      * @throws Exception
      *             the exception
      */
-    public static SWTBotTree getLdapBrowserTree( SWTWorkbenchBot bot ) throws Exception
+    public static SWTBotTree getLdapBrowserTree( SWTWorkbenchBot bot )
     {
         SWTBotView view = bot.viewByTitle( "LDAP Browser" );
         view.show();
@@ -414,7 +414,7 @@
      *             the exception
      */
     public static SWTBotTreeItem selectEntry( final SWTWorkbenchBot bot, final SWTBotTree
tree,
-        final boolean expandChild, final String... path ) throws Exception
+        final boolean expandChild, final String... path )
     {
         List<String> pathList = new ArrayList<String>( Arrays.asList( path )
);
         SWTBotTreeItem entry = null;
@@ -468,7 +468,6 @@
      *             the exception
      */
     public static void expandEntry( final SWTWorkbenchBot bot, final SWTBotTreeItem entry,
final String nextName )
-        throws Exception
     {
         UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
         {

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java?rev=828656&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
Thu Oct 22 11:15:18 2009
@@ -0,0 +1,204 @@
+/*
+ *  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.Arrays;
+import java.util.List;
+
+import org.apache.directory.studio.test.integration.ui.SWTBotUtils;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+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 BrowserViewBot
+{
+    private SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+
+    public boolean existsEntry( String... path )
+    {
+        // ensure the parent exists
+        String[] parentPath = new String[path.length - 1];
+        System.arraycopy( path, 0, parentPath, 0, parentPath.length );
+        getEntry( parentPath );
+
+        // check if the child exists
+        try
+        {
+            getEntry( path );
+            return true;
+        }
+        catch ( WidgetNotFoundException e )
+        {
+            return false;
+        }
+    }
+
+
+    public void selectEntry( String... path )
+    {
+        SWTBotTreeItem entry = getEntry( path );
+        select( entry );
+    }
+
+
+    public ReferralDialogBot selectEntryExpectingReferralDialog( String... path )
+    {
+        SWTBotTreeItem entry = getEntry( path );
+        select( entry );
+        return new ReferralDialogBot();
+    }
+
+
+    public void expandEntry( String... path )
+    {
+        SWTBotTreeItem entry = getEntry( path );
+        expand( entry, true, null );
+    }
+
+
+    public ReferralDialogBot expandEntryExpectingReferralDialog( String... path )
+    {
+        SWTBotTreeItem entry = getEntry( path );
+        expand( entry, false, null );
+        return new ReferralDialogBot();
+    }
+
+
+    private SWTBotTreeItem getEntry( String... path )
+    {
+        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+        List<String> pathList = new ArrayList<String>( Arrays.asList( path )
);
+        SWTBotTreeItem entry = null;
+
+        while ( !pathList.isEmpty() )
+        {
+            String node = pathList.remove( 0 );
+
+            if ( entry == null )
+            {
+                node = adjustNodeName( browserTree, node );
+                entry = browserTree.getTreeItem( node );
+            }
+            else
+            {
+                // adjust current path, because the label is decorated with the
+                // number of children
+                node = adjustNodeName( entry, node );
+                System.out.println( node );
+                entry = entry.getNode( node );
+            }
+
+            if ( !pathList.isEmpty() )
+            {
+                // expand entry and wait till
+                // - children are displayed
+                // - next child is visible
+                final String nextNode = !pathList.isEmpty() ? pathList.get( 0 ) : null;
+                expand( entry, true, nextNode );
+            }
+        }
+
+        return entry;
+    }
+
+
+    private void expand( final SWTBotTreeItem entry, boolean wait, final String nextNode
)
+    {
+        UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
+        {
+            public void run()
+            {
+                entry.expand();
+            }
+        } );
+
+        if ( wait )
+        {
+            bot.waitUntil( new DefaultCondition()
+            {
+                public boolean test() throws Exception
+                {
+//                    if ( nextNode != null )
+//                    {
+//                        String adjustedNodeName = nextNode != null ? adjustNodeName( entry,
nextNode ) : null;
+//                        SWTBotTreeItem node = entry.getNode( adjustedNodeName );
+//                        if ( node == null )
+//                        {
+//                            return false;
+//                        }
+//                    }
+                    return !entry.getNodes().contains( "Fetching Entries..." )
+                        && !entry.getNodes().contains( "Opening Connection..." );
+                }
+
+
+                public String getFailureMessage()
+                {
+                    return "Could not find entry " + entry.getText() + " -> " + nextNode;
+                }
+            } );
+        }
+    }
+
+
+    private void select( SWTBotTreeItem entry )
+    {
+        entry.click();
+        entry.select();
+    }
+
+
+    private String adjustNodeName( SWTBotTreeItem child, String nodeName )
+    {
+        List<String> nodes = child.getNodes();
+        for ( String node : nodes )
+        {
+            if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+            {
+                return node;
+            }
+        }
+        return nodeName;
+    }
+
+
+    private String adjustNodeName( SWTBotTree tree, String nodeName )
+    {
+        SWTBotTreeItem[] allItems = tree.getAllItems();
+        for ( SWTBotTreeItem item : allItems )
+        {
+            String node = item.getText();
+            if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+            {
+                return node;
+            }
+        }
+        return nodeName;
+    }
+
+}

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java?rev=828656&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java
Thu Oct 22 11:15:18 2009
@@ -0,0 +1,59 @@
+/*
+ *  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.swt.finder.utils.TableCollection;
+import org.eclipse.swtbot.swt.finder.utils.TableRow;
+
+
+public class ReferralDialogBot extends DialogBot
+{
+
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+
+
+    public void clickCancelButton()
+    {
+        super.clickButton( "Cancel" );
+    }
+
+
+    public void selectConnection( String connectionName )
+    {
+        bot.tree().select( connectionName );
+    }
+
+
+    public String getSelectedConnection()
+    {
+        TableCollection selection = bot.tree().selection();
+        if ( selection != null && selection.rowCount() == 1 )
+        {
+            TableRow row = selection.get( 0 );
+            return row.get( 0 );
+        }
+        return null;
+    }
+
+}



Mime
View raw message