directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r887729 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: ./ bots/
Date Sun, 06 Dec 2009 18:16:52 GMT
Author: seelmann
Date: Sun Dec  6 18:16:51 2009
New Revision: 887729

URL: http://svn.apache.org/viewvc?rev=887729&view=rev
Log:
Added test for DIRSTUDIO-601.

Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java
Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java?rev=887729&r1=887728&r2=887729&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
Sun Dec  6 18:16:51 2009
@@ -24,10 +24,18 @@
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertTrue;
 
+import java.util.ArrayList;
+import java.util.List;
+
 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.LdapServer;
+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.ldapbrowser.core.BrowserConnectionManager;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
@@ -36,7 +44,9 @@
 import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.SearchDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.SearchPropertiesDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.SearchResultEditorBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -49,7 +59,6 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-//@RunWith(SWTBotJunit4ClassRunner.class)
 @RunWith(SiRunner.class)
 @CleanupLevel(Level.SUITE)
 public class SearchTest
@@ -157,4 +166,46 @@
         assertEquals( "Only 1 event firings expected when running quick search.", 1, fireCount
);
     }
 
+
+    /**
+     * Test for DIRSTUDIO-601.
+     * (The 'Perform Search/Search Again' button in the Search Result Editor does not work
correctly)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testRefresh() throws Exception
+    {
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
+        SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
+        assertTrue( dialogBot.isVisible() );
+        dialogBot.setSearchName( "Search Admin" );
+        dialogBot.setFilter( "(uid=admin)" );
+        dialogBot.setReturningAttributes( "objectClass, uid, description" );
+        dialogBot.clickSearchButton();
+        browserViewBot.selectEntry( "Searches", "Search Admin" );
+
+        SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( "Search Result
Editor" );
+        srEditorBot.activate();
+        assertTrue( srEditorBot.isEnabled() );
+
+        // assert that description attribute is empty
+        assertEquals( "uid=admin,ou=system", srEditorBot.getContent( 1, 1 ) );
+        assertEquals( "", srEditorBot.getContent( 1, 4 ) );
+
+        // add description
+        List<Modification> modifications = new ArrayList<Modification>();
+        modifications.add( new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE,
new DefaultClientAttribute(
+            "description", "The 1st description." ) ) );
+        ldapServer.getDirectoryService().getAdminSession().modify( new LdapDN( "uid=admin,ou=system"
), modifications );
+
+        // refresh the search, using the toolbar icon
+        srEditorBot.refresh();
+        SWTUtils.sleep( 1000 );
+
+        // assert the description attribute value is displayed now
+        assertEquals( "uid=admin,ou=system", srEditorBot.getContent( 1, 1 ) );
+        assertEquals( "The 1st description.", srEditorBot.getContent( 1, 4 ) );
+    }
+
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java?rev=887729&r1=887728&r2=887729&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
Sun Dec  6 18:16:51 2009
@@ -49,6 +49,12 @@
     }
 
 
+    public void setReturningAttributes( String string )
+    {
+        searchPageWrapperBot.setReturningAttributes( string );
+    }
+
+
     public void clickSearchButton()
     {
         super.clickButton( "Search" );

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java?rev=887729&r1=887728&r2=887729&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
Sun Dec  6 18:16:51 2009
@@ -42,13 +42,19 @@
 
     void setSearchName( String string )
     {
-        bot.textWithLabel( "Search Name:" ).setText( "Search all persons" );
+        bot.textWithLabel( "Search Name:" ).setText( string );
     }
 
 
     void setFilter( String string )
     {
-        bot.comboBoxWithLabel( "Filter:" ).setText( "(objectClass=person)" );
+        bot.comboBoxWithLabel( "Filter:" ).setText( string );
+    }
+
+
+    void setReturningAttributes( String string )
+    {
+        bot.comboBoxWithLabel( "Returning Attributes:" ).setText( string );
     }
 
 }

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java?rev=887729&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java
Sun Dec  6 18:16:51 2009
@@ -0,0 +1,80 @@
+/*
+ *  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 static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withTooltip;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.hamcrest.Matcher;
+
+
+public class SearchResultEditorBot
+{
+
+    private SWTBotEditor editor;
+    private SWTBot bot;
+
+
+    public SearchResultEditorBot( String title )
+    {
+        SWTWorkbenchBot bot = new SWTWorkbenchBot();
+        editor = bot.editorByTitle( title );
+        this.bot = editor.bot();
+    }
+
+
+    public boolean isEnabled()
+    {
+        return bot.table().isEnabled();
+    }
+
+
+    public void activate()
+    {
+        editor.setFocus();
+        bot.table().setFocus();
+    }
+
+
+    public String getContent( int row, int column )
+    {
+        return bot.table().cell( row - 1, column - 1 );
+    }
+
+
+    public void refresh()
+    {
+        Matcher matcher = allOf( widgetOfType( ToolItem.class ), withTooltip( "Search Again
(F5)" ), withStyle(
+            SWT.PUSH, "SWT.PUSH" ) );
+        SWTBotToolbarButton button = new SWTBotToolbarButton( ( ToolItem ) bot.widget( matcher,
0 ), matcher );
+        button.click();
+    }
+
+}

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java?rev=887729&r1=887728&r2=887729&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
Sun Dec  6 18:16:51 2009
@@ -98,9 +98,11 @@
                         "org.apache.directory.studio.ldapbrowser.ui.perspective.BrowserPerspective",
window );
 
                     // reset LDAP perspective
-                    page.closeAllEditors( false );
-                    page.resetPerspective();
-
+                    if ( page.getActivePart() != null )
+                    {
+                        page.closeAllEditors( false );
+                        page.resetPerspective();
+                    }
                 }
                 catch ( Exception e )
                 {
@@ -119,4 +121,10 @@
         return new PreferencesBot();
     }
 
+
+    public SearchResultEditorBot getSearchResultEditorBot( String title )
+    {
+        return new SearchResultEditorBot( title );
+    }
+
 }



Mime
View raw message