directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r882586 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: BrowserTest.java EntryEditorTest.java
Date Fri, 20 Nov 2009 14:48:56 GMT
Author: seelmann
Date: Fri Nov 20 14:48:55 2009
New Revision: 882586

URL: http://svn.apache.org/viewvc?rev=882586&view=rev
Log:
Tests for DIRSTUDIO-597 (Modification sent to the server while browsing through the DIT and
refreshing entries)

Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java

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=882586&r1=882585&r2=882586&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 Nov 20 14:48:55 2009
@@ -46,9 +46,11 @@
 import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
+import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.ReferralDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.SearchLogsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.eclipse.jface.dialogs.ErrorDialog;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -73,6 +75,7 @@
     private ConnectionsViewBot connectionsViewBot;
     private BrowserViewBot browserViewBot;
     private SearchLogsViewBot searchLogsViewBot;
+    private ModificationLogsViewBot modificationLogsViewBot;
 
     private Connection connection;
 
@@ -86,6 +89,7 @@
         connection = connectionsViewBot.createTestConnection( "BrowserTest", ldapServer.getPort()
);
         browserViewBot = studioBot.getBrowserView();
         searchLogsViewBot = studioBot.getSearchLogsViewBot();
+        modificationLogsViewBot = studioBot.getModificationLogsViewBot();
     }
 
 
@@ -122,6 +126,8 @@
         int countMatchesAfter = StringUtils.countMatches( text, "#!SEARCH REQUEST" );
 
         assertEquals( "Expected exactly 1 search request", 1, countMatchesAfter - countMatchesBefore
);
+
+        assertEquals( "No modification expected", "", modificationLogsViewBot.getModificationLogsText()
);
     }
 
 
@@ -184,6 +190,8 @@
         List<String> attributeValues = entryEditorBot.getAttributeValues();
         assertEquals( 23, attributeValues.size() );
         assertTrue( attributeValues.contains( "uid: user.1" ) );
+
+        assertEquals( "No modification expected", "", modificationLogsViewBot.getModificationLogsText()
);
     }
 
 
@@ -415,5 +423,51 @@
         assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
             "cn=\\#ACL_AD-Projects_Author" ) );
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ACL_AD-Projects_Author"
);
+
+        assertEquals( "No modification expected", "", modificationLogsViewBot.getModificationLogsText()
);
     }
