directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r828973 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: ./ bots/
Date Fri, 23 Oct 2009 09:33:07 GMT
Author: seelmann
Date: Fri Oct 23 09:33:07 2009
New Revision: 828973

URL: http://svn.apache.org/viewvc?rev=828973&view=rev
Log:
Added tests for DIRSTUDIO-409

Modified:
    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/bots/BrowserViewBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.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/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=828973&r1=828972&r2=828973&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
Fri Oct 23 09:33:07 2009
@@ -32,15 +32,22 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 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.name.LdapDN;
+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.NewEntryWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.ReferralDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.jface.dialogs.ErrorDialog;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -63,12 +70,14 @@
     private ConnectionsViewBot connectionsViewBot;
     private BrowserViewBot browserViewBot;
 
-    private SWTWorkbenchBot bot;
+    private Connection connection;
 
 
     @Before
     public void setUp() throws Exception
     {
+        ErrorDialog.AUTOMATED_MODE = false;
+
         // check if krb5kdc is disabled
         DirContext schemaRoot = ( DirContext ) getWiredContext( ldapServer ).lookup( "ou=schema"
);
         Attributes krb5kdcAttrs = schemaRoot.getAttributes( "cn=Krb5kdc" );
@@ -86,13 +95,19 @@
             schemaRoot.modifyAttributes( "cn=Krb5kdc", mods );
         }
 
+        // create referral entry
+        ServerEntry entry = new DefaultServerEntry( ldapServer.getDirectoryService().getRegistries()
);
+        entry.setDn( new LdapDN( "cn=referral,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 );
+
         studioBot = new StudioBot();
         studioBot.resetLdapPerspective();
         connectionsViewBot = studioBot.getConnectionView();
-        connectionsViewBot.createTestConnection( "NewEntryWizardTest", ldapServer.getPort()
);
+        connection = connectionsViewBot.createTestConnection( "NewEntryWizardTest", ldapServer.getPort()
);
         browserViewBot = studioBot.getBrowserView();
-
-        bot = new SWTWorkbenchBot();
     }
 
 
@@ -100,18 +115,14 @@
     public void tearDown() throws Exception
     {
         connectionsViewBot.deleteTestConnections();
-        bot = null;
     }
 
 
     /**
      * Test to create a single organization entry.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testCreateOrganizationEntry() throws Exception
+    public void testCreateOrganizationEntry()
     {
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
 
@@ -160,19 +171,16 @@
 
         wizardBot.clickFinishButton();
 
-        browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "o=testCreateOrganizationEntry"
);
+        assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "o=testCreateOrganizationEntry"
) );
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "o=testCreateOrganizationEntry"
);
     }
 
 
     /**
      * Test to create a single person entry.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testCreatePersonEntry() throws Exception
+    public void testCreatePersonEntry()
     {
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
 
@@ -191,7 +199,7 @@
         wizardBot.setAttributeValue( "sn", 1, "test" );
         wizardBot.clickFinishButton();
 
-        browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "cn=testCreatePersonEntry"
);
+        assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "cn=testCreatePersonEntry"
) );
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "cn=testCreatePersonEntry"
);
     }
 
@@ -201,12 +209,9 @@
      * 
      * Create entries with upper case attribute types and ensures that the
      * retrieved entries still are in upper case.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testCreateUpperCaseOrganizationEntries() throws Exception
+    public void testCreateUpperCaseOrganizationEntries()
     {
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
 
@@ -224,7 +229,7 @@
 
         wizardBot.clickFinishButton();
 
-        browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "O=testCreateOrganizationEntry"
);
+        assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "O=testCreateOrganizationEntry"
) );
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "O=testCreateOrganizationEntry"
);
 
         // Now create a second entry under the previously created entry
@@ -246,8 +251,8 @@
 
         wizardBot.clickFinishButton();
 
-        browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "O=testCreateOrganizationEntry",
-            "O=testCreateOrganizationEntry2" );
+        assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "O=testCreateOrganizationEntry",
+            "O=testCreateOrganizationEntry2" ) );
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "O=testCreateOrganizationEntry",
             "O=testCreateOrganizationEntry2" );
     }
@@ -257,12 +262,9 @@
      * Test for DIRSTUDIO-360.
      * 
      * Create entries with a slash '/' in the RDN value.
-     * 
-     * @throws Exception
-     *             the exception
      */
     @Test
-    public void testCreateEntryWithSlash() throws Exception
+    public void testCreateEntryWithSlash()
     {
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
 
@@ -282,8 +284,96 @@
         wizardBot.setAttributeValue( "sn", 1, "test" );
         wizardBot.clickFinishButton();
 
-        browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "krb5PrincipalName=kadmin/changepw@DOMAIN"
);
+        assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system",
+            "krb5PrincipalName=kadmin/changepw@DOMAIN" ) );
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "krb5PrincipalName=kadmin/changepw@DOMAIN"
);
     }
 
