You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/08/25 14:45:31 UTC
svn commit: r688708 - in
/directory/studio/trunk/test-integration-ui/src/main:
java/org/apache/directory/studio/test/integration/ui/
resources/org/apache/directory/studio/test/integration/ui/
Author: seelmann
Date: Mon Aug 25 05:45:31 2008
New Revision: 688708
URL: http://svn.apache.org/viewvc?rev=688708&view=rev
Log:
Added first test for the Entry Editor
Added:
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
directory/studio/trunk/test-integration-ui/src/main/resources/org/apache/directory/studio/test/integration/ui/EntryEditorTest.ldif
Removed:
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreparationTest.java
Modified:
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/SWTBotUtils.java
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=688708&r1=688707&r2=688708&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 Mon Aug 25 05:45:31 2008
@@ -23,6 +23,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
/**
@@ -42,13 +43,28 @@
public AutomatedSuite()
{
- addTest( new TestSuite( PreparationTest.class ) );
+ // Test Preparation: close welcome view
+ try
+ {
+ SWTEclipseBot bot = new SWTEclipseBot();
+ bot.view( "Welcome" ).close();
+ }
+ catch ( Exception e )
+ {
+ }
+ // Test Connections view
addTest( new TestSuite( NewConnectionWizardTest.class ) );
+
+ // Test Browser view
addTest( new TestSuite( NewEntryWizardTest.class ) );
addTest( new TestSuite( RenameEntryDialogTest.class ) );
addTest( new TestSuite( ReferralDialogTest.class ) );
+ // Test Entry editor
+ addTest( new TestSuite( EntryEditorTest.class ) );
+
+ // Test allocated resources
addTest( new TestSuite( SwtResourcesTest.class ) );
}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java?rev=688708&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java Mon Aug 25 05:45:31 2008
@@ -0,0 +1,236 @@
+/*
+ * 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 net.sf.swtbot.eclipse.finder.SWTEclipseBot;
+import net.sf.swtbot.wait.DefaultCondition;
+import net.sf.swtbot.widgets.SWTBotTree;
+
+import org.apache.directory.server.unit.AbstractServerTest;
+
+
+/**
+ * Tests the new entry wizard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorTest extends AbstractServerTest
+{
+ private SWTEclipseBot bot;
+
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ super.loadTestLdif( true );
+ bot = new SWTEclipseBot();
+ SWTBotUtils.openLdapPerspective( bot );
+ SWTBotUtils.createTestConnection( bot, "EntryEditorTest", ldapServer.getIpPort() );
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ SWTBotUtils.deleteTestConnections();
+ bot = null;
+ super.tearDown();
+ }
+
+
+ /**
+ * Test to create a single organization entry.
+ *
+ * @throws Exception the exception
+ */
+ public void testAddEditDeleteAttribute() throws Exception
+ {
+ final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+ SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
+ "cn=Barbara Jensen" );
+
+ final SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot );
+
+ // add description attribute
+ entryEditorTree.contextMenu( "New Attribute..." ).click();
+ bot.comboBoxWithLabel( "Attribute type:" ).setText( "description" );
+ SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return bot.text( "" ) != null;
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find empty description attribute";
+ }
+ } );
+ bot.text( "" ).setText( "This is the 1st description." );
+ SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return entryEditorTree.cell( 6, 0 ).equals( "description" )
+ && entryEditorTree.cell( 6, 1 ).equals( "This is the 1st description." );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find attribute 'description:This is the 1st description.'";
+ }
+ } );
+
+ // add second value
+ entryEditorTree.getTreeItem( "description" ).click();
+ SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "New Value" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return bot.text( "" ) != null;
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find empty description attribute";
+ }
+ } );
+ bot.text( "" ).setText( "This is the 2nd description." );
+ SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return entryEditorTree.cell( 7, 0 ).equals( "description" )
+ && entryEditorTree.cell( 7, 1 ).equals( "This is the 2nd description." );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find attribute 'description:This is the 2nd description.'";
+ }
+ } );
+
+ // edit second value
+ entryEditorTree.select( 7 );
+ SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "Edit Value" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return bot.text( "This is the 2nd description." ) != null;
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find description 'This is the 2nd description.'";
+ }
+ } );
+ bot.text( "This is the 2nd description." ).setText( "This is the 3rd description." );
+ SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return entryEditorTree.cell( 7, 0 ).equals( "description" )
+ && entryEditorTree.cell( 7, 1 ).equals( "This is the 3rd description." );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find attribute 'description:This is the 3rd description.'";
+ }
+ } );
+
+ // delete second value
+ entryEditorTree.select( 7 );
+ entryEditorTree.contextMenu( "Delete Value" ).click();
+ SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return !entryEditorTree.cell( 7, 0 ).equals( "description" )
+ && entryEditorTree.cell( 6, 0 ).equals( "description" )
+ && entryEditorTree.cell( 6, 1 ).equals( "This is the 1st description." );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Attribute 'description' is still there.";
+ }
+ } );
+
+ // edit 1st value
+ entryEditorTree.select( 6 );
+ SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "Edit Value" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return bot.text( "This is the 1st description." ) != null;
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find description 'This is the 1st description.'";
+ }
+ } );
+ bot.text( "This is the 1st description." ).setText( "This is the final description." );
+ SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return entryEditorTree.cell( 6, 0 ).equals( "description" )
+ && entryEditorTree.cell( 6, 1 ).equals( "This is the final description." );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find attribute 'description:This is the final description.'";
+ }
+ } );
+
+ // delete 1st value/attribute
+ entryEditorTree.select( 6 );
+ entryEditorTree.contextMenu( "Delete Attribute" ).click();
+ SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return !entryEditorTree.cell( 6, 0 ).equals( "description" );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Attribute 'description' is still there.";
+ }
+ } );
+
+ }
+
+}
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=688708&r1=688707&r2=688708&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 Mon Aug 25 05:45:31 2008
@@ -29,6 +29,7 @@
import net.sf.swtbot.eclipse.finder.widgets.SWTBotView;
import net.sf.swtbot.finder.ControlFinder;
import net.sf.swtbot.finder.UIThreadRunnable;
+import net.sf.swtbot.finder.UIThreadRunnable.VoidResult;
import net.sf.swtbot.matcher.ClassMatcher;
import net.sf.swtbot.wait.DefaultCondition;
import net.sf.swtbot.wait.ICondition;
@@ -49,6 +50,8 @@
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
/**
@@ -202,6 +205,46 @@
/**
+ * Gets the entry editor tree.
+ *
+ * @param bot the bot
+ *
+ * @return the entry editor tree
+ *
+ * @throws Exception the exception
+ */
+ public static SWTBotTree getEntryEditorTree( SWTEclipseBot bot ) throws Exception
+ {
+ List findEditors = SWTBotView.findEditors();
+ for ( Object object : findEditors )
+ {
+ final IEditorReference editorReference = ( IEditorReference ) object;
+ if ( editorReference.getName().equals( "Entry Editor" ) )
+ {
+ UIThreadRunnable.syncExec( new VoidResult()
+ {
+ public void run()
+ {
+ IEditorPart editor = editorReference.getEditor( true );
+ editorReference.getPage().activate( editor );
+ }
+ } );
+
+ final SWTBotView editor = new SWTBotView( editorReference );
+ List<Tree> findControls = new ControlFinder().findControls( editor.widget,
+ new ClassMatcher( Tree.class ), true );
+ if ( findControls.isEmpty() )
+ {
+ throw new WidgetNotFoundException( "Could not find Entry Editor tree" );
+ }
+ return new SWTBotTree( findControls.get( 0 ) );
+ }
+ }
+ throw new WidgetNotFoundException( "Could not find Entry Editor tree" );
+ }
+
+
+ /**
* Clicks a button asynchronously and waits till the given condition
* is fulfilled.
*
@@ -272,6 +315,34 @@
/**
+ * Clicks a tree item asynchronously and waits till the given condition
+ * is fulfilled.
+ *
+ * @param bot the SWT bot
+ * @param item the tree item to click
+ * @param waitCondition the condition to wait for, may be null
+ *
+ * @throws TimeoutException the timeout exception
+ */
+ public static void asyncClick( final SWTEclipseBot bot, final SWTBotTreeItem item, final ICondition waitCondition )
+ throws TimeoutException
+ {
+ UIThreadRunnable.asyncExec( bot.getDisplay(), new UIThreadRunnable.VoidResult()
+ {
+ public void run()
+ {
+ item.click();
+ }
+ } );
+
+ if ( waitCondition != null )
+ {
+ bot.waitUntil( waitCondition );
+ }
+ }
+
+
+ /**
* 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.
Added: directory/studio/trunk/test-integration-ui/src/main/resources/org/apache/directory/studio/test/integration/ui/EntryEditorTest.ldif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/resources/org/apache/directory/studio/test/integration/ui/EntryEditorTest.ldif?rev=688708&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/resources/org/apache/directory/studio/test/integration/ui/EntryEditorTest.ldif (added)
+++ directory/studio/trunk/test-integration-ui/src/main/resources/org/apache/directory/studio/test/integration/ui/EntryEditorTest.ldif Mon Aug 25 05:45:31 2008
@@ -0,0 +1,10 @@
+dn: cn=Barbara Jensen,ou=users,ou=system
+objectClass: inetOrgPerson
+objectClass: organizationalPerson
+objectClass: person
+objectClass: top
+cn: Barbara Jensen
+sn: Jensen
+givenName: Barbara
+uid: bjensen
+