directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r741561 [2/3] - in /directory/studio/trunk: ./ repository/ repository/net/ repository/org/eclipse/swtbot/ repository/org/eclipse/swtbot/eclipse/ repository/org/eclipse/swtbot/eclipse/core/ repository/org/eclipse/swtbot/eclipse/core/2.0.0.13...
Date Fri, 06 Feb 2009 13:22:01 GMT
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=741561&r1=741560&r2=741561&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  6 13:21:59 2009
@@ -20,237 +20,205 @@
 
 package org.apache.directory.studio.test.integration.ui;
 
-
 import java.io.File;
 import java.net.URL;
 
-import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
-import net.sf.swtbot.wait.DefaultCondition;
-import net.sf.swtbot.widgets.SWTBotTree;
-
 import org.apache.commons.io.FileUtils;
 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;
 
 /**
  * Tests the import and export (LDIF, DSML).
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ *         Project</a>
  * @version $Rev$, $Date$
  */
-public class ImportExportTest extends AbstractServerTest
-{
-    private SWTEclipseBot bot;
-
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        super.loadTestLdif( false );
-        bot = new SWTEclipseBot();
-        SWTBotUtils.openLdapPerspective( bot );
-        SWTBotUtils.createTestConnection( bot, "ImportExportTest", ldapService.getPort() );
-    }
-
-
-    protected void tearDown() throws Exception
-    {
-        SWTBotUtils.deleteTestConnections();
-        bot = null;
-        super.tearDown();
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-395.
-     * 
-     * <li>export an entry with German umlaut in DN to LDIF</li>
-     * <li>verify that exported LDIF starts with the Base64 encoded DN</li>
-     * <li>delete the entry</li>
-     * <li>import the exported LDIF</li>
-     * <li>verify that entry with umlaut exists</li>
-     * 
-     * @throws Exception the exception
-     */
-    public void testExportImportLdifWithGermanUmlautInDN() throws Exception
-    {
-        URL url = Platform.getInstanceLocation().getURL();
-        String file = url.getFile() + "ImportExportTest.ldif";
-
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
-            "cn=Wolfgang K\u00f6lbel" );
-
-        // export LDIF
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "LDIF Export..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "LDIF Export" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'LDIF Export'";
-            }
-        } );
-        bot.button( "Next >" ).click();
-        bot.comboBoxWithLabel( "LDIF File:" ).setText( file );
-        bot.button( "Finish" ).click();
-
-        // verify that exported LDIF starts with the Base64 encoded DN 
-        String content = FileUtils.readFileToString( new File( file ) );
-        assertTrue( "LDIF must start with Base64 encoded DN.", content
-            .startsWith( "dn:: Y249V29sZmdhbmcgS8O2bGJlbCxvdT11c2VycyxvdT1zeXN0ZW0=" ) );
-
-        // delete entry
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "Delete Entry" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "Delete Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-        SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "ou=users" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not select 'ou=system'";
-            }
-        } );
-
-        // import LDIF
-        SWTBotUtils.asyncClick( bot, 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'";
-            }
-        } );
-        bot.comboBoxWithLabel( "LDIF File:" ).setText( file );
-        bot.button( "Finish" ).click();
-
-        // verify that entry with umlaut exists
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
-            "cn=Wolfgang K\u00f6lbel" );
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-395.
-     * 
-     * <li>export an entry with German umlaut in DN to DSML</li>
-     * <li>verify that exported DSML starts with the Base64 encoded DN</li>
-     * <li>delete the entry</li>
-     * <li>import the exported DSML</li>
-     * <li>verify that entry with umlaut exists</li>
-     * 
-     * @throws Exception the exception
-     */
-    public void testExportImportDsmlWithGermanUmlautInDN() throws Exception
-    {
-        URL url = Platform.getInstanceLocation().getURL();
-        String file = url.getFile() + "ImportExportTest.dsml";
-
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
-            "cn=Wolfgang K\u00f6lbel" );
-        bot.sleep( 2000 );
-
-        // export DSML
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "DSML Export..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "DSML Export" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                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();
-
-        // 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\"" ) );
-
-        // delete entry
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "Delete Entry" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "Delete Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-        SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "ou=users" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not select 'ou=system'";
-            }
-        } );
-
-        // import DSML
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "DSML Import..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "DSML Import" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'LDIF Import'";
-            }
-        } );
-        bot.comboBoxWithLabel( "DSML File:" ).setText( file );
-        bot.button( "Finish" ).click();
-
-        // verify that entry with umlaut exists
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
-            "cn=Wolfgang K\u00f6lbel" );
-    }
+public class ImportExportTest extends AbstractServerTest {
+	private SWTEclipseBot bot;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		super.loadTestLdif(false);
+		bot = new SWTEclipseBot();
+		SWTBotUtils.openLdapPerspective(bot);
+		SWTBotUtils.createTestConnection(bot, "ImportExportTest", ldapService
+				.getPort());
+	}
+
+	protected void tearDown() throws Exception {
+		SWTBotUtils.deleteTestConnections();
+		bot = null;
+		super.tearDown();
+	}
+
+	/**
+	 * Test for DIRSTUDIO-395.
+	 * 
+	 * <li>export an entry with German umlaut in DN to LDIF</li> <li>verify that
+	 * exported LDIF starts with the Base64 encoded DN</li> <li>delete the entry
+	 * </li> <li>import the exported LDIF</li> <li>verify that entry with umlaut
+	 * exists</li>
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testExportImportLdifWithGermanUmlautInDN() throws Exception {
+		URL url = Platform.getInstanceLocation().getURL();
+		String file = url.getFile() + "ImportExportTest.ldif";
+
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
+
+		// export LDIF
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("LDIF Export..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("LDIF Export") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'LDIF Export'";
+					}
+				});
+		bot.button("Next >").click();
+		bot.comboBoxWithLabel("LDIF File:").setText(file);
+		bot.button("Finish").click();
+
+		// verify that exported LDIF starts with the Base64 encoded DN
+		String content = FileUtils.readFileToString(new File(file));
+		assertTrue(
+				"LDIF must start with Base64 encoded DN.",
+				content
+						.startsWith("dn:: Y249V29sZmdhbmcgS8O2bGJlbCxvdT11c2VycyxvdT1zeXN0ZW0="));
+
+		// delete entry
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("Delete Entry"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("Delete Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+		SWTBotUtils.asyncClick(bot, bot.button("OK"), new DefaultCondition() {
+			public boolean test() throws Exception {
+				return browserTree.selection().get(0).get(0).startsWith(
+						"ou=users");
+			}
+
+			public String getFailureMessage() {
+				return "Could not select 'ou=system'";
+			}
+		});
+
+		// import LDIF
+		SWTBotUtils.asyncClick(bot, 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'";
+					}
+				});
+		bot.comboBoxWithLabel("LDIF File:").setText(file);
+		bot.button("Finish").click();
+
+		// verify that entry with umlaut exists
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
+	}
+
+	/**
+	 * Test for DIRSTUDIO-395.
+	 * 
+	 * <li>export an entry with German umlaut in DN to DSML</li> <li>verify that
+	 * exported DSML starts with the Base64 encoded DN</li> <li>delete the entry
+	 * </li> <li>import the exported DSML</li> <li>verify that entry with umlaut
+	 * exists</li>
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testExportImportDsmlWithGermanUmlautInDN() throws Exception {
+		URL url = Platform.getInstanceLocation().getURL();
+		String file = url.getFile() + "ImportExportTest.dsml";
+
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
+		bot.sleep(2000);
+
+		// export DSML
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("DSML Export..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("DSML Export") != null;
+					}
+
+					public String getFailureMessage() {
+						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();
+
+		// 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\""));
+
+		// delete entry
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("Delete Entry"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("Delete Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+		SWTBotUtils.asyncClick(bot, bot.button("OK"), new DefaultCondition() {
+			public boolean test() throws Exception {
+				return browserTree.selection().get(0).get(0).startsWith(
+						"ou=users");
+			}
+
+			public String getFailureMessage() {
+				return "Could not select 'ou=system'";
+			}
+		});
+
+		// import DSML
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("DSML Import..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("DSML Import") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'LDIF Import'";
+					}
+				});
+		bot.comboBoxWithLabel("DSML File:").setText(file);
+		bot.button("Finish").click();
+
+		// verify that entry with umlaut exists
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ou=users", "cn=Wolfgang K\u00f6lbel");
+	}
 
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java?rev=741561&r1=741560&r2=741561&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java Fri Feb  6 13:21:59 2009
@@ -20,232 +20,225 @@
 
 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.SWTBotButton;
-import net.sf.swtbot.widgets.SWTBotCombo;
-import net.sf.swtbot.widgets.SWTBotMenu;
-import net.sf.swtbot.widgets.SWTBotText;
-import net.sf.swtbot.widgets.SWTBotTree;
-
 import org.apache.directory.server.unit.AbstractServerTest;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.apache.directory.studio.connection.core.ConnectionManager;
 import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
 import org.eclipse.jface.dialogs.ErrorDialog;
-
+import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 
 /**
  * Tests the new connection wizard.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ *         Project</a>
  * @version $Rev$, $Date$
  */
