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 2009/02/27 11:30:38 UTC

svn commit: r748477 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: AutomatedSuite.java EntryEditorTest.java ImportExportTest.java

Author: seelmann
Date: Fri Feb 27 10:30:37 2009
New Revision: 748477

URL: http://svn.apache.org/viewvc?rev=748477&view=rev
Log:
DIRSTUDIO-465: Added test to ensure that root DSE is reloaded when importing an context entry

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/EntryEditorTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.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=748477&r1=748476&r2=748477&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 Feb 27 10:30:37 2009
@@ -48,6 +48,9 @@
 
 		// Test Connections view
 		addTest(new TestSuite(NewConnectionWizardTest.class));
+		
+		// Test Import/Export
+		addTest(new TestSuite(ImportExportTest.class));
 
 		// Test Browser view
 		addTest(new TestSuite(NewEntryWizardTest.class));
@@ -57,9 +60,6 @@
 		// Test Entry editor
 		addTest(new TestSuite(EntryEditorTest.class));
 
-		// Test Import/Export
-		addTest(new TestSuite(ImportExportTest.class));
-
 		// Test allocated resources
 		// addTest( new TestSuite( SwtResourcesTest.class ) );
 	}

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=748477&r1=748476&r2=748477&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 Feb 27 10:30:37 2009
@@ -188,7 +188,7 @@
 
 		// delete 1st value/attribute
 		entryEditorTree.select(6);
