directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r775165 - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/
Date Fri, 15 May 2009 14:42:27 GMT
Author: seelmann
Date: Fri May 15 14:42:26 2009
New Revision: 775165

URL: http://svn.apache.org/viewvc?rev=775165&view=rev
Log:
Fix for DIRSTUDIO-490 (Copy/Paste a search from one connection to another doesn't work)

Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/AutomatedSuite.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java?rev=775165&r1=775164&r2=775165&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
Fri May 15 14:42:26 2009
@@ -34,7 +34,9 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -149,7 +151,7 @@
         IEntry[] entries = getEntriesToPaste();
         if ( entries != null )
         {
-            this.pasteEntries( getSelectedEntries()[0], entries );
+            pasteEntries( getSelectedEntries()[0], entries );
             return;
         }
 
@@ -157,8 +159,7 @@
         ISearch[] searches = getSearchesToPaste();
         if ( searches != null )
         {
-
-            this.pasteSearches( searches );
+            pasteSearches( searches );
             return;
         }
 
@@ -166,7 +167,7 @@
         IValue[] values = getValuesToPaste();
         if ( values != null )
         {
-            this.pasteValues( values );
+            pasteValues( values );
             return;
         }
 
@@ -224,7 +225,8 @@
             ISearch clone = null;
             for ( ISearch search : searches )
             {
-                clone = ( ISearch ) search.clone();
+                SearchParameter searchParameter = ( SearchParameter ) search.getSearchParameter().clone();
+                clone = new Search( browserConnection, searchParameter );
                 browserConnection.getSearchManager().addSearch( clone );
             }
 

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/AutomatedSuite.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/AutomatedSuite.java?rev=775165&r1=775164&r2=775165&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/AutomatedSuite.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/AutomatedSuite.java
Fri May 15 14:42:26 2009
@@ -65,6 +65,7 @@
         addTest( new TestSuite( NewEntryWizardTest.class ) );
         addTest( new TestSuite( RenameEntryDialogTest.class ) );
         addTest( new TestSuite( ReferralDialogTest.class ) );
+        addTest( new TestSuite( SearchTest.class ) );
 
         // Test Entry editor
         addTest( new TestSuite( EntryEditorTest.class ) );

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java?rev=775165&r1=775164&r2=775165&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
Fri May 15 14:42:26 2009
@@ -84,7 +84,5 @@
         int countMatchesAfter = StringUtils.countMatches( text, "#!SEARCH REQUEST" );
 
         assertEquals( "Expected exactly 1 search request", 1, countMatchesAfter - countMatchesBefore
);
-
-        Thread.sleep( 10000 );
     }
 }

Added: 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=775165&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
Fri May 15 14:42:26 2009
@@ -0,0 +1,117 @@
+/*
+ *  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;
+
+
+import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+
+/**
+ * Tests the Search dialog and Search category in the LDAP Browser view.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchTest extends AbstractServerTest
+{
+    private SWTEclipseBot bot;
+
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        bot = new SWTEclipseBot();
+        SWTBotUtils.openLdapPerspective( bot );
+        SWTBotUtils.createTestConnection( bot, "SearchTest1", ldapService.getPort() );
+        SWTBotUtils.createTestConnection( bot, "SearchTest2", ldapService.getPort() );
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        SWTBotUtils.deleteTestConnections();
+        bot = null;
+        super.tearDown();
+    }
+
+
+    /**
+     * Test for DIRSTUDIO-490.
+     * 
+     * Copy/Paste a search between connections and verify that the associated browser connection
is correct.
+     *
+     * @throws Exception
+     */
+    public void testCopyPasteSearchBetweenConnections() throws Exception
+    {
+        BrowserConnectionManager browserConnectionManager = BrowserCorePlugin.getDefault().getConnectionManager();
+        IBrowserConnection browserConnection1 = browserConnectionManager.getBrowserConnectionByName(
"SearchTest1" );
+        IBrowserConnection browserConnection2 = browserConnectionManager.getBrowserConnectionByName(
"SearchTest2" );
+        assertEquals( 0, browserConnection1.getSearchManager().getSearches().size() );
+        assertEquals( 0, browserConnection2.getSearchManager().getSearches().size() );
+
+        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
+        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+
+        // create a search for in connection 1
+        connectionsTree.select( "SearchTest1" );
+        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system"
);
+        browserTree.contextMenu( "New Search..." ).click();
+        bot.shell( "Search" );
+        //SWTBotAssert.assertEnabled( bot.textWithLabel( "Connection:" ) );
+        //SWTBotAssert.assertText( "SearchTest1", bot.textWithLabel( "Connection:" ) );
+        bot.textWithLabel( "Search Name:" ).setText( "Search all persons" );
+        bot.comboBoxWithLabel( "Filter:" ).setText( "(objectClass=person)" );
+        //bot.radioWithLabelInGroup( "Subtree", "Scope" ).click();
+        bot.button( "Search" ).click();
+        SWTBotUtils.selectEntry( bot, browserTree, false, "Searches", "Search all persons"
);
+
+        // assert browser connection in searches
+        assertEquals( 1, browserConnection1.getSearchManager().getSearches().size() );
+        assertEquals( browserConnection1, browserConnection1.getSearchManager().getSearches().get(
0 )
+            .getBrowserConnection() );
+        assertEquals( 0, browserConnection2.getSearchManager().getSearches().size() );
+
+        // copy/paste the created search from connection 1 to connection 2
+        browserTree.contextMenu( "Copy Search" ).click();
+        connectionsTree.select( "SearchTest2" );
+        SWTBotUtils.selectEntry( bot, browserTree, false, "Searches" );
+        browserTree.contextMenu( "Paste Search" ).click();
+        bot.shell( "Properties for Search all persons" );
+        //SWTBotAssert.assertNotEnabled( bot.textWithLabel( "Connection:" ) );
+        //SWTBotAssert.assertText( "SearchTest2", bot.textWithLabel( "Connection:" ) );
+        bot.button( "Cancel" ).click();
+
+        // assert browser connection in searches
+        assertEquals( 1, browserConnection1.getSearchManager().getSearches().size() );
+        assertEquals( browserConnection1, browserConnection1.getSearchManager().getSearches().get(
0 )
+            .getBrowserConnection() );
+        assertEquals( 1, browserConnection2.getSearchManager().getSearches().size() );
+        assertEquals( browserConnection2, browserConnection2.getSearchManager().getSearches().get(
0 )
+            .getBrowserConnection() );
+    }
+
+}



Mime
View raw message