+
+
+    /**
+     * Test for DIRSTUDIO-597.
+     * (Modification sent to the server while browsing through the DIT and refreshing entries)
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testNoModificationWhileBrowsingAndRefreshing() throws Exception
+    {
+        boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
+        ErrorDialog.AUTOMATED_MODE = false;
+
+        String text = modificationLogsViewBot.getModificationLogsText();
+        assertEquals( "", text );
+
+        try
+        {
+            assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
+                "cn=\\#ACL_AD-Projects_Author" ) );
+
+            for ( int i = 0; i < 5; i++ )
+            {
+                // select entry and refresh
+                browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ACL_AD-Projects_Author"
);
+                browserViewBot.refresh();
+
+                // select parent and refresh
+                browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+                browserViewBot.refresh();
+            }
+        }
+        finally
+        {
+            // reset flag
+            ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
+        }
+
+        // check that modification logs is still empty 
+        // to ensure that no modification was sent to the server
+        assertEquals( "No modification expected", "", modificationLogsViewBot.getModificationLogsText()
);
+    }
+
 }

Modified: 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=882586&r1=882585&r2=882586&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
Fri Nov 20 14:48:55 2009
@@ -24,7 +24,9 @@
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
+import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertContains;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.directory.server.core.integ.Level;
 import org.apache.directory.server.core.integ.annotations.ApplyLdifFiles;
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
@@ -34,6 +36,7 @@
 import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.DnEditorDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
+import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.NewAttributeWizardBot;
 import org.apache.directory.studio.test.integration.ui.bots.SelectDnDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
@@ -61,6 +64,7 @@
     private StudioBot studioBot;
     private ConnectionsViewBot connectionsViewBot;
     private BrowserViewBot browserViewBot;
+    private ModificationLogsViewBot modificationLogsViewBot;
 
 
     @Before
@@ -71,6 +75,7 @@
         connectionsViewBot = studioBot.getConnectionView();
         connectionsViewBot.createTestConnection( "EntryEditorTest", ldapServer.getPort()
);
         browserViewBot = studioBot.getBrowserView();
+        modificationLogsViewBot = studioBot.getModificationLogsViewBot();
     }
 
 
@@ -97,8 +102,10 @@
         String dn = entryEditorBot.getDnText();
         assertEquals( "DN: cn=Barbara Jensen,ou=users,ou=system", dn );
         assertEquals( 8, entryEditorBot.getAttributeValues().size() );
+        assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
 
         // add description attribute
+        entryEditorBot.activate();
         NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
         assertTrue( wizardBot.isVisible() );
         wizardBot.typeAttributeType( "description" );
@@ -106,13 +113,18 @@
         entryEditorBot.typeValueAndFinish( "This is the 1st description." );
         assertEquals( 9, entryEditorBot.getAttributeValues().size() );
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
1st description." ) );
+        assertContains( "add: description\ndescription: This is the 1st description.", modificationLogsViewBot
+            .getModificationLogsText() );
 
         // add second value
+        entryEditorBot.activate();
         entryEditorBot.addValue( "description" );
         entryEditorBot.typeValueAndFinish( "This is the 2nd description." );
         assertEquals( 10, entryEditorBot.getAttributeValues().size() );
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
1st description." ) );
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
2nd description." ) );
+        assertContains( "add: description\ndescription: This is the 2nd description.", modificationLogsViewBot
+            .getModificationLogsText() );
 
         // edit second value
         entryEditorBot.editValue( "description", "This is the 2nd description." );
@@ -122,12 +134,18 @@
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
1st description." ) );
         assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is
the 2nd description." ) );
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
3rd description." ) );
+        assertContains( "delete: description\ndescription: This is the 2nd description.",
modificationLogsViewBot
+            .getModificationLogsText() );
+        assertContains( "add: description\ndescription: This is the 3rd description.", modificationLogsViewBot
+            .getModificationLogsText() );
 
         // delete second value
         entryEditorBot.deleteValue( "description", "This is the 3rd description." );
         assertEquals( 9, entryEditorBot.getAttributeValues().size() );
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
1st description." ) );
         assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is
the 3rd description." ) );
+        assertContains( "delete: description\ndescription: This is the 3rd description.",
modificationLogsViewBot
+            .getModificationLogsText() );
 
         // edit 1st value
         entryEditorBot.editValue( "description", "This is the 1st description." );
@@ -135,11 +153,17 @@
         assertEquals( 9, entryEditorBot.getAttributeValues().size() );
         assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is
the 1st description." ) );
         assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the
final description." ) );
+        assertContains( "replace: description\ndescription: This is the final description.",
modificationLogsViewBot
+            .getModificationLogsText() );
 
         // delete 1st value/attribute
         entryEditorBot.deleteValue( "description", "This is the final description." );
         assertEquals( 8, entryEditorBot.getAttributeValues().size() );
         assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is
the final description." ) );
+        assertContains( "delete: description\n-", modificationLogsViewBot.getModificationLogsText()
);
+
+        assertEquals( "Expected 6 modifications.", 6, StringUtils.countMatches( modificationLogsViewBot
+            .getModificationLogsText(), "#!RESULT OK" ) );
     }
 
 
@@ -182,6 +206,9 @@
             "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system" );
         assertEquals( "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system", dnEditorBot.getDnText()
);
         dnEditorBot.clickCancelButton();
+
+        assertEquals( "Expected 1 modification.", 1, StringUtils.countMatches( modificationLogsViewBot
+            .getModificationLogsText(), "#!RESULT OK" ) );
     }
 
 }



Mime
View raw message