+
+    /**
+     * Test for DIRSTUDIO-409.
+     *
+     * Try to create an entry below an referral object.
+     * The connection selection dialog pops up and we cancel the selection.
+     * No error should occur and the wizard is not closed.
+     */
+    @Test
+    public void testCreateEntryBelowReferralObjectCancel()
+    {
+        // set ManageDsaIT control
+        connection.getConnectionParameter().setExtendedIntProperty(
+            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD, ReferralHandlingMethod.IGNORE.ordinal()
);
+        connection.getConnectionParameter().setExtendedBoolProperty(
+            IBrowserConnection.CONNECTION_PARAMETER_MANAGE_DSA_IT, true );
+
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "cn=referral" );
+
+        NewEntryWizardBot wizardBot = browserViewBot.openNewEntryWizard();
+
+        wizardBot.selectCreateEntryFromScratch();
+        wizardBot.clickNextButton();
+
+        wizardBot.addObjectClasses( "organization" );
+        wizardBot.clickNextButton();
+
+        wizardBot.setRdnType( 1, "o" );
+        wizardBot.setRdnValue( 1, "orgBelowReferral" );
+        wizardBot.clickNextButton();
+
+        ReferralDialogBot referralDialogBot = wizardBot.clickFinishButtonExpectingReferralDialog();
+        assertTrue( referralDialogBot.isVisible() );
+
+        // click cancel button, check the wizard is not closed
+        referralDialogBot.clickCancelButton();
+        assertTrue( wizardBot.isVisible() );
+        assertTrue( wizardBot.isFinishButtonEnabled() );
+
+        wizardBot.clickCancelButton();
+
+        assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
"o=orgBelowReferral" ) );
+    }
+
+
+    /**
+     * Test for DIRSTUDIO-409.
+     *
+     * Try to create an entry below an referral object.
+     * The connection selection dialog pops up and we select a connection.
+     * The entry is created under the target entry.
+     */
+    @Test
+    public void testCreateEntryBelowReferralObjectFollow()
+    {
+        // set ManageDsaIT control
+        connection.getConnectionParameter().setExtendedIntProperty(
+            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD, ReferralHandlingMethod.IGNORE.ordinal()
);
+        connection.getConnectionParameter().setExtendedBoolProperty(
+            IBrowserConnection.CONNECTION_PARAMETER_MANAGE_DSA_IT, true );
+
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "cn=referral" );
+
+        NewEntryWizardBot wizardBot = browserViewBot.openNewEntryWizard();
+
+        wizardBot.selectCreateEntryFromScratch();
+        wizardBot.clickNextButton();
+
+        wizardBot.addObjectClasses( "organization" );
+        wizardBot.clickNextButton();
+
+        wizardBot.setRdnType( 1, "o" );
+        wizardBot.setRdnValue( 1, "orgBelowReferral" );
+        wizardBot.clickNextButton();
+
+        ReferralDialogBot referralDialogBot = wizardBot.clickFinishButtonExpectingReferralDialog();
+        assertTrue( referralDialogBot.isVisible() );
+
+        // follow referral, click ok button
+        referralDialogBot.selectConnection( "NewEntryWizardTest" );
+        referralDialogBot.clickOkButton();
+
+        // check entry was created under referral target entry
+        assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
"o=orgBelowReferral" ) );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "o=orgBelowReferral"
);
+    }
+
 }

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=828973&r1=828972&r2=828973&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
Fri Oct 23 09:33:07 2009
@@ -197,7 +197,7 @@
         assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal
);
         assertTrue( manageDsaIT );
 
-        // expand ou=system, that reads the referral and opens the referral dialog
+        // expand ou=system, that reads the referral object
         browserViewBot.expandEntry( parentPath );
 
         // ensure that the referral entry exists

Modified: 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=828973&r1=828972&r2=828973&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
Fri Oct 23 09:33:07 2009
@@ -27,10 +27,12 @@
 import org.apache.directory.studio.test.integration.ui.ContextMenuHelper;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
 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.waits.ICondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 
@@ -180,8 +182,30 @@
     }
 
 
-    private void select( SWTBotTreeItem entry )
+    private void select( final SWTBotTreeItem entry )
     {
+        if ( !getBrowserTree().isEnabled() )
+        {
+            bot.waitUntil( new ICondition()
+            {
+
+                public boolean test() throws Exception
+                {
+                    return getBrowserTree().isEnabled();
+                }
+
+
+                public void init( SWTBot bot )
+                {
+                }
+
+
+                public String getFailureMessage()
+                {
+                    return "Entry " + entry + " is not enabled!";
+                }
+            } );
+        }
         entry.click();
         entry.select();
     }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java?rev=828973&r1=828972&r2=828973&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java
Fri Oct 23 09:33:07 2009
@@ -95,4 +95,11 @@
         }
     }
 
+
+    public ReferralDialogBot clickFinishButtonExpectingReferralDialog()
+    {
+        clickFinishButton();
+        return new ReferralDialogBot();
+    }
+
 }

Modified: 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=828973&r1=828972&r2=828973&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java
Fri Oct 23 09:33:07 2009
@@ -27,6 +27,12 @@
 public class ReferralDialogBot extends DialogBot
 {
 
+    public boolean isVisible()
+    {
+        return super.isVisible( "Select Referral Connection" );
+    }
+
+
     public void clickOkButton()
     {
         super.clickButton( "OK" );



Mime
View raw message