-		entryEditorTree.contextMenu("Delete Attribute").click();
+		entryEditorTree.contextMenu("Delete Value").click();
 		SWTBotUtils.asyncClick(bot, bot.button("OK"), new DefaultCondition() {
 			public boolean test() throws Exception {
 				return !entryEditorTree.cell(6, 0).equals("description");

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java?rev=748477&r1=748476&r2=748477&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java Fri Feb 27 10:30:37 2009
@@ -22,13 +22,17 @@
 
 import java.io.File;
 import java.net.URL;
+import java.util.List;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.unit.AbstractServerTest;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
 import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 
 /**
  * Tests the import and export (LDIF, DSML).
@@ -38,20 +42,20 @@
  * @version $Rev$, $Date$
  */
 public class ImportExportTest extends AbstractServerTest {
-	private SWTEclipseBot bot;
+	private SWTEclipseBot eBot;
 
 	protected void setUp() throws Exception {
 		super.setUp();
 		super.loadTestLdif(false);
-		bot = new SWTEclipseBot();
-		SWTBotUtils.openLdapPerspective(bot);
-		SWTBotUtils.createTestConnection(bot, "ImportExportTest", ldapService
+		eBot = new SWTEclipseBot();
+		SWTBotUtils.openLdapPerspective(eBot);
+		SWTBotUtils.createTestConnection(eBot, "ImportExportTest", ldapService
 				.getPort());
 	}
 
 	protected void tearDown() throws Exception {
 		SWTBotUtils.deleteTestConnections();
-		bot = null;
+		eBot = null;
 		super.tearDown();
 	}
 
@@ -70,13 +74,13 @@
 		URL url = Platform.getInstanceLocation().getURL();
 		String file = url.getFile() + "ImportExportTest.ldif";
 
-		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(eBot);
 
-		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+		SWTBotUtils.selectEntry(eBot, browserTree, false, "DIT", "Root DSE",
 				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
 
 		// export LDIF
-		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("LDIF Export..."),
+		SWTBotUtils.asyncClick(eBot, browserTree.contextMenu("LDIF Export..."),
 				new DefaultCondition() {
 					public boolean test() throws Exception {
 						return bot.shell("LDIF Export") != null;
@@ -86,9 +90,9 @@
 						return "Could not find dialog 'LDIF Export'";
 					}
 				});
-		bot.button("Next >").click();
-		bot.comboBoxWithLabel("LDIF File:").setText(file);
-		bot.button("Finish").click();
+		eBot.button("Next >").click();
+		eBot.comboBoxWithLabel("LDIF File:").setText(file);
+		eBot.button("Finish").click();
 
 		// verify that exported LDIF starts with the Base64 encoded DN
 		String content = FileUtils.readFileToString(new File(file));
@@ -98,7 +102,7 @@
 						.startsWith("dn:: Y249V29sZmdhbmcgS8O2bGJlbCxvdT11c2VycyxvdT1zeXN0ZW0="));
 
 		// delete entry
-		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("Delete Entry"),
+		SWTBotUtils.asyncClick(eBot, browserTree.contextMenu("Delete Entry"),
 				new DefaultCondition() {
 					public boolean test() throws Exception {
 						return bot.shell("Delete Entry") != null;
@@ -108,7 +112,7 @@
 						return "Could not find dialog 'New Entry'";
 					}
 				});
-		SWTBotUtils.asyncClick(bot, bot.button("OK"), new DefaultCondition() {
+		SWTBotUtils.asyncClick(eBot, eBot.button("OK"), new DefaultCondition() {
 			public boolean test() throws Exception {
 				return browserTree.selection().get(0).get(0).startsWith(
 						"ou=users");
@@ -120,7 +124,7 @@
 		});
 
 		// import LDIF
-		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("LDIF Import..."),
+		SWTBotUtils.asyncClick(eBot, browserTree.contextMenu("LDIF Import..."),
 				new DefaultCondition() {
 					public boolean test() throws Exception {
 						return bot.shell("LDIF Import") != null;
@@ -130,11 +134,11 @@
 						return "Could not find dialog 'LDIF Import'";
 					}
 				});
-		bot.comboBoxWithLabel("LDIF File:").setText(file);
-		bot.button("Finish").click();
+		eBot.comboBoxWithLabel("LDIF File:").setText(file);
+		eBot.button("Finish").click();
 
 		// verify that entry with umlaut exists
-		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+		SWTBotUtils.selectEntry(eBot, browserTree, false, "DIT", "Root DSE",
 				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
 	}
 
@@ -153,14 +157,14 @@
 		URL url = Platform.getInstanceLocation().getURL();
 		String file = url.getFile() + "ImportExportTest.dsml";
 
-		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(eBot);
 
-		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+		SWTBotUtils.selectEntry(eBot, browserTree, false, "DIT", "Root DSE",
 				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
-		bot.sleep(2000);
+		eBot.sleep(2000);
 
 		// export DSML
-		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("DSML Export..."),
+		SWTBotUtils.asyncClick(eBot, browserTree.contextMenu("DSML Export..."),
 				new DefaultCondition() {
 					public boolean test() throws Exception {
 						return bot.shell("DSML Export") != null;
@@ -170,18 +174,18 @@
 						return "Could not find dialog 'DSML Export'";
 					}
 				});
-		bot.button("Next >").click();
-		bot.comboBoxWithLabel("DSML File:").setText(file);
-		bot.radio("DSML Request").click();
-		bot.button("Finish").click();
+		eBot.button("Next >").click();
+		eBot.comboBoxWithLabel("DSML File:").setText(file);
+		eBot.radio("DSML Request").click();
+		eBot.button("Finish").click();
 
 		// verify that exported DSML contains the Base64 encoded DN
 		String content = FileUtils.readFileToString(new File(file));
 		assertTrue("DSML must contain DN with umlaut.", content
-				.contains("dn=\"cn=Wolfgang Kölbel,ou=users,ou=system\""));
+				.contains("dn=\"cn=Wolfgang K\u00f6lbel,ou=users,ou=system\""));
 
 		// delete entry
-		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("Delete Entry"),
+		SWTBotUtils.asyncClick(eBot, browserTree.contextMenu("Delete Entry"),
 				new DefaultCondition() {
 					public boolean test() throws Exception {
 						return bot.shell("Delete Entry") != null;
@@ -191,7 +195,7 @@
 						return "Could not find dialog 'New Entry'";
 					}
 				});
-		SWTBotUtils.asyncClick(bot, bot.button("OK"), new DefaultCondition() {
+		SWTBotUtils.asyncClick(eBot, eBot.button("OK"), new DefaultCondition() {
 			public boolean test() throws Exception {
 				return browserTree.selection().get(0).get(0).startsWith(
 						"ou=users");
@@ -203,7 +207,7 @@
 		});
 
 		// import DSML
-		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("DSML Import..."),
+		SWTBotUtils.asyncClick(eBot, browserTree.contextMenu("DSML Import..."),
 				new DefaultCondition() {
 					public boolean test() throws Exception {
 						return bot.shell("DSML Import") != null;
@@ -213,12 +217,88 @@
 						return "Could not find dialog 'LDIF Import'";
 					}
 				});
-		bot.comboBoxWithLabel("DSML File:").setText(file);
-		bot.button("Finish").click();
+		eBot.comboBoxWithLabel("DSML File:").setText(file);
+		eBot.button("Finish").click();
 
 		// verify that entry with umlaut exists
-		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+		SWTBotUtils.selectEntry(eBot, browserTree, false, "DIT", "Root DSE",
 				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
 	}
 
+	/**
+     * Test for DIRSTUDIO-465.
+     * 
+     * Import a new context entry must refresh the root DSE and 
+     * show the new context entry in the LDAP Browser view.
+     * 
+     * @throws Exception
+     *             the exception
+     */
+    public void testImportContextEntryRefreshesRootDSE() throws Exception
+    {
+        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( eBot );
+
+        // add a new partition
+        Partition partition = new JdbmPartition();
+        partition.setId( "example" );
+        partition.setSuffix( "dc=example,dc=com" );
+        directoryService.addPartition( partition );
+
+        // refresh root DSE and ensure that the partition is in root DSE
+        SWTBotTreeItem rootDSE = SWTBotUtils.selectEntry( eBot, browserTree, false, "DIT", "Root DSE" );
+        SWTBotUtils.asyncClick( eBot, browserTree.contextMenu( "Reload Attributes and Children" ),
+            new DefaultCondition()
+            {
+                public boolean test() throws Exception
+                {
+                    SWTBotUtils.selectEntry( eBot, browserTree, false, "DIT", "Root DSE" );
+                    final SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( eBot );
+                    String text = entryEditorTree.cell( 2, 1 );
+                    System.out.println( text );
+                    return "dc=example,dc=com".equals( text );
+                }
+
+
+                public String getFailureMessage()
+                {
+                    return "New partition 'dc=example,dc=com' not found in Root DSE entry";
+                }
+            } );
+
+        // ensure context entry is not there
+        rootDSE = SWTBotUtils.selectEntry( eBot, browserTree, false, "DIT", "Root DSE" );
+        List<String> nodes = rootDSE.getNodes();
+        for ( String node : nodes )
+        {
+            if ( node.startsWith( "dc=example,dc=com" ) )
+            {
+                fail( "dc=example,dc=com should not exist yet" );
+            }
+        }
+
+        // import
+        URL url = Platform.getInstanceLocation().getURL();
+        String file = url.getFile() + "ImportContextEntry.ldif";
+        String data = "dn:dc=example,dc=com\nobjectClass:top\nobjectClass:domain\ndc:example\n\n";
+        FileUtils.writeStringToFile( new File( file ), data );
+        SWTBotUtils.asyncClick( eBot, browserTree.contextMenu( "LDIF Import..." ), new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return bot.shell( "LDIF Import" ) != null;
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Could not find dialog 'LDIF Import'";
+            }
+        } );
+        eBot.comboBoxWithLabel( "LDIF File:" ).setText( file );
+        eBot.button( "Finish" ).click();
+
+        // ensure context entry is there now, without a manual refresh
+        SWTBotUtils.selectEntry( eBot, browserTree, false, "DIT", "Root DSE", "dc=example,dc=com" );
+    }
+	
 }