-public class NewConnectionWizardTest extends AbstractServerTest
-{
-    private SWTEclipseBot bot;
-
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        bot = new SWTEclipseBot();
-        SWTBotUtils.openLdapPerspective( bot );
-    }
-
-
-    protected void tearDown() throws Exception
-    {
-        SWTBotUtils.deleteTestConnections();
-        bot = null;
-        super.tearDown();
-    }
-
-
-    /**
-     * Creates a new connection using the new connection wizard.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCreateConnection() throws Exception
-    {
-        // Select "Connections" view, ensure no connections exists yet
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        assertEquals( 0, connectionsTree.rowCount() );
-
-        // open "New Connection" wizard
-        SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
-        newConnectionMenu.click();
-
-        // get buttons
-        SWTBotButton backButton = bot.button( "< Back" );
-        SWTBotButton nextButton = bot.button( "Next >" );
-        SWTBotButton finishButton = bot.button( "Finish" );
-
-        // ensure "Next >" and "Finish" buttons are disabled
-        assertFalse( backButton.isEnabled() );
-        assertFalse( nextButton.isEnabled() );
-        assertFalse( finishButton.isEnabled() );
-
-        // enter connection parameter
-        SWTBotText connText = bot.textWithLabel( "Connection name:" );
-        connText.setText( "NewConnectionWizardTest" );
-        SWTBotCombo hostnameCombo = bot.comboBoxWithLabel( "Hostname:" );
-        hostnameCombo.setText( "localhost" );
-        SWTBotCombo portCombo = bot.comboBoxWithLabel( "Port:" );
-        portCombo.setText( Integer.toString( ldapService.getPort() ) );
-
-        // ensure "Next >" button is enabled, "Finish" button is disabled
-        assertFalse( backButton.isEnabled() );
-        assertTrue( nextButton.isEnabled() );
-        assertFalse( finishButton.isEnabled() );
-
-        // jump to auth page
-        nextButton.click();
-
-        // ensure "< Back" is enabled, "Next >" button is disabled, "Finish" button is disabled
-        assertTrue( backButton.isEnabled() );
-        assertFalse( nextButton.isEnabled() );
-        assertFalse( finishButton.isEnabled() );
-
-        // ensure "Simple Authentication" is the default
-        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( "Authentication Method" );
-        assertEquals( "Simple Authentication", authMethodCombo.selection() );
-
-        // enter authentication parameters
-        SWTBotCombo dnCombo = bot.comboBoxWithLabel( "Bind DN or user:" );
-        dnCombo.setText( "uid=admin,ou=system" );
-        SWTBotText passwordText = bot.textWithLabel( "Bind password:" );
-        passwordText.setText( "secret" );
-
-        // ensure "< Back" is enabled, "Next >" button is enabled, "Finish" button is enabled
-        assertTrue( backButton.isEnabled() );
-        assertTrue( nextButton.isEnabled() );
-        assertTrue( finishButton.isEnabled() );
-
-        // finish dialog
-        finishButton.click();
-        bot.sleep( 2000 );
-
-        // ensure connection was created
-        ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
-        assertNotNull( connectionManager.getConnections() );
-        assertEquals( 1, connectionManager.getConnections().length );
-        Connection connection = connectionManager.getConnections()[0];
-        assertEquals( "NewConnectionWizardTest", connection.getName() );
-        assertEquals( "localhost", connection.getHost() );
-        assertEquals( ldapService.getPort(), connection.getPort() );
-        assertEquals( AuthenticationMethod.SIMPLE, connection.getAuthMethod() );
-        assertEquals( "uid=admin,ou=system", connection.getBindPrincipal() );
-        assertEquals( "secret", connection.getBindPassword() );
-
-        // ensure connection is visible in Connections view
-        assertEquals( 1, connectionsTree.rowCount() );
-
-        // close connection
-        connectionsTree.select( "NewConnectionWizardTest" );
-        SWTBotMenu contextMenu = connectionsTree.contextMenu( "Close Connection" );
-        contextMenu.click();
-    }
-
-
-    /**
-     * Tests the "Check Network Parameter" button.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCheckNetworkParameterButtonOK() throws Exception
-    {
-        // Select "Connections" view, ensure no connections exists yet
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        assertEquals( 0, connectionsTree.rowCount() );
-
-        // open "New Connection" wizard
-        SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
-        newConnectionMenu.click();
-
-        // enter connection parameter
-        SWTBotText connText = bot.textWithLabel( "Connection name:" );
-        connText.setText( "NewConnectionWizardTest" );
-        SWTBotCombo hostnameCombo = bot.comboBoxWithLabel( "Hostname:" );
-        hostnameCombo.setText( "localhost" );
-        SWTBotCombo portCombo = bot.comboBoxWithLabel( "Port:" );
-        portCombo.setText( Integer.toString( ldapService.getPort() ) );
-
-        // click "Check Network Parameter" button
-        SWTBotButton checkButton = bot.button( "Check Network Parameter" );
-        checkButton.click();
-        bot.sleep( 1000 );
-        bot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.activeShell().getText().equals( "Check Network Parameter" ) && bot.button( "OK" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Expected an dialog box 'Check Network Parameter' with an 'OK' button.";
-            }
-        } );
-
-        bot.button( "OK" ).click();
-        bot.button( "Cancel" ).click();
-    }
-
-
-    /**
-     * Tests the "Check Network Parameter" button.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCheckNetworkParameterButtonNOK() throws Exception
-    {
-        // we expect the error dialog here, so set flag to false
-        boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
-        ErrorDialog.AUTOMATED_MODE = false;
-        
-        // Select "Connections" view, ensure no connections exists yet
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        assertEquals( 0, connectionsTree.rowCount() );
-
-        // open "New Connection" wizard
-        SWTBotMenu newConnectionMenu = connectionsTree.contextMenu( "New Connection..." );
-        newConnectionMenu.click();
-
-        // enter connection parameter
-        SWTBotText connText = bot.textWithLabel( "Connection name:" );
-        connText.setText( "NewConnectionWizardTest" );
-        SWTBotCombo hostnameCombo = bot.comboBoxWithLabel( "Hostname:" );
-        hostnameCombo.setText( "localhost" );
-        SWTBotCombo portCombo = bot.comboBoxWithLabel( "Port:" );
-        portCombo.setText( Integer.toString( ldapService.getPort() + 1 ) );
-
-        // click "Check Network Parameter" button
-        SWTBotButton checkButton = bot.button( "Check Network Parameter" );
-        checkButton.click();
-        bot.sleep( 1000 );
-        bot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.activeShell().getText().equals( "Error" ) && bot.button( "OK" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Expected an dialog box 'Error' with an 'OK' button.";
-            }
-        } );
-        
-        bot.button( "OK" ).click();
-        bot.button( "Cancel" ).click();
-        
-        // reset flag
-        ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
-    }
+public class NewConnectionWizardTest extends AbstractServerTest {
+	private SWTEclipseBot bot;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		bot = new SWTEclipseBot();
+		SWTBotUtils.openLdapPerspective(bot);
+	}
+
+	protected void tearDown() throws Exception {
+		SWTBotUtils.deleteTestConnections();
+		bot = null;
+		super.tearDown();
+	}
+
+	/**
+	 * Creates a new connection using the new connection wizard.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCreateConnection() throws Exception {
+		// Select "Connections" view, ensure no connections exists yet
+		SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree(bot);
+		assertEquals(0, connectionsTree.rowCount());
+
+		// open "New Connection" wizard
+		SWTBotMenu newConnectionMenu = connectionsTree
+				.contextMenu("New Connection...");
+		newConnectionMenu.click();
+
+		// get buttons
+		SWTBotButton backButton = bot.button("< Back");
+		SWTBotButton nextButton = bot.button("Next >");
+		SWTBotButton finishButton = bot.button("Finish");
+
+		// ensure "Next >" and "Finish" buttons are disabled
+		assertFalse(backButton.isEnabled());
+		assertFalse(nextButton.isEnabled());
+		assertFalse(finishButton.isEnabled());
+
+		// enter connection parameter
+		SWTBotText connText = bot.textWithLabel("Connection name:");
+		connText.setText("NewConnectionWizardTest");
+		SWTBotCombo hostnameCombo = bot.comboBoxWithLabel("Hostname:");
+		hostnameCombo.setText("localhost");
+		SWTBotCombo portCombo = bot.comboBoxWithLabel("Port:");
+		portCombo.setText(Integer.toString(ldapService.getPort()));
+
+		// ensure "Next >" button is enabled, "Finish" button is disabled
+		assertFalse(backButton.isEnabled());
+		assertTrue(nextButton.isEnabled());
+		assertFalse(finishButton.isEnabled());
+
+		// jump to auth page
+		nextButton.click();
+
+		// ensure "< Back" is enabled, "Next >" button is disabled, "Finish"
+		// button is disabled
+		assertTrue(backButton.isEnabled());
+		assertFalse(nextButton.isEnabled());
+		assertFalse(finishButton.isEnabled());
+
+		// ensure "Simple Authentication" is the default
+		SWTBotCombo authMethodCombo = bot
+				.comboBoxInGroup("Authentication Method");
+		assertEquals("Simple Authentication", authMethodCombo.selection());
+
+		// enter authentication parameters
+		SWTBotCombo dnCombo = bot.comboBoxWithLabel("Bind DN or user:");
+		dnCombo.setText("uid=admin,ou=system");
+		SWTBotText passwordText = bot.textWithLabel("Bind password:");
+		passwordText.setText("secret");
+
+		// ensure "< Back" is enabled, "Next >" button is enabled, "Finish"
+		// button is enabled
+		assertTrue(backButton.isEnabled());
+		assertTrue(nextButton.isEnabled());
+		assertTrue(finishButton.isEnabled());
+
+		// finish dialog
+		finishButton.click();
+		bot.sleep(2000);
+
+		// ensure connection was created
+		ConnectionManager connectionManager = ConnectionCorePlugin.getDefault()
+				.getConnectionManager();
+		assertNotNull(connectionManager.getConnections());
+		assertEquals(1, connectionManager.getConnections().length);
+		Connection connection = connectionManager.getConnections()[0];
+		assertEquals("NewConnectionWizardTest", connection.getName());
+		assertEquals("localhost", connection.getHost());
+		assertEquals(ldapService.getPort(), connection.getPort());
+		assertEquals(AuthenticationMethod.SIMPLE, connection.getAuthMethod());
+		assertEquals("uid=admin,ou=system", connection.getBindPrincipal());
+		assertEquals("secret", connection.getBindPassword());
+
+		// ensure connection is visible in Connections view
+		assertEquals(1, connectionsTree.rowCount());
+
+		// close connection
+		connectionsTree.select("NewConnectionWizardTest");
+		SWTBotMenu contextMenu = connectionsTree
+				.contextMenu("Close Connection");
+		contextMenu.click();
+	}
+
+	/**
+	 * Tests the "Check Network Parameter" button.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCheckNetworkParameterButtonOK() throws Exception {
+		// Select "Connections" view, ensure no connections exists yet
+		SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree(bot);
+		assertEquals(0, connectionsTree.rowCount());
+
+		// open "New Connection" wizard
+		SWTBotMenu newConnectionMenu = connectionsTree
+				.contextMenu("New Connection...");
+		newConnectionMenu.click();
+
+		// enter connection parameter
+		SWTBotText connText = bot.textWithLabel("Connection name:");
+		connText.setText("NewConnectionWizardTest");
+		SWTBotCombo hostnameCombo = bot.comboBoxWithLabel("Hostname:");
+		hostnameCombo.setText("localhost");
+		SWTBotCombo portCombo = bot.comboBoxWithLabel("Port:");
+		portCombo.setText(Integer.toString(ldapService.getPort()));
+
+		// click "Check Network Parameter" button
+		SWTBotButton checkButton = bot.button("Check Network Parameter");
+		checkButton.click();
+		bot.sleep(1000);
+		bot.waitUntil(new DefaultCondition() {
+			public boolean test() throws Exception {
+				return bot.activeShell().getText().equals(
+						"Check Network Parameter")
+						&& bot.button("OK") != null;
+			}
+
+			public String getFailureMessage() {
+				return "Expected an dialog box 'Check Network Parameter' with an 'OK' button.";
+			}
+		});
+
+		bot.button("OK").click();
+		bot.button("Cancel").click();
+	}
+
+	/**
+	 * Tests the "Check Network Parameter" button.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCheckNetworkParameterButtonNOK() throws Exception {
+		// we expect the error dialog here, so set flag to false
+		boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
+		ErrorDialog.AUTOMATED_MODE = false;
+
+		// Select "Connections" view, ensure no connections exists yet
+		SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree(bot);
+		assertEquals(0, connectionsTree.rowCount());
+
+		// open "New Connection" wizard
+		SWTBotMenu newConnectionMenu = connectionsTree
+				.contextMenu("New Connection...");
+		newConnectionMenu.click();
+
+		// enter connection parameter
+		SWTBotText connText = bot.textWithLabel("Connection name:");
+		connText.setText("NewConnectionWizardTest");
+		SWTBotCombo hostnameCombo = bot.comboBoxWithLabel("Hostname:");
+		hostnameCombo.setText("localhost");
+		SWTBotCombo portCombo = bot.comboBoxWithLabel("Port:");
+		portCombo.setText(Integer.toString(ldapService.getPort() + 1));
+
+		// click "Check Network Parameter" button
+		SWTBotButton checkButton = bot.button("Check Network Parameter");
+		checkButton.click();
+		bot.sleep(1000);
+		bot.waitUntil(new DefaultCondition() {
+			public boolean test() throws Exception {
+				return bot.activeShell().getText().equals("Error")
+						&& bot.button("OK") != null;
+			}
+
+			public String getFailureMessage() {
+				return "Expected an dialog box 'Error' with an 'OK' button.";
+			}
+		});
+
+		bot.button("OK").click();
+		bot.button("Cancel").click();
+
+		// reset flag
+		ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
+	}
 }

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=741561&r1=741560&r2=741561&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 Feb  6 13:21:59 2009
@@ -20,442 +20,401 @@
 
 package org.apache.directory.studio.test.integration.ui;
 
-
 import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.ModificationItem;
+import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.DirContext;
-
-import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
-import net.sf.swtbot.wait.DefaultCondition;
-import net.sf.swtbot.widgets.SWTBotCombo;
-import net.sf.swtbot.widgets.SWTBotText;
-import net.sf.swtbot.widgets.SWTBotTree;
-import net.sf.swtbot.widgets.SWTBotTreeItem;
+import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.server.unit.AbstractServerTest;
-
+import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 
 /**
  * Tests the new entry wizard.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ *         Project</a>
  * @version $Rev$, $Date$
  */
