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 2021/04/18 15:08:16 UTC
[directory-studio] 01/02: Migrate move and rename entry tests
This is an automated email from the ASF dual-hosted git repository.
seelmann pushed a commit to branch DIRSTUDIO-1274-rework-integration-tests
in repository https://gitbox.apache.org/repos/asf/directory-studio.git
commit a2ca7a0f13d169754acf86c341d03f24ed63f1cc
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Sat Apr 17 20:54:10 2021 +0200
Migrate move and rename entry tests
---
.../test/integration/junit5/TestFixture.java | 30 ++++
.../test/integration/junit5/TestFixture.ldif | 75 +++++++++
.../test/integration/ui/AbstractTestBase.java | 60 +++++++-
.../studio/test/integration/ui/MoveEntryTest.java | 99 +++++-------
.../test/integration/ui/ReferralDialogTest.java | 57 +++----
.../test/integration/ui/RenameEntryTest.java | 170 +++++++++++----------
.../test/integration/ui/bots/BrowserWidgetBot.java | 19 ++-
7 files changed, 330 insertions(+), 180 deletions(-)
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java
index b8f6ce7..6178713 100644
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java
+++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java
@@ -41,6 +41,7 @@ import org.apache.directory.api.ldap.model.message.SearchRequest;
import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.directory.api.ldap.model.schema.comparators.DnComparator;
import org.apache.directory.ldap.client.api.EntryCursorImpl;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -66,6 +67,19 @@ public class TestFixture
}
+ public static Dn dn( Rdn rdn, Dn dn )
+ {
+ try
+ {
+ return dn.add( rdn );
+ }
+ catch ( LdapInvalidDnException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+
public static Dn dn( String rdn, Dn dn )
{
try
@@ -85,6 +99,22 @@ public class TestFixture
public static final Dn CONTEXT_DN = dn( "dc=example,dc=org" );
public static final Dn MISC_DN = dn( "ou=misc", CONTEXT_DN );
+ public static final Dn MISC1_DN = dn( "ou=misc.1", MISC_DN );
+ public static final Dn MISC11_DN = dn( "ou=misc.1.1", MISC1_DN );
+ public static final Dn MISC111_DN = dn( "ou=misc.1.1.1", MISC11_DN );
+ public static final Dn MISC2_DN = dn( "ou=misc.2", MISC_DN );
+ public static final Dn MISC21_DN = dn( "ou=misc.2.1", MISC2_DN );
+ public static final Dn MISC211_DN = dn( "ou=misc.2.1.1", MISC21_DN );
+ public static final Dn MISC212_DN = dn( "ou=misc.2.1.2", MISC21_DN );
+ public static final Dn MISC22_DN = dn( "ou=misc.2.2", MISC2_DN );
+ public static final Dn MISC221_DN = dn( "ou=misc.2.2.1", MISC22_DN );
+ public static final Dn MISC222_DN = dn( "ou=misc.2.2.2", MISC22_DN );
+ public static final Dn MULTI_VALUED_RDN_DN = dn( "cn=Barbara Jensen+uid=bjensen", MISC_DN );
+ public static final Dn LEADING_SHARP_DN_BACKSLASH_PREFIXED = dn( "cn=\\#123456", MISC_DN );
+ public static final Dn LEADING_SHARP_DN_HEX_ESCAPED = dn( "cn=\\23123456", MISC_DN );
+ public static final Dn RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED = dn( "cn=\\#\\\\\\+\\, \\\"öé\\\"",
+ MISC_DN );
+ public static final Dn RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED = dn( "cn=\\23\\5C\\2B\\2C \\22öé\\22", MISC_DN );
public static final Dn USERS_DN = dn( "ou=users", CONTEXT_DN );
public static final Dn USER1_DN = dn( "uid=user.1", USERS_DN );
diff --git a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif
index 9bc0a18..b0296b0 100644
--- a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif
+++ b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif
@@ -37,6 +37,76 @@ sn: Jensen
givenName: Barbara
uid: bjensen
+# cn=\#\\\+\, \"öé\",ou=misc,dc=example,dc=org
+dn:: Y249XCNcXFwrXCwgXCLDtsOpXCIsb3U9bWlzYyxkYz1leGFtcGxlLGRjPW9yZw==
+objectClass: inetOrgPerson
+objectClass: organizationalPerson
+objectClass: person
+objectClass: top
+cn:: I1wrLCAiw7bDqSI=
+sn:: I1wrLCAiw7bDqSI=
+givenName:: I1wrLCAiw7bDqSI=
+
+dn: cn=\#123456,ou=misc,dc=example,dc=org
+objectClass: inetOrgPerson
+objectClass: organizationalPerson
+objectClass: person
+objectClass: top
+cn: #123456
+sn: #123456
+givenName: #123456
+uid: #123456
+
+dn: ou=misc.1,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.1
+
+dn: ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.1.1
+
+dn: ou=misc.1.1.1,ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.1.1.1
+
+dn: ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2
+
+dn: ou=misc.2.1,ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2.1
+
+dn: ou=misc.2.1.1,ou=misc.2.1,ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2.1.1
+
+dn: ou=misc.2.1.2,ou=misc.2.1,ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2.1.2
+
+dn: ou=misc.2.2,ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2.2
+
+dn: ou=misc.2.2.1,ou=misc.2.2,ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2.2.1
+
+dn: ou=misc.2.2.2,ou=misc.2.2,ou=misc.2,ou=misc,dc=example,dc=org
+objectClass: top
+objectClass: organizationalUnit
+ou: misc.2.2.2
+
#
# ou=users
# Fixed number of users used by severals search tests that expect a fixed entry set.
@@ -248,6 +318,11 @@ postalAddress: Abahri Abazari$81023 River Street$Monroe, SD 51865
description: This is the description for Abahri Abazari.
roomNumber: 1963
+#
+# ou=referrals
+# Entries for referral specific test scenarios.
+#
+
dn: ou=referrals,dc=example,dc=org
objectClass: organizationalUnit
objectClass: top
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java
index 6deed0d..fd3000b 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java
@@ -1,11 +1,22 @@
package org.apache.directory.studio.test.integration.ui;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRALS_DN;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
+import org.apache.directory.studio.test.integration.junit5.SkipTestIfLdapServerIsNotAvailableInterceptor;
+import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions;
-import org.apache.directory.studio.test.integration.junit5.SkipTestIfLdapServerIsNotAvailableInterceptor;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit5.SWTBotJunit5Extension;
import org.junit.jupiter.api.AfterEach;
@@ -37,9 +48,54 @@ public class AbstractTestBase
@AfterEach
void tearDown() throws Exception
{
- connectionsViewBot.closeSelectedConnections();
connectionsViewBot.deleteTestConnections();
Assertions.genericTearDownAssertions();
}
+ public static final String[] ROOT_DSE_PATH =
+ { "DIT", "Root DSE" };
+ public static final String[] CONTEXT_PATH = path( ROOT_DSE_PATH, CONTEXT_DN.getName() );
+
+ private static String[] path( String[] parents, String leaf )
+ {
+ return ArrayUtils.addAll( parents, leaf );
+ }
+
+
+ /**
+ * Gets the path to the DN in the LDAP browser tree.
+ * The path starts with "DIT", "Root DSE", and the context entry.
+ */
+ public static String[] path( Dn dn )
+ {
+ List<String> l = new ArrayList<>();
+
+ l.addAll( Arrays.asList( CONTEXT_PATH ) );
+
+ List<Rdn> rdns = dn.getRdns();
+ for ( int i = rdns.size() - 3; i >= 0; i-- )
+ {
+ l.add( rdns.get( i ).getName() );
+ }
+
+ return l.toArray( new String[0] );
+ }
+
+
+ /**
+ * Gets the path to the RDN below the DN in the LDAP browser tree.
+ * The path starts with "DIT", "Root DSE", and the context entry.
+ */
+ public static String[] path( Dn dn, Rdn rdn )
+ {
+ return ArrayUtils.add( path( dn ), rdn.getName() );
+ }
+
+
+ public static String[] pathWithRefLdapUrl( TestLdapServer ldapServer, Dn dn )
+ {
+ String s = ldapServer.getLdapUrl() + "/" + dn.getName();
+ return path( path( REFERRALS_DN ), s );
+ }
+
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java
index 9057c84..67eeac1 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java
@@ -21,25 +21,24 @@
package org.apache.directory.studio.test.integration.ui;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_BACKSLASH_PREFIXED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_HEX_ESCAPED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC111_DN;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.annotations.ApplyLdifFiles;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
-import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
-import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.studio.test.integration.junit5.LdapServerType;
+import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
+import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.MoveEntriesDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SelectDnDialogBot;
-import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
-import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions;
-import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.params.ParameterizedTest;
/**
@@ -48,72 +47,58 @@ import org.junit.runner.RunWith;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-@RunWith(FrameworkRunnerWithScreenshotCaptureListener.class)
-@CreateLdapServer(transports =
- { @CreateTransport(protocol = "LDAP") })
-@ApplyLdifFiles(clazz = MoveEntryTest.class, value = "org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.ldif")
-public class MoveEntryTest extends AbstractLdapTestUnit
+public class MoveEntryTest extends AbstractTestBase
{
- private StudioBot studioBot;
- private ConnectionsViewBot connectionsViewBot;
- private BrowserViewBot browserViewBot;
-
- @Before
- public void setUp() throws Exception
- {
- studioBot = new StudioBot();
- studioBot.resetLdapPerspective();
- connectionsViewBot = studioBot.getConnectionView();
- connectionsViewBot.createTestConnection( "MoveEntryTest", ldapServer.getPort() );
- browserViewBot = studioBot.getBrowserView();
- }
-
-
- @After
- public void tearDown() throws Exception
+ @ParameterizedTest
+ @LdapServersSource
+ public void testMoveUp( TestLdapServer server ) throws Exception
{
- connectionsViewBot.deleteTestConnections();
- Assertions.genericTearDownAssertions();
- }
+ Dn dnToMove = MISC111_DN;
+ Dn newParentDn = MISC_DN;
-
- @Test
- public void testMoveUp() throws Exception
- {
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara Jensen+uid=bjensen" );
+ connectionsViewBot.createTestConnection( server );
+ browserViewBot.selectEntry( path( dnToMove ) );
MoveEntriesDialogBot moveEntryDialog = browserViewBot.openMoveEntryDialog();
assertTrue( moveEntryDialog.isVisible() );
- moveEntryDialog.setParentText( "ou=system" );
+ moveEntryDialog.setParentText( newParentDn.getName() );
moveEntryDialog.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "cn=Barbara Jensen+uid=bjensen" ) );
- assertFalse(
- browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara Jensen+uid=bjensen" ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "cn=Barbara Jensen+uid=bjensen" );
+ assertTrue( browserViewBot.existsEntry( path( newParentDn, dnToMove.getRdn() ) ) );
+ browserViewBot.selectEntry( path( newParentDn, dnToMove.getRdn() ) );
+ assertFalse( browserViewBot.existsEntry( path( dnToMove ) ) );
}
- @Test
- public void testMoveDown() throws Exception
+ @ParameterizedTest
+ @LdapServersSource
+ public void testMoveDown( TestLdapServer server ) throws Exception
{
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#123456" );
+ Dn dnToMove = RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED;
+ Dn newParentDn = LEADING_SHARP_DN_BACKSLASH_PREFIXED;
+ if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds )
+ {
+ // OpenLDAP and 389ds escape all characters with hex digits
+ dnToMove = RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED;
+ newParentDn = LEADING_SHARP_DN_HEX_ESCAPED;
+ }
+
+ connectionsViewBot.createTestConnection( server );
+ browserViewBot.selectEntry( path( dnToMove ) );
MoveEntriesDialogBot moveEntryDialog = browserViewBot.openMoveEntryDialog();
assertTrue( moveEntryDialog.isVisible() );
SelectDnDialogBot selectDnBot = moveEntryDialog.clickBrowseButtonExpectingSelectDnDialog();
assertTrue( selectDnBot.isVisible() );
- selectDnBot.selectEntry( "Root DSE", "ou=system", "ou=users", "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"" );
+ selectDnBot.selectEntry( ArrayUtils.remove( path( newParentDn ), 0 ) );
selectDnBot.clickOkButton();
moveEntryDialog.activate();
- assertEquals( "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system", moveEntryDialog.getParentText() );
+ assertEquals( newParentDn.getName(), moveEntryDialog.getParentText() );
moveEntryDialog.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"", "cn=\\#123456" ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"", "cn=\\#123456" );
+ assertTrue( browserViewBot.existsEntry( path( newParentDn, dnToMove.getRdn() ) ) );
+ browserViewBot.selectEntry( path( newParentDn, dnToMove.getRdn() ) );
}
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
index b979909..d0e3a63 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java
@@ -21,7 +21,6 @@
package org.apache.directory.studio.test.integration.ui;
-import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRALS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_2_DN;
@@ -35,8 +34,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.directory.api.ldap.model.name.Dn;
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;
@@ -55,24 +52,6 @@ import org.junit.jupiter.params.ParameterizedTest;
public class ReferralDialogTest extends AbstractTestBase
{
- static String[] path( String[] parents, String leaf )
- {
- return ArrayUtils.addAll( parents, leaf );
- }
-
- public static final String[] ROOT_DSE_PATH =
- { "DIT", "Root DSE" };
- public static final String[] CONTEXT_PATH = path( ROOT_DSE_PATH, CONTEXT_DN.getName() );
- public static final String[] USERS_PATH = path( CONTEXT_PATH, USERS_DN.getRdn().getName() );
- public static final String[] REFERRALS_PATH = path( CONTEXT_PATH, REFERRALS_DN.getRdn().getName() );
-
- public static String[] pathWithRefLdapUrl( TestLdapServer ldapServer, Dn dn )
- {
- String s = ldapServer.getLdapUrl() + "/" + dn.getName();
- return path( REFERRALS_PATH, s );
- }
-
-
/**
* Test for DIRSTUDIO-343.
*
@@ -92,7 +71,7 @@ public class ReferralDialogTest extends AbstractTestBase
assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, that reads the referrals and opens the referral dialog
- ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog( REFERRALS_PATH );
+ ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog( path( REFERRALS_DN ) );
assertTrue( referralDialogBot.isVisible() );
assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
referralDialogBot.clickOkButton();
@@ -128,7 +107,7 @@ public class ReferralDialogTest extends AbstractTestBase
assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, that reads the referral and opens the referral dialog
- ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog( REFERRALS_PATH );
+ ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog( path( REFERRALS_DN ) );
assertTrue( referralDialogBot.isVisible() );
assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
referralDialogBot.clickCancelButton();
@@ -156,7 +135,7 @@ public class ReferralDialogTest extends AbstractTestBase
assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, no referral dialog expected
- browserViewBot.expandEntry( REFERRALS_PATH );
+ browserViewBot.expandEntry( path( REFERRALS_DN ) );
// ensure that neither the continuation URLs, nor the referral entries are visible
assertReferralEntriesAreNotVisible();
@@ -186,16 +165,16 @@ public class ReferralDialogTest extends AbstractTestBase
assertTrue( manageDsaIT );
// expand ou=referrals, that reads the referral object
- browserViewBot.expandEntry( REFERRALS_PATH );
+ browserViewBot.expandEntry( path( REFERRALS_DN ) );
// ensure that the referral entries are visible, but not the continuation URLs
assertRefLdapUrlsAreNotVisible( server );
- browserViewBot.selectEntry( path( REFERRALS_PATH, REFERRAL_TO_USER1_DN.getRdn().getName() ) );
- browserViewBot.selectEntry( path( REFERRALS_PATH, REFERRAL_TO_USERS_DN.getRdn().getName() ) );
- browserViewBot.selectEntry( path( REFERRALS_PATH, REFERRAL_TO_REFERRAL_TO_USERS_DN.getRdn().getName() ) );
- browserViewBot.selectEntry( path( REFERRALS_PATH, REFERRAL_TO_REFERRALS_DN.getRdn().getName() ) );
- browserViewBot.selectEntry( path( REFERRALS_PATH, REFERRAL_LOOP_1_DN.getRdn().getName() ) );
- browserViewBot.selectEntry( path( REFERRALS_PATH, REFERRAL_LOOP_2_DN.getRdn().getName() ) );
+ browserViewBot.selectEntry( path( REFERRAL_TO_USER1_DN ) );
+ browserViewBot.selectEntry( path( REFERRAL_TO_USERS_DN ) );
+ browserViewBot.selectEntry( path( REFERRAL_TO_REFERRAL_TO_USERS_DN ) );
+ browserViewBot.selectEntry( path( REFERRAL_TO_REFERRALS_DN ) );
+ browserViewBot.selectEntry( path( REFERRAL_LOOP_1_DN ) );
+ browserViewBot.selectEntry( path( REFERRAL_LOOP_2_DN ) );
}
@@ -216,7 +195,7 @@ public class ReferralDialogTest extends AbstractTestBase
assertEquals( ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, no referral dialog expected yet
- browserViewBot.expandEntry( REFERRALS_PATH );
+ browserViewBot.expandEntry( path( REFERRALS_DN ) );
// ensure that only the referral targets are visible, not the referrals
assertReferralEntriesAreNotVisible();
@@ -257,14 +236,12 @@ public class ReferralDialogTest extends AbstractTestBase
private void assertReferralEntriesAreNotVisible()
{
- assertFalse( browserViewBot.existsEntry( path( REFERRALS_PATH, REFERRAL_TO_USER1_DN.getRdn().getName() ) ) );
- assertFalse( browserViewBot.existsEntry( path( REFERRALS_PATH, REFERRAL_TO_USERS_DN.getRdn().getName() ) ) );
- assertFalse(
- browserViewBot.existsEntry( path( REFERRALS_PATH, REFERRAL_TO_REFERRAL_TO_USERS_DN.getRdn().getName() ) ) );
- assertFalse(
- browserViewBot.existsEntry( path( REFERRALS_PATH, REFERRAL_TO_REFERRALS_DN.getRdn().getName() ) ) );
- assertFalse( browserViewBot.existsEntry( path( REFERRALS_PATH, REFERRAL_LOOP_1_DN.getRdn().getName() ) ) );
- assertFalse( browserViewBot.existsEntry( path( REFERRALS_PATH, REFERRAL_LOOP_2_DN.getRdn().getName() ) ) );
+ assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_USER1_DN ) ) );
+ assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_USERS_DN ) ) );
+ assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRAL_TO_USERS_DN ) ) );
+ assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRALS_DN ) ) );
+ assertFalse( browserViewBot.existsEntry( path( REFERRAL_LOOP_1_DN ) ) );
+ assertFalse( browserViewBot.existsEntry( path( REFERRAL_LOOP_2_DN ) ) );
}
}
\ No newline at end of file
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java
index 1927e6a..2f12049 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java
@@ -21,22 +21,23 @@
package org.apache.directory.studio.test.integration.ui;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_BACKSLASH_PREFIXED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_HEX_ESCAPED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.MULTI_VALUED_RDN_DN;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.dn;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.annotations.ApplyLdifFiles;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
-import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
-import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
+import org.apache.directory.api.ldap.model.name.Ava;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
+import org.apache.directory.studio.test.integration.junit5.LdapServerType;
+import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
+import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.RenameEntryDialogBot;
-import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
-import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions;
-import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.params.ParameterizedTest;
/**
@@ -45,59 +46,37 @@ import org.junit.runner.RunWith;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-@RunWith(FrameworkRunnerWithScreenshotCaptureListener.class)
-@CreateLdapServer(transports =
- { @CreateTransport(protocol = "LDAP") })
-@ApplyLdifFiles( clazz = RenameEntryTest.class,
- value = "org/apache/directory/studio/test/integration/ui/RenameEntryDialogTest.ldif" )
-public class RenameEntryTest extends AbstractLdapTestUnit
+public class RenameEntryTest extends AbstractTestBase
{
- private StudioBot studioBot;
- private ConnectionsViewBot connectionsViewBot;
- private BrowserViewBot browserViewBot;
-
-
- @Before
- public void setUp() throws Exception
- {
- studioBot = new StudioBot();
- studioBot.resetLdapPerspective();
- connectionsViewBot = studioBot.getConnectionView();
- connectionsViewBot.createTestConnection( "RenameEntryTest", ldapServer.getPort() );
- browserViewBot = studioBot.getBrowserView();
- }
-
-
- @After
- public void tearDown() throws Exception
- {
- connectionsViewBot.deleteTestConnections();
- Assertions.genericTearDownAssertions();
- }
-
/**
* Test for DIRSTUDIO-318.
*
* Renames a multi-valued RDN by changing both RDN attributes.
- *
- * @throws Exception
- * the exception
*/
- @Test
- public void testRenameMultiValuedRdn() throws Exception
+ @ParameterizedTest
+ @LdapServersSource
+ public void testRenameMultiValuedRdn( TestLdapServer server ) throws Exception
{
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara Jensen+uid=bjensen" );
+ Dn oldDn = MULTI_VALUED_RDN_DN;
+ Rdn newRdn = new Rdn( new Ava( "cn", "Babs Jensen" ), new Ava( "uid", "dj" ) );
+ Dn newDn = dn( newRdn, oldDn.getParent() );
+
+ connectionsViewBot.createTestConnection( server );
+ browserViewBot.selectEntry( path( oldDn ) );
RenameEntryDialogBot renameDialogBot = browserViewBot.openRenameDialog();
assertTrue( renameDialogBot.isVisible() );
- renameDialogBot.setRdnValue( 1, "Babs Jensen" );
- renameDialogBot.setRdnValue( 2, "babsjens" );
+ for ( int i = 0; i < newRdn.size(); i++ )
+ {
+ renameDialogBot.setRdnType( i + 1, newRdn.getAva( i ).getType() );
+ renameDialogBot.setRdnValue( i + 1, newRdn.getAva( i ).getValue().getString() );
+ }
renameDialogBot.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=Babs Jensen+uid=babsjens" ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Babs Jensen+uid=babsjens" );
+ assertTrue( browserViewBot.existsEntry( path( newDn ) ) );
+ browserViewBot.selectEntry( path( newDn ) );
+ assertFalse( browserViewBot.existsEntry( path( oldDn ) ) );
}
@@ -105,45 +84,63 @@ public class RenameEntryTest extends AbstractLdapTestUnit
* Test for DIRSTUDIO-484.
*
* Renames a RDN with escaped characters.
- *
- * @throws Exception
- * the exception
*/
- @Test
- public void testRenameRdnWithEscapedCharacters() throws Exception
+ @ParameterizedTest
+ @LdapServersSource
+ public void testRenameRdnWithEscapedCharacters( TestLdapServer server ) throws Exception
{
- browserViewBot
- .selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"" );
+ Dn oldDn = RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED;
+ Dn newDn = dn( "cn=\\#\\\\\\+\\, \\\"öé\\\" 2", oldDn.getParent() );
+ if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds )
+ {
+ // OpenLDAP and 389ds escape all characters with hex digits
+ oldDn = RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED;
+ newDn = dn( "cn=\\23\\5C\\2B\\2C \\22öé\\22 2", oldDn.getParent() );
+ }
+
+ connectionsViewBot.createTestConnection( server );
+ browserViewBot.selectEntry( path( oldDn ) );
RenameEntryDialogBot renameDialogBot = browserViewBot.openRenameDialog();
assertTrue( renameDialogBot.isVisible() );
- renameDialogBot.setRdnValue( 1, "#\\+, \"\u00F6\u00E9\"2" );
+ renameDialogBot.setRdnValue( 1, "#\\+, \"öé\" 2" );
renameDialogBot.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"2" ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"2" );
+ assertTrue( browserViewBot.existsEntry( path( newDn ) ) );
+ browserViewBot.selectEntry( path( newDn ) );
+ assertFalse( browserViewBot.existsEntry( path( oldDn ) ) );
}
/**
* Test for DIRSTUDIO-589, DIRSTUDIO-591, DIRSHARED-38.
*
- * Rename an entry with sharp in DN: cn=\#123456.
+ * Rename an entry with leading sharp in DN: cn=\#123456.
*/
- @Test
- public void testRenameRdnWithSharp() throws Exception
+ @ParameterizedTest
+ @LdapServersSource
+ public void testRenameRdnWithSharp( TestLdapServer server ) throws Exception
{
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#123456" );
+ Dn oldDn = LEADING_SHARP_DN_BACKSLASH_PREFIXED;
+ Dn newDn = dn( "cn=\\#ABCDEF", oldDn.getParent() );
+ if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds )
+ {
+ // OpenLDAP and 389ds escape all characters with hex digits
+ oldDn = LEADING_SHARP_DN_HEX_ESCAPED;
+ newDn = dn( "cn=\\23ABCDEF", oldDn.getParent() );
+ }
+
+ connectionsViewBot.createTestConnection( server );
+ browserViewBot.selectEntry( path( oldDn ) );
RenameEntryDialogBot renameDialogBot = browserViewBot.openRenameDialog();
assertTrue( renameDialogBot.isVisible() );
renameDialogBot.setRdnValue( 1, "#ABCDEF" );
renameDialogBot.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ABCDEF" ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ABCDEF" );
+ assertTrue( browserViewBot.existsEntry( path( newDn ) ) );
+ browserViewBot.selectEntry( path( newDn ) );
+ assertFalse( browserViewBot.existsEntry( path( oldDn ) ) );
}
@@ -152,26 +149,43 @@ public class RenameEntryTest extends AbstractLdapTestUnit
*
* Rename an entry with trailing space in RDN.
*/
- @Test
- public void testRenameRdnWithTrailingSpace() throws Exception
+ @ParameterizedTest
+ @LdapServersSource(types =
+ { LdapServerType.ApacheDS, LdapServerType.OpenLdap })
+ public void testRenameRdnWithTrailingSpace( TestLdapServer server ) throws Exception
{
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#123456" );
+ Dn oldDn = LEADING_SHARP_DN_BACKSLASH_PREFIXED;
+ Dn newDn1 = dn( "cn=\\#ABCDEF\\ ", oldDn.getParent() );
+ Dn newDn2 = dn( "cn=A\\ ", oldDn.getParent() );
+ if ( server.getType() == LdapServerType.OpenLdap )
+ {
+ // OpenLDAP and 389ds escape all characters with hex digits
+ oldDn = LEADING_SHARP_DN_HEX_ESCAPED;
+ newDn1 = dn( "cn=\\23ABCDEF\\20", oldDn.getParent() );
+ newDn2 = dn( "cn=A\\20", oldDn.getParent() );
+ }
+
+ connectionsViewBot.createTestConnection( server );
+ browserViewBot.selectEntry( path( oldDn ) );
RenameEntryDialogBot renameDialogBot = browserViewBot.openRenameDialog();
assertTrue( renameDialogBot.isVisible() );
renameDialogBot.setRdnValue( 1, "#ABCDEF " );
renameDialogBot.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ABCDEF\\ " ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ABCDEF\\ " );
+ assertTrue( browserViewBot.existsEntry( path( newDn1 ) ) );
+ browserViewBot.selectEntry( path( newDn1 ) );
+ assertFalse( browserViewBot.existsEntry( path( oldDn ) ) );
renameDialogBot = browserViewBot.openRenameDialog();
assertTrue( renameDialogBot.isVisible() );
renameDialogBot.setRdnValue( 1, "A " );
renameDialogBot.clickOkButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=A\\ " ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=A\\ " );
+ assertTrue( browserViewBot.existsEntry( path( newDn2 ) ) );
+ browserViewBot.selectEntry( path( newDn2 ) );
+ assertFalse( browserViewBot.existsEntry( path( newDn1 ) ) );
+ assertFalse( browserViewBot.existsEntry( path( oldDn ) ) );
}
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java
index 37891b0..c0bc316 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java
@@ -23,6 +23,8 @@ package org.apache.directory.studio.test.integration.ui.bots;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.bots.utils.JobWatcher;
@@ -43,7 +45,6 @@ class BrowserWidgetBot
{
private SWTBot bot;
-
BrowserWidgetBot( SWTBot bot )
{
this.bot = bot;
@@ -243,7 +244,7 @@ class BrowserWidgetBot
List<String> nodes = entry.getNodes();
for ( String node : nodes )
{
- if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+ if ( matches( node, nodeName ) )
{
return node;
}
@@ -258,7 +259,7 @@ class BrowserWidgetBot
for ( SWTBotTreeItem item : allItems )
{
String node = item.getText();
- if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+ if ( matches( node, nodeName ) )
{
return node;
}
@@ -267,6 +268,18 @@ class BrowserWidgetBot
}
+ private boolean matches( String node, String nodeName )
+ {
+ Pattern pattern = Pattern.compile( "(.*) \\(\\d+\\+?\\)" );
+ Matcher matcher = pattern.matcher( node );
+ if ( matcher.matches() )
+ {
+ node = matcher.group( 1 );
+ }
+ return node.toUpperCase().equals( nodeName.toUpperCase() );
+ }
+
+
SWTBotTree getTree()
{
return bot.tree();