-public class NewEntryWizardTest extends AbstractServerTest
-{
-    private SWTEclipseBot bot;
-
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        // check if krb5kdc is disabled
-        Attributes krb5kdcAttrs = schemaRoot.getAttributes( "cn=Krb5kdc" );
-        boolean isKrb5KdcDisabled = false;
-        if ( krb5kdcAttrs.get( "m-disabled" ) != null )
-        {
-            isKrb5KdcDisabled = ( ( String ) krb5kdcAttrs.get( "m-disabled" ).get() ).equalsIgnoreCase( "TRUE" );
-        }
-        // if krb5kdc is disabled then enable it
-        if ( isKrb5KdcDisabled )
-        {
-            Attribute disabled = new BasicAttribute( "m-disabled" );
-            ModificationItem[] mods = new ModificationItem[]
-                { new ModificationItem( DirContext.REMOVE_ATTRIBUTE, disabled ) };
-            schemaRoot.modifyAttributes( "cn=Krb5kdc", mods );
-        }
-
-        bot = new SWTEclipseBot();
-        SWTBotUtils.openLdapPerspective( bot );
-        SWTBotUtils.createTestConnection( bot, "NewEntryWizardTest", ldapService.getPort() );
-    }
-
-
-    protected void tearDown() throws Exception
-    {
-        SWTBotUtils.deleteTestConnections();
-        bot = null;
-        super.tearDown();
-    }
-
-
-    /**
-     * Test to create a single organization entry.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCreateOrganizationEntry() throws Exception
-    {
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // open "New Entry" wizard
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "New Entry..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "New Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-
-        // select entry creation method
-        bot.radio( "Create entry from scratch" ).click();
-        bot.button( "Next >" ).click();
-
-        // select object classes
-        bot.table( 0 ).select( "organization" );
-        bot.button( "Add" ).click();
-        bot.button( "Next >" ).click();
-
-        // specify DN
-        SWTBotCombo typeCombo = bot.comboBox( "" );
-        typeCombo.setText( "o" );
-        SWTBotText valueText = bot.text( "" );
-        valueText.setText( "testCreateOrganizationEntry" );
-        SWTBotUtils.asyncClick( bot, bot.button( "Next >" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.tree( 0 ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-
-        // click finish to create the entry
-        SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "o=testCreateOrganizationEntry" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find 'o=testCreateOrganizationEntry'";
-            }
-        } );
-    }
-
-
-    /**
-     * Test to create a single person entry.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCreatePersonEntry() throws Exception
-    {
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // open "New Entry" wizard
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "New Entry..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "New Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-
-        // select entry creation method
-        bot.radio( "Create entry from scratch" ).click();
-        bot.button( "Next >" ).click();
-
-        // select object classes
-        bot.table( 0 ).select( "inetOrgPerson" );
-        bot.button( "Add" ).click();
-        bot.button( "Next >" ).click();
-
-        // specify DN
-        SWTBotCombo typeCombo = bot.comboBox( "" );
-        typeCombo.setText( "cn" );
-        SWTBotText valueText = bot.text( "" );
-        valueText.setText( "testCreatePersonEntry" );
-        SWTBotUtils.asyncClick( bot, bot.button( "Next >" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.tree( 0 ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-
-        // enter sn value
-        SWTBotTree tree = bot.tree( 0 );
-        tree.select( "sn" );
-        bot.text( "" ).setText( "test" );
-        // click to finish editing of sn
-        SWTBotTreeItem snNode = tree.getTreeItem( "sn" );
-        snNode.click();
-
-        // click finish to create the entry
-        SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "cn=testCreatePersonEntry" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find 'cn=testCreatePersonEntry'";
-            }
-        } );
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-350.
-     * 
-     * Create entries with upper case attribute types and ensures that
-     * the retrieved entries still are in upper case.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCreateUpperCaseOrganizationEntries() throws Exception
-    {
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // open "New Entry" wizard
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "New Entry..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "New Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-
-        // select entry creation method
-        bot.radio( "Create entry from scratch" ).click();
-        bot.button( "Next >" ).click();
-
-        // select object classes
-        bot.table( 0 ).select( "organization" );
-        bot.button( "Add" ).click();
-        bot.button( "Next >" ).click();
-
-        // specify DN
-        SWTBotCombo typeCombo = bot.comboBox( "" );
-        typeCombo.setText( "O" );
-        SWTBotText valueText = bot.text( "" );
-        valueText.setText( "testCreateOrganizationEntry" );
-        SWTBotUtils.asyncClick( bot, bot.button( "Next >" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.tree( 0 ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-
-        // click finish to create the entry
-        SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "O=testCreateOrganizationEntry" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find 'O=testCreateOrganizationEntry'";
-            }
-        } );
-
-        // Now create a second entry under the previously created entry 
-        // to ensure that the selected parent is also upper case.
-
-        // open "New Entry" wizard
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "New Entry..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "New Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-
-        // select entry creation method
-        bot.radio( "Create entry from scratch" ).click();
-        bot.button( "Next >" ).click();
-
-        // select object classes
-        bot.table( 0 ).select( "organization" );
-        bot.button( "Add" ).click();
-        bot.button( "Next >" ).click();
-
-        // specify DN
-        typeCombo = bot.comboBox( "" );
-        typeCombo.setText( "O" );
-        valueText = bot.text( "" );
-        valueText.setText( "testCreateOrganizationEntry2" );
-
-        // check preview text 
-        SWTBotText previewText = bot.text( "O=testCreateOrganizationEntry2,O=testCreateOrganizationEntry,ou=system" );
-        assertEquals( "O=testCreateOrganizationEntry2,O=testCreateOrganizationEntry,ou=system", previewText.getText() );
-
-        SWTBotUtils.asyncClick( bot, bot.button( "Next >" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.tree( 0 ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-
-        // click finish to create the entry
-        SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "O=testCreateOrganizationEntry2" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find 'O=testCreateOrganizationEntry2'";
-            }
-        } );
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-360.
-     * 
-     * Create entries with a slash '/' in the RDN value.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCreateEntryWithSlash() throws Exception
-    {
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // open "New Entry" wizard
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "New Entry..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "New Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-
-        // select entry creation method
-        bot.radio( "Create entry from scratch" ).click();
-        bot.button( "Next >" ).click();
-
-        // select object classes
-        bot.table( 0 ).select( "krb5Principal" );
-        bot.button( "Add" ).click();
-        bot.table( 0 ).select( "person" );
-        bot.button( "Add" ).click();
-        bot.button( "Next >" ).click();
-
-        // specify DN
-        SWTBotCombo typeCombo = bot.comboBox( "" );
-        typeCombo.setText( "krb5PrincipalName" );
-        SWTBotText valueText = bot.text( "" );
-        valueText.setText( "kadmin/changepw@DOMAIN" );
-        SWTBotUtils.asyncClick( bot, bot.button( "Next >" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.tree( 0 ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find entry editor";
-            }
-        } );
-
-        SWTBotTree tree = bot.tree( 0 );
-        SWTBotTreeItem krbNode = tree.getTreeItem( "krb5PrincipalName" );
-
-        // enter cn value
-        tree.select( "cn" );
-        bot.text( "" ).setText( "test" );
-        // click to finish editing of cn
-        krbNode.click();
-
-        // enter sn value
-        tree.select( "sn" );
-        bot.text( "" ).setText( "test" );
-        // click to finish editing of sn
-        krbNode.click();
-
-        // click finish to create the entry
-        SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 )
-                    .startsWith( "krb5PrincipalName=kadmin/changepw@DOMAIN" );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find entry 'krb5Principal=kadmin/changepw@DOMAIN'";
-            }
-        } );
-    }
+public class NewEntryWizardTest extends AbstractServerTest {
+	private SWTEclipseBot bot;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		// check if krb5kdc is disabled
+		Attributes krb5kdcAttrs = schemaRoot.getAttributes("cn=Krb5kdc");
+		boolean isKrb5KdcDisabled = false;
+		if (krb5kdcAttrs.get("m-disabled") != null) {
+			isKrb5KdcDisabled = ((String) krb5kdcAttrs.get("m-disabled").get())
+					.equalsIgnoreCase("TRUE");
+		}
+		// if krb5kdc is disabled then enable it
+		if (isKrb5KdcDisabled) {
+			Attribute disabled = new BasicAttribute("m-disabled");
+			ModificationItem[] mods = new ModificationItem[] { new ModificationItem(
+					DirContext.REMOVE_ATTRIBUTE, disabled) };
+			schemaRoot.modifyAttributes("cn=Krb5kdc", mods);
+		}
+
+		bot = new SWTEclipseBot();
+		SWTBotUtils.openLdapPerspective(bot);
+		SWTBotUtils.createTestConnection(bot, "NewEntryWizardTest", ldapService
+				.getPort());
+	}
+
+	protected void tearDown() throws Exception {
+		SWTBotUtils.deleteTestConnections();
+		bot = null;
+		super.tearDown();
+	}
+
+	/**
+	 * Test to create a single organization entry.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCreateOrganizationEntry() throws Exception {
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		SWTBotUtils.selectEntry(bot, browserTree, true, "DIT", "Root DSE",
+				"ou=system");
+
+		// open "New Entry" wizard
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("New Entry..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("New Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+
+		// select entry creation method
+		bot.radio("Create entry from scratch").click();
+		bot.button("Next >").click();
+
+		// select object classes
+		bot.table(0).select("organization");
+		bot.button("Add").click();
+		bot.button("Next >").click();
+
+		// specify DN
+		SWTBotCombo typeCombo = bot.comboBox("");
+		typeCombo.setText("o");
+		SWTBotText valueText = bot.text("");
+		valueText.setText("testCreateOrganizationEntry");
+		SWTBotUtils.asyncClick(bot, bot.button("Next >"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.tree(0) != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find widget";
+					}
+				});
+
+		// click finish to create the entry
+		SWTBotUtils.asyncClick(bot, bot.button("Finish"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return browserTree.selection().get(0).get(0)
+								.startsWith("o=testCreateOrganizationEntry");
+					}
+
+					public String getFailureMessage() {
+						return "Could not find 'o=testCreateOrganizationEntry'";
+					}
+				});
+	}
+
+	/**
+	 * Test to create a single person entry.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCreatePersonEntry() throws Exception {
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		SWTBotUtils.selectEntry(bot, browserTree, true, "DIT", "Root DSE",
+				"ou=system");
+
+		// open "New Entry" wizard
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("New Entry..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("New Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+
+		// select entry creation method
+		bot.radio("Create entry from scratch").click();
+		bot.button("Next >").click();
+
+		// select object classes
+		bot.table(0).select("inetOrgPerson");
+		bot.button("Add").click();
+		bot.button("Next >").click();
+
+		// specify DN
+		SWTBotCombo typeCombo = bot.comboBox("");
+		typeCombo.setText("cn");
+		SWTBotText valueText = bot.text("");
+		valueText.setText("testCreatePersonEntry");
+		SWTBotUtils.asyncClick(bot, bot.button("Next >"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.tree(0) != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find widget";
+					}
+				});
+
+		// enter sn value
+		SWTBotTree tree = bot.tree(0);
+		tree.select("sn");
+		bot.text("").setText("test");
+		// click to finish editing of sn
+		SWTBotTreeItem snNode = tree.getTreeItem("sn");
+		snNode.click();
+
+		// click finish to create the entry
+		SWTBotUtils.asyncClick(bot, bot.button("Finish"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return browserTree.selection().get(0).get(0)
+								.startsWith("cn=testCreatePersonEntry");
+					}
+
+					public String getFailureMessage() {
+						return "Could not find 'cn=testCreatePersonEntry'";
+					}
+				});
+	}
+
+	/**
+	 * Test for DIRSTUDIO-350.
+	 * 
+	 * Create entries with upper case attribute types and ensures that the
+	 * retrieved entries still are in upper case.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCreateUpperCaseOrganizationEntries() throws Exception {
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		SWTBotUtils.selectEntry(bot, browserTree, true, "DIT", "Root DSE",
+				"ou=system");
+
+		// open "New Entry" wizard
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("New Entry..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("New Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+
+		// select entry creation method
+		bot.radio("Create entry from scratch").click();
+		bot.button("Next >").click();
+
+		// select object classes
+		bot.table(0).select("organization");
+		bot.button("Add").click();
+		bot.button("Next >").click();
+
+		// specify DN
+		SWTBotCombo typeCombo = bot.comboBox("");
+		typeCombo.setText("O");
+		SWTBotText valueText = bot.text("");
+		valueText.setText("testCreateOrganizationEntry");
+		SWTBotUtils.asyncClick(bot, bot.button("Next >"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.tree(0) != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find widget";
+					}
+				});
+
+		// click finish to create the entry
+		SWTBotUtils.asyncClick(bot, bot.button("Finish"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return browserTree.selection().get(0).get(0)
+								.startsWith("O=testCreateOrganizationEntry");
+					}
+
+					public String getFailureMessage() {
+						return "Could not find 'O=testCreateOrganizationEntry'";
+					}
+				});
+
+		// Now create a second entry under the previously created entry
+		// to ensure that the selected parent is also upper case.
+
+		// open "New Entry" wizard
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("New Entry..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("New Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+
+		// select entry creation method
+		bot.radio("Create entry from scratch").click();
+		bot.button("Next >").click();
+
+		// select object classes
+		bot.table(0).select("organization");
+		bot.button("Add").click();
+		bot.button("Next >").click();
+
+		// specify DN
+		typeCombo = bot.comboBox("");
+		typeCombo.setText("O");
+		valueText = bot.text("");
+		valueText.setText("testCreateOrganizationEntry2");
+
+		// check preview text
+		SWTBotText previewText = bot
+				.text("O=testCreateOrganizationEntry2,O=testCreateOrganizationEntry,ou=system");
+		assertEquals(
+				"O=testCreateOrganizationEntry2,O=testCreateOrganizationEntry,ou=system",
+				previewText.getText());
+
+		SWTBotUtils.asyncClick(bot, bot.button("Next >"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.tree(0) != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find widget";
+					}
+				});
+
+		// click finish to create the entry
+		SWTBotUtils.asyncClick(bot, bot.button("Finish"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return browserTree.selection().get(0).get(0)
+								.startsWith("O=testCreateOrganizationEntry2");
+					}
+
+					public String getFailureMessage() {
+						return "Could not find 'O=testCreateOrganizationEntry2'";
+					}
+				});
+	}
+
+	/**
+	 * Test for DIRSTUDIO-360.
+	 * 
+	 * Create entries with a slash '/' in the RDN value.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testCreateEntryWithSlash() throws Exception {
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		SWTBotUtils.selectEntry(bot, browserTree, true, "DIT", "Root DSE",
+				"ou=system");
+
+		// open "New Entry" wizard
+		SWTBotUtils.asyncClick(bot, browserTree.contextMenu("New Entry..."),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.shell("New Entry") != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find dialog 'New Entry'";
+					}
+				});
+
+		// select entry creation method
+		bot.radio("Create entry from scratch").click();
+		bot.button("Next >").click();
+
+		// select object classes
+		bot.table(0).select("krb5Principal");
+		bot.button("Add").click();
+		bot.table(0).select("person");
+		bot.button("Add").click();
+		bot.button("Next >").click();
+
+		// specify DN
+		SWTBotCombo typeCombo = bot.comboBox("");
+		typeCombo.setText("krb5PrincipalName");
+		SWTBotText valueText = bot.text("");
+		valueText.setText("kadmin/changepw@DOMAIN");
+		SWTBotUtils.asyncClick(bot, bot.button("Next >"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return bot.tree(0) != null;
+					}
+
+					public String getFailureMessage() {
+						return "Could not find entry editor";
+					}
+				});
+
+		SWTBotTree tree = bot.tree(0);
+		SWTBotTreeItem krbNode = tree.getTreeItem("krb5PrincipalName");
+
+		// enter cn value
+		tree.select("cn");
+		bot.text("").setText("test");
+		// click to finish editing of cn
+		krbNode.click();
+
+		// enter sn value
+		tree.select("sn");
+		bot.text("").setText("test");
+		// click to finish editing of sn
+		krbNode.click();
+
+		// click finish to create the entry
+		SWTBotUtils.asyncClick(bot, bot.button("Finish"),
+				new DefaultCondition() {
+					public boolean test() throws Exception {
+						return browserTree
+								.selection()
+								.get(0)
+								.get(0)
+								.startsWith(
+										"krb5PrincipalName=kadmin/changepw@DOMAIN");
+					}
+
+					public String getFailureMessage() {
+						return "Could not find entry 'krb5Principal=kadmin/changepw@DOMAIN'";
+					}
+				});
+	}
 
 }

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=741561&r1=741560&r2=741561&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 Feb  6 13:21:59 2009
@@ -20,14 +20,6 @@
 
 package org.apache.directory.studio.test.integration.ui;
 
-
-import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
-import net.sf.swtbot.finder.UIThreadRunnable;
-import net.sf.swtbot.finder.results.VoidResult;
-import net.sf.swtbot.widgets.SWTBotTree;
-import net.sf.swtbot.widgets.SWTBotTreeItem;
-import net.sf.swtbot.widgets.WidgetNotFoundException;
-
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.unit.AbstractServerTest;
@@ -35,216 +27,233 @@
 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.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
+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.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 
 /**
  * Tests the referral dialog.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ *         Project</a>
  * @version $Rev$, $Date$
  */
-public class ReferralDialogTest extends AbstractServerTest
-{
-    private SWTEclipseBot bot;
-    private Connection connection;
-
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        bot = new SWTEclipseBot();
-        SWTBotUtils.openLdapPerspective( bot );
-        connection = SWTBotUtils.createTestConnection( bot, "ReferralDialogTest", ldapService.getPort() );
-    }
-
-
-    protected void tearDown() throws Exception
-    {
-        SWTBotUtils.deleteTestConnections();
-        bot = null;
-        super.tearDown();
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-343.
-     * 
-     * Follows a continuation reference.
-     * 
-     * @throws Exception the exception
-     */
-    public void testBrowseAndFollowContinuationReference() throws Exception
-    {
-        // ensure that referrals handling method is FOLLOW 
-        int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
-            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
-        assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal );
-
-        // create the referral entry
-        createReferralEntry();
-
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        // select ou=system, don't expand yet
-        final SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE",
-            "ou=system" );
-
-        // expand ou=system, that reads the referral and opens the referral dialog
-        UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
-        {
-            public void run()
-            {
-                systemNode.expand();
-            }
-        } );
-        bot.sleep( 1000 );
-
-        // click OK in the referral dialog
-        bot.button( "OK" ).click();
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // ensure that the referral URL and target is visible
-        SWTBotTreeItem referralNode = systemNode.getNode( "ldap://localhost:" + ldapService.getPort()
-            + "/ou=users,ou=system" );
-        assertNotNull( referralNode );
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ldap://localhost:"
-            + ldapService.getPort() + "/ou=users,ou=system" );
-
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-343.
-     * 
-     * Does not follow a continuation reference by clicking 
-     * the cancel button in the referral dialog.
-     * 
-     * @throws Exception the exception
-     */
-    public void testBrowseAndCancelFollowingContinuationReference() throws Exception
-    {
-        // ensure that referrals handling method is FOLLOW 
-        int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
-            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
-        assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal );
-
-        // create the referral entry
-        createReferralEntry();
-
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        // select ou=system, don't expand yet
-        final SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE",
-            "ou=system" );
-
-        // expand ou=system, that reads the referral and opens the referral dialog
-        UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
-        {
-            public void run()
-            {
-                systemNode.expand();
-            }
-        } );
-        bot.sleep( 1000 );
-
-        // click Cancel in the referral dialog
-        bot.button( "Cancel" ).click();
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // ensure that the referral URL and target is not visible
-        SWTBotTreeItem referralNode = null;
-        try
-        {
-            referralNode = systemNode.getNode( "ldap://localhost:" + ldapService.getPort() + "/ou=users,ou=system" );
-        }
-        catch ( WidgetNotFoundException wnfe )
-        {
-            // that is expected
-        }
-        assertNull( referralNode );
-    }
-
-
-    /**
-     * Tests ignore referral by setting the connection property to IGNORE.
-     * 
-     * @throws Exception the exception
-     */
-    public void testBrowseAndIgnoreReferral() throws Exception
-    {
-        // ensure that referrals handling method is IGNORE
-        connection.getConnectionParameter().setExtendedIntProperty(
-            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD, ReferralHandlingMethod.IGNORE.ordinal() );
-        int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
-            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
-        assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal );
-
-        // create the referral entry
-        createReferralEntry();
-
-        // expand ou=system, the referral must be ignored, no referral dialog expected
-        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // ensure that the referral entry is not visible
-        SWTBotTreeItem referralNode1 = null;
-        try
-        {
-            referralNode1 = systemNode.getNode( "ldap://localhost:" + ldapService.getPort() + "/ou=users,ou=system" );
-        }
-        catch ( WidgetNotFoundException wnfe )
-        {
-            // that is expected
-        }
-        assertNull( referralNode1 );
-        SWTBotTreeItem referralNode2 = null;
-        try
-        {
-            referralNode2 = systemNode.getNode( "cn=referralDialogTest" );
-        }
-        catch ( WidgetNotFoundException wnfe )
-        {
-            // that is expected
-        }
-        assertNull( referralNode2 );
-    }
-
-
-    /**
-     * Tests manage referral entry by setting the connection property to MANAGE.
-     * 
-     * @throws Exception the exception
-     */
-    public void testBrowseAndManageReferralEntry() throws Exception
-    {
-        // ensure that referrals handling method is MANAGE
-        connection.getConnectionParameter().setExtendedIntProperty(
-            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD, ReferralHandlingMethod.MANAGE.ordinal() );
-        int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
-            IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
-        assertEquals( ReferralHandlingMethod.MANAGE.ordinal(), referralsHandlingMethodOrdinal );
-
-        // create the referral entry
-        createReferralEntry();
-
-        // expand ou=system, the referral is managed, no referral dialog expected
-        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-        SWTBotTreeItem systemNode = SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-
-        // ensure that the referral entry is visible
-        SWTBotTreeItem referralNode = systemNode.getNode( "cn=referralDialogTest" );
-        assertNotNull( referralNode );
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "cn=referralDialogTest" );
-    }
-
-
-    private void createReferralEntry() throws Exception
-    {
-        ServerEntry entry = new DefaultServerEntry(rootDSE.getDirectoryService().getRegistries());
-        entry.setDn( new LdapDN("cn=referralDialogTest,ou=system"  ) );
-        entry.add( "objectClass", "top", "referral", "extensibleObject" );
-        entry.add( "cn", "referralDialogTest" );
-        entry.add( "ref", "ldap://localhost:" + ldapService.getPort() + "/ou=users,ou=system" );
-        rootDSE.add( entry );
-    }
+public class ReferralDialogTest extends AbstractServerTest {
+	private SWTEclipseBot bot;
+	private Connection connection;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		bot = new SWTEclipseBot();
+		SWTBotUtils.openLdapPerspective(bot);
+		connection = SWTBotUtils.createTestConnection(bot,
+				"ReferralDialogTest", ldapService.getPort());
+	}
+
+	protected void tearDown() throws Exception {
+		SWTBotUtils.deleteTestConnections();
+		bot = null;
+		super.tearDown();
+	}
+
+	/**
+	 * Test for DIRSTUDIO-343.
+	 * 
+	 * Follows a continuation reference.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testBrowseAndFollowContinuationReference() throws Exception {
+		// ensure that referrals handling method is FOLLOW
+		int referralsHandlingMethodOrdinal = connection
+				.getConnectionParameter()
+				.getExtendedIntProperty(
+						IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD);
+		assertEquals(ReferralHandlingMethod.FOLLOW.ordinal(),
+				referralsHandlingMethodOrdinal);
+
+		// create the referral entry
+		createReferralEntry();
+
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+
+		// select ou=system, don't expand yet
+		final SWTBotTreeItem systemNode = SWTBotUtils.selectEntry(bot,
+				browserTree, false, "DIT", "Root DSE", "ou=system");
+
+		// expand ou=system, that reads the referral and opens the referral
+		// dialog
+		UIThreadRunnable.asyncExec(bot.getDisplay(), new VoidResult() {
+			public void run() {
+				systemNode.expand();
+			}
+		});
+		bot.sleep(1000);
+
+		// click OK in the referral dialog
+		bot.button("OK").click();
+		SWTBotUtils.selectEntry(bot, browserTree, true, "DIT", "Root DSE",
+				"ou=system");
+
+		// ensure that the referral URL and target is visible
+		SWTBotTreeItem referralNode = systemNode.getNode("ldap://localhost:"
+				+ ldapService.getPort() + "/ou=users,ou=system");
+		assertNotNull(referralNode);
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ldap://localhost:" + ldapService.getPort()
+						+ "/ou=users,ou=system");
+
+	}
+
+	/**
+	 * Test for DIRSTUDIO-343.
+	 * 
+	 * Does not follow a continuation reference by clicking the cancel button in
+	 * the referral dialog.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testBrowseAndCancelFollowingContinuationReference()
+			throws Exception {
+		// ensure that referrals handling method is FOLLOW
+		int referralsHandlingMethodOrdinal = connection
+				.getConnectionParameter()
+				.getExtendedIntProperty(
+						IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD);
+		assertEquals(ReferralHandlingMethod.FOLLOW.ordinal(),
+				referralsHandlingMethodOrdinal);
+
+		// create the referral entry
+		createReferralEntry();
+
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+
+		// select ou=system, don't expand yet
+		final SWTBotTreeItem systemNode = SWTBotUtils.selectEntry(bot,
+				browserTree, false, "DIT", "Root DSE", "ou=system");
+
+		// expand ou=system, that reads the referral and opens the referral
+		// dialog
+		UIThreadRunnable.asyncExec(bot.getDisplay(), new VoidResult() {
+			public void run() {
+				systemNode.expand();
+			}
+		});
+		bot.sleep(1000);
+
+		// click Cancel in the referral dialog
+		bot.button("Cancel").click();
+		SWTBotUtils.selectEntry(bot, browserTree, true, "DIT", "Root DSE",
+				"ou=system");
+
+		// ensure that the referral URL and target is not visible
+		SWTBotTreeItem referralNode = null;
+		try {
+			referralNode = systemNode.getNode("ldap://localhost:"
+					+ ldapService.getPort() + "/ou=users,ou=system");
+		} catch (WidgetNotFoundException wnfe) {
+			// that is expected
+		}
+		assertNull(referralNode);
+	}
+
+	/**
+	 * Tests ignore referral by setting the connection property to IGNORE.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testBrowseAndIgnoreReferral() throws Exception {
+		// ensure that referrals handling method is IGNORE
+		connection
+				.getConnectionParameter()
+				.setExtendedIntProperty(
+						IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
+						ReferralHandlingMethod.IGNORE.ordinal());
+		int referralsHandlingMethodOrdinal = connection
+				.getConnectionParameter()
+				.getExtendedIntProperty(
+						IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD);
+		assertEquals(ReferralHandlingMethod.IGNORE.ordinal(),
+				referralsHandlingMethodOrdinal);
+
+		// create the referral entry
+		createReferralEntry();
+
+		// expand ou=system, the referral must be ignored, no referral dialog
+		// expected
+		SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		SWTBotTreeItem systemNode = SWTBotUtils.selectEntry(bot, browserTree,
+				true, "DIT", "Root DSE", "ou=system");
+
+		// ensure that the referral entry is not visible
+		SWTBotTreeItem referralNode1 = null;
+		try {
+			referralNode1 = systemNode.getNode("ldap://localhost:"
+					+ ldapService.getPort() + "/ou=users,ou=system");
+		} catch (WidgetNotFoundException wnfe) {
+			// that is expected
+		}
+		assertNull(referralNode1);
+		SWTBotTreeItem referralNode2 = null;
+		try {
+			referralNode2 = systemNode.getNode("cn=referralDialogTest");
+		} catch (WidgetNotFoundException wnfe) {
+			// that is expected
+		}
+		assertNull(referralNode2);
+	}
+
+	/**
+	 * Tests manage referral entry by setting the connection property to MANAGE.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testBrowseAndManageReferralEntry() throws Exception {
+		// ensure that referrals handling method is MANAGE
+		connection
+				.getConnectionParameter()
+				.setExtendedIntProperty(
+						IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
+						ReferralHandlingMethod.MANAGE.ordinal());
+		int referralsHandlingMethodOrdinal = connection
+				.getConnectionParameter()
+				.getExtendedIntProperty(
+						IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD);
+		assertEquals(ReferralHandlingMethod.MANAGE.ordinal(),
+				referralsHandlingMethodOrdinal);
+
+		// create the referral entry
+		createReferralEntry();
+
+		// expand ou=system, the referral is managed, no referral dialog
+		// expected
+		SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+		SWTBotTreeItem systemNode = SWTBotUtils.selectEntry(bot, browserTree,
+				true, "DIT", "Root DSE", "ou=system");
+
+		// ensure that the referral entry is visible
+		SWTBotTreeItem referralNode = systemNode
+				.getNode("cn=referralDialogTest");
+		assertNotNull(referralNode);
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "cn=referralDialogTest");
+	}
+
+	private void createReferralEntry() throws Exception {
+		ServerEntry entry = new DefaultServerEntry(rootDSE
+				.getDirectoryService().getRegistries());
+		entry.setDn(new LdapDN("cn=referralDialogTest,ou=system"));
+		entry.add("objectClass", "top", "referral", "extensibleObject");
+		entry.add("cn", "referralDialogTest");
+		entry.add("ref", "ldap://localhost:" + ldapService.getPort()
+				+ "/ou=users,ou=system");
+		rootDSE.add(entry);
+	}
 }

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java?rev=741561&r1=741560&r2=741561&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.java Fri Feb  6 13:21:59 2009
@@ -20,68 +20,61 @@
 
 package org.apache.directory.studio.test.integration.ui;
 
-
-import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
-import net.sf.swtbot.widgets.SWTBotMenu;
-import net.sf.swtbot.widgets.SWTBotTree;
-
 import org.apache.directory.server.unit.AbstractServerTest;
-
+import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 
 /**
  * Tests the rename entry dialog.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ *         Project</a>
  * @version $Rev$, $Date$
  */
-public class RenameEntryDialogTest extends AbstractServerTest
-{
-    private SWTEclipseBot bot;
-
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        super.loadTestLdif( true );
-        bot = new SWTEclipseBot();
-        SWTBotUtils.openLdapPerspective( bot );
-        SWTBotUtils.createTestConnection( bot, "RenameEntryDialogTest", ldapService.getPort() );
-    }
-
-
-    protected void tearDown() throws Exception
-    {
-        SWTBotUtils.deleteTestConnections();
-        bot = null;
-        super.tearDown();
-    }
-
-
-    /**
-     * Test for DIRSTUDIO-318.
-     * 
-     * Renames a multi-valued RDN by changing both RDN attributes.
-     * 
-     * @throws Exception the exception
-     */
-    public void testRenameMultiValuedRdn() throws Exception
-    {
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
-            "cn=Barbara Jensen+uid=bjensen" );
-
-        bot.sleep( 2000 );
-        SWTBotMenu contextMenu = browserTree.contextMenu( "Rename Entry..." );
-        contextMenu.click();
-
-        bot.text( "Barbara Jensen" ).setText( "Babs Jensen" );
-        bot.text( "bjensen" ).setText( "babsjens" );
-        bot.button( "OK" ).click();
-
-        // ensure that the entry with the new name exists
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
-            "cn=Babs Jensen+uid=babsjens" );
-    }
+public class RenameEntryDialogTest extends AbstractServerTest {
+	private SWTEclipseBot bot;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		super.loadTestLdif(true);
+		bot = new SWTEclipseBot();
+		SWTBotUtils.openLdapPerspective(bot);
+		SWTBotUtils.createTestConnection(bot, "RenameEntryDialogTest",
+				ldapService.getPort());
+	}
+
+	protected void tearDown() throws Exception {
+		SWTBotUtils.deleteTestConnections();
+		bot = null;
+		super.tearDown();
+	}
+
+	/**
+	 * Test for DIRSTUDIO-318.
+	 * 
+	 * Renames a multi-valued RDN by changing both RDN attributes.
+	 * 
+	 * @throws Exception
+	 *             the exception
+	 */
+	public void testRenameMultiValuedRdn() throws Exception {
+		final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree(bot);
+
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ou=users", "cn=Barbara Jensen+uid=bjensen");
+
+		bot.sleep(2000);
+		SWTBotMenu contextMenu = browserTree.contextMenu("Rename Entry...");
+		contextMenu.click();
+
+		bot.text("Barbara Jensen").setText("Babs Jensen");
+		bot.text("bjensen").setText("babsjens");
+		bot.button("OK").click();
+
+		// ensure that the entry with the new name exists
+		SWTBotUtils.selectEntry(bot, browserTree, false, "DIT", "Root DSE",
+				"ou=system", "ou=users", "cn=Babs Jensen+uid=babsjens");
+	}
 
 }



Mime
View raw message