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/22 04:27:09 UTC
[directory-studio] branch DIRSTUDIO-1274-rework-integration-tests
updated: Migrate valueeditor and swtresources test, fix other 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
The following commit(s) were added to refs/heads/DIRSTUDIO-1274-rework-integration-tests by this push:
new c3c84a3 Migrate valueeditor and swtresources test, fix other tests
c3c84a3 is described below
commit c3c84a35c924835fbd83aae04803f9fbc5cd66d2
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Thu Apr 22 06:26:53 2021 +0200
Migrate valueeditor and swtresources test, fix other tests
---
.../test/integration/junit5/TestFixture.java | 5 +
.../studio/test/integration/junit5/ApacheDS.ldif | 2 +-
.../test/integration/junit5/TestFixture.ldif | 8 +
.../studio/test/integration/ui/CopyEntryTest.java | 70 ++++-----
.../test/integration/ui/ImportExportTest.java | 1 -
.../test/integration/ui/SwtResourcesTest.java | 77 +++-------
.../test/integration/ui/ValueEditorTest.java | 169 ++++++++++++---------
7 files changed, 172 insertions(+), 160 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 929070e..879a894 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
@@ -127,6 +127,8 @@ public class TestFixture
public static final Dn GROUPS_DN = dn( "ou=groups", CONTEXT_DN );
public static final Dn GROUP1_DN = dn( "cn=group.1", GROUPS_DN );
+ public static final Dn TARGET_DN = dn( "ou=target", CONTEXT_DN );
+
public static final Dn REFERRALS_DN = dn( "ou=referrals", CONTEXT_DN );
public static final Dn REFERRAL_TO_USERS_DN = dn( "cn=referral-to-users", REFERRALS_DN );
public static final Dn REFERRAL_TO_USER1_DN = dn( "cn=referral-to-user.1", REFERRALS_DN );
@@ -203,6 +205,9 @@ public class TestFixture
// delete ou=misc
deleteTree( connection, MISC_DN, Optional.of( Controls.SUBENTRIES_CONTROL ) );
deleteTree( connection, MISC_DN, Optional.empty() );
+ // delete ou=target
+ deleteTree( connection, TARGET_DN, Optional.of( Controls.SUBENTRIES_CONTROL ) );
+ deleteTree( connection, TARGET_DN, Optional.empty() );
} );
}
diff --git a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/ApacheDS.ldif b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/ApacheDS.ldif
index 888b05d..e96163d 100644
--- a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/ApacheDS.ldif
+++ b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/ApacheDS.ldif
@@ -22,7 +22,7 @@ add: administrativeRole
administrativeRole: accessControlSpecificArea
-
-dn: ou=misc.1.1.1,ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org
+dn: ou=target,dc=example,dc=org
changetype: modify
add: administrativeRole
administrativeRole: accessControlSpecificArea
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 58f3440..f5dc9c1 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
@@ -389,6 +389,14 @@ member: uid=user.6,ou=users,dc=example,dc=org
member: uid=user.7,ou=users,dc=example,dc=org
member: uid=user.8,ou=users,dc=example,dc=org
+#
+# ou=target
+#
+
+dn: ou=target,dc=example,dc=org
+objectClass: organizationalUnit
+objectClass: top
+ou: target
#
# ou=referrals
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CopyEntryTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CopyEntryTest.java
index 7ee7586..e34ffb5 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CopyEntryTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CopyEntryTest.java
@@ -23,7 +23,7 @@ package org.apache.directory.studio.test.integration.ui;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.ALIAS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN;
-import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC111_DN;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.TARGET_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_USER1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.SUBENTRY_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN;
@@ -70,7 +70,7 @@ public class CopyEntryTest extends AbstractTestBase
@LdapServersSource
public void testCopyPasteSingleEntryWithoutCopyDepthDialog( TestLdapServer server ) throws Exception
{
- Dn newDn = dn( USER1_DN.getRdn(), MISC111_DN );
+ Dn newDn = dn( USER1_DN.getRdn(), TARGET_DN );
// expand the entry to avoid copy depth dialog
connectionsViewBot.createTestConnection( server );
@@ -81,7 +81,7 @@ public class CopyEntryTest extends AbstractTestBase
browserViewBot.copy();
// select the parent entry where the copied entry should be pasted to
- browserViewBot.selectEntry( path( MISC111_DN ) );
+ browserViewBot.selectEntry( path( TARGET_DN ) );
assertFalse( browserViewBot.existsEntry( path( newDn ) ) );
// paste the entry
@@ -113,8 +113,8 @@ public class CopyEntryTest extends AbstractTestBase
browserViewBot.copy();
// select the parent entry where the copied entries should be pasted to
- browserViewBot.selectEntry( path( MISC111_DN ) );
- assertFalse( browserViewBot.existsEntry( path( MISC111_DN, "uid=user.1" ) ) );
+ browserViewBot.selectEntry( path( TARGET_DN ) );
+ assertFalse( browserViewBot.existsEntry( path( TARGET_DN, "uid=user.1" ) ) );
// paste the entry
SelectCopyDepthDialogBot dialog = browserViewBot.pasteEntriesExpectingSelectCopyDepthDialog( 4 );
@@ -122,16 +122,16 @@ public class CopyEntryTest extends AbstractTestBase
dialog.clickOkButton();
// verify the entries were copied
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "uid=user.1" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "uid=user.2" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "uid=user.3" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "uid=user.4" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "uid=user.1" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "uid=user.2" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "uid=user.3" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "uid=user.4" ) ) );
// verify in modification logs
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.1", MISC111_DN ), "changetype: add" );
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.2", MISC111_DN ), "changetype: add" );
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.3", MISC111_DN ), "changetype: add" );
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.4", MISC111_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.1", TARGET_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.2", TARGET_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.3", TARGET_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( "uid=user.4", TARGET_DN ), "changetype: add" );
}
@@ -148,9 +148,9 @@ public class CopyEntryTest extends AbstractTestBase
browserViewBot.copy();
// select the parent entry where the copied entries should be pasted to
- browserViewBot.selectEntry( path( MISC111_DN ) );
- assertFalse( browserViewBot.existsEntry( path( MISC111_DN, "ou=users" ) ) );
- assertFalse( browserViewBot.existsEntry( path( MISC111_DN, "ou=groups" ) ) );
+ browserViewBot.selectEntry( path( TARGET_DN ) );
+ assertFalse( browserViewBot.existsEntry( path( TARGET_DN, "ou=users" ) ) );
+ assertFalse( browserViewBot.existsEntry( path( TARGET_DN, "ou=groups" ) ) );
// paste the entry
SelectCopyDepthDialogBot dialog = browserViewBot.pasteEntriesExpectingSelectCopyDepthDialog( 2 );
@@ -158,15 +158,15 @@ public class CopyEntryTest extends AbstractTestBase
dialog.clickOkButton();
// verify the entries were copied
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "ou=users" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "ou=users", "uid=user.1" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "ou=users", "uid=user.8" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "ou=groups" ) ) );
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, "ou=groups", "cn=group.1" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "ou=users" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "ou=users", "uid=user.1" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "ou=users", "uid=user.8" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "ou=groups" ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, "ou=groups", "cn=group.1" ) ) );
// verify in modification logs
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( "ou=users", MISC111_DN ), "changetype: add" );
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( "ou=groups", MISC111_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( "ou=users", TARGET_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( "ou=groups", TARGET_DN ), "changetype: add" );
}
@@ -249,17 +249,17 @@ public class CopyEntryTest extends AbstractTestBase
browserViewBot.copy();
// select the parent entry where the copied entry should be pasted to
- browserViewBot.selectEntry( path( MISC111_DN ) );
- assertFalse( browserViewBot.existsEntry( path( MISC111_DN, ALIAS_DN.getRdn() ) ) );
+ browserViewBot.selectEntry( path( TARGET_DN ) );
+ assertFalse( browserViewBot.existsEntry( path( TARGET_DN, ALIAS_DN.getRdn() ) ) );
// paste the entry
browserViewBot.pasteEntries( 1 );
// verify the entyr was copied
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, ALIAS_DN.getRdn() ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, ALIAS_DN.getRdn() ) ) );
// verify in modification logs
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( ALIAS_DN.getRdn(), MISC111_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( ALIAS_DN.getRdn(), TARGET_DN ), "changetype: add" );
}
@@ -278,17 +278,17 @@ public class CopyEntryTest extends AbstractTestBase
browserViewBot.copy();
// select the parent entry where the copied entry should be pasted to
- browserViewBot.selectEntry( path( MISC111_DN ) );
- assertFalse( browserViewBot.existsEntry( path( MISC111_DN, REFERRAL_TO_USER1_DN.getRdn() ) ) );
+ browserViewBot.selectEntry( path( TARGET_DN ) );
+ assertFalse( browserViewBot.existsEntry( path( TARGET_DN, REFERRAL_TO_USER1_DN.getRdn() ) ) );
// paste the entry
browserViewBot.pasteEntries( 1 );
// verify the entry was copied
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, REFERRAL_TO_USER1_DN.getRdn() ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, REFERRAL_TO_USER1_DN.getRdn() ) ) );
// verify in modification logs
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( REFERRAL_TO_USER1_DN.getRdn(), MISC111_DN ),
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( REFERRAL_TO_USER1_DN.getRdn(), TARGET_DN ),
"changetype: add" );
}
@@ -308,17 +308,17 @@ public class CopyEntryTest extends AbstractTestBase
browserViewBot.copy();
// select the parent entry where the copied entry should be pasted to
- browserViewBot.selectEntry( path( MISC111_DN ) );
- assertFalse( browserViewBot.existsEntry( path( MISC111_DN, SUBENTRY_DN.getRdn() ) ) );
+ browserViewBot.selectEntry( path( TARGET_DN ) );
+ assertFalse( browserViewBot.existsEntry( path( TARGET_DN, SUBENTRY_DN.getRdn() ) ) );
// paste the entry
browserViewBot.pasteEntries( 1 );
// verify the entry was copied
- assertTrue( browserViewBot.existsEntry( path( MISC111_DN, SUBENTRY_DN.getRdn() ) ) );
+ assertTrue( browserViewBot.existsEntry( path( TARGET_DN, SUBENTRY_DN.getRdn() ) ) );
// verify in modification logs
- modificationLogsViewBot.assertContainsOk( "dn: " + dn( SUBENTRY_DN.getRdn(), MISC111_DN ), "changetype: add" );
+ modificationLogsViewBot.assertContainsOk( "dn: " + dn( SUBENTRY_DN.getRdn(), TARGET_DN ), "changetype: add" );
}
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
index aac8eb2..41c0085 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
@@ -462,7 +462,6 @@ public class ImportExportTest extends AbstractTestBase
// verify that exported DSML
String content = FileUtils.readFileToString( new File( file ), StandardCharsets.UTF_8 );
- System.out.println( content );
assertTrue( content.contains( "dn=\"" + SUBENTRY_DN.getName() + "\"" ) );
assertTrue( content.contains( "<attr name=\"subtreespecification\">" ) );
assertTrue( content.contains( "<value>{}</value>" ) );
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
index 21b1ef1..fa9f786 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
@@ -21,27 +21,21 @@
package org.apache.directory.studio.test.integration.ui;
-import static org.junit.Assert.fail;
+import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN;
+
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
-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.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.DeleteDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.NewEntryWizardBot;
-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.eclipse.swt.graphics.DeviceData;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.IntResult;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.params.ParameterizedTest;
/**
@@ -50,47 +44,21 @@ 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") })
-public class SwtResourcesTest extends AbstractLdapTestUnit
+public class SwtResourcesTest 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( "SwtResourcesTest", ldapServer.getPort() );
- browserViewBot = studioBot.getBrowserView();
- }
-
-
- @After
- public void tearDown() throws Exception
- {
- connectionsViewBot.deleteTestConnections();
- Assertions.genericTearDownAssertions();
- }
-
/**
* Test for DIRSTUDIO-319.
*
* Creates multiple entries using the New Entry wizard. Checks that we don't
* allocate too much SWT resources during the run.
- *
- * @throws Exception
- * the exception
*/
- @Test
- public void testSwtResourcesDelta() throws Exception
+ @ParameterizedTest
+ @LdapServersSource(types = LdapServerType.ApacheDS)
+ public void testSwtResourcesDelta( TestLdapServer server ) throws Exception
{
+ connectionsViewBot.createTestConnection( server );
+
// run the new entry wizard once to ensure all SWT resources are created
createAndDeleteEntry( "testSwtResourcesDelta" + 0 );
@@ -116,11 +84,13 @@ public class SwtResourcesTest extends AbstractLdapTestUnit
* Ensure that we have not allocated too many SWT resources during the
* complete test suite.
*/
- @Test
- public void testSwtResourcesCount() throws Exception
+ @ParameterizedTest
+ @LdapServersSource(types = LdapServerType.ApacheDS)
+ public void testSwtResourcesCount( TestLdapServer server ) throws Exception
{
+ connectionsViewBot.createTestConnection( server );
int swtObjectCount = getSwtObjectCount();
- System.out.println("### SWT resouces count: " + swtObjectCount);
+ System.out.println( "### SWT resouces count: " + swtObjectCount );
assertTrue( "Too many SWT resources were allocated: " + swtObjectCount, swtObjectCount < 1500 );
}
@@ -135,7 +105,8 @@ public class SwtResourcesTest extends AbstractLdapTestUnit
DeviceData info = bot.getDisplay().getDeviceData();
if ( !info.tracking )
{
- fail( "To run this test options 'org.eclipse.ui/debug' and 'org.eclipse.ui/trace/graphics' must be true." );
+ fail(
+ "To run this test options 'org.eclipse.ui/debug' and 'org.eclipse.ui/trace/graphics' must be true." );
}
return info.objects.length;
}
@@ -145,8 +116,8 @@ public class SwtResourcesTest extends AbstractLdapTestUnit
private void createAndDeleteEntry( final String name ) throws Exception
{
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
- browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system" );
+ browserViewBot.selectEntry( path( MISC_DN ) );
+ browserViewBot.expandEntry( path( MISC_DN ) );
NewEntryWizardBot wizardBot = browserViewBot.openNewEntryWizard();
wizardBot.selectCreateEntryFromScratch();
@@ -161,8 +132,8 @@ public class SwtResourcesTest extends AbstractLdapTestUnit
wizardBot.clickFinishButton();
- assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "o=" + name ) );
- browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "o=" + name );
+ assertTrue( browserViewBot.existsEntry( path( MISC_DN, "o=" + name ) ) );
+ browserViewBot.selectEntry( path( MISC_DN, "o=" + name ) );
DeleteDialogBot dialog = browserViewBot.openDeleteDialog();
dialog.clickOkButton();
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ValueEditorTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ValueEditorTest.java
index 0896131..5a4f384 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ValueEditorTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ValueEditorTest.java
@@ -21,12 +21,13 @@
package org.apache.directory.studio.test.integration.ui;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.nio.charset.StandardCharsets;
+import java.util.stream.Stream;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
@@ -43,12 +44,9 @@ import org.apache.directory.studio.valueeditors.InPlaceTextValueEditor;
import org.apache.directory.studio.valueeditors.TextValueEditor;
import org.apache.directory.studio.valueeditors.bool.InPlaceBooleanValueEditor;
import org.apache.directory.studio.valueeditors.oid.InPlaceOidValueEditor;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
/**
@@ -56,8 +54,7 @@ import org.junit.runners.Parameterized.Parameters;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-@RunWith(Parameterized.class)
-public class ValueEditorTest
+public class ValueEditorTest extends AbstractTestBase
{
private static final String CN = "cn";
@@ -79,50 +76,55 @@ public class ValueEditorTest
private static final String NUMERIC_OID = "1.3.6.1.4.1.1466.20037";
private static final String DESCR_OID = "a-zA-Z0-9";
-
- @Parameters(name = "{0}")
- public static Object[] data()
+ public static Stream<Arguments> data()
{
- return new Object[][]
+ return Stream.of( new Object[][]
{
/*
* InPlaceTextValueEditor can handle string values and binary values that can be decoded as UTF-8.
*/
- { "InPlaceTextValueEditor - empty value",
+ {
+ "InPlaceTextValueEditor - empty value",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN )
.rawValue( IValue.EMPTY_STRING_VALUE ).expectedRawValue( EMPTY_STRING )
.expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
- { "InPlaceTextValueEditor - empty string",
+ {
+ "InPlaceTextValueEditor - empty string",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN )
.rawValue( EMPTY_STRING ).expectedRawValue( EMPTY_STRING ).expectedDisplayValue( EMPTY_STRING )
.expectedHasValue( true ).expectedStringOrBinaryValue( EMPTY_STRING ) },
- { "InPlaceTextValueEditor - ascii",
+ {
+ "InPlaceTextValueEditor - ascii",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN ).rawValue( ASCII )
.expectedRawValue( ASCII ).expectedDisplayValue( ASCII ).expectedHasValue( true )
.expectedStringOrBinaryValue( ASCII ) },
- { "InPlaceTextValueEditor - unicode",
+ {
+ "InPlaceTextValueEditor - unicode",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN ).rawValue( UNICODE )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
- { "InPlaceTextValueEditor - bytearray UTF8",
+ {
+ "InPlaceTextValueEditor - bytearray UTF8",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD ).rawValue( UTF8 )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle ISO-8859-1 encoded byte[]
- { "InPlaceTextValueEditor - bytearray ISO-8859-1",
+ {
+ "InPlaceTextValueEditor - bytearray ISO-8859-1",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD )
.rawValue( ISO88591 ).expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL )
.expectedHasValue( true ).expectedStringOrBinaryValue( null ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle arbitrary byte[]
- { "InPlaceTextValueEditor - bytearray PNG",
+ {
+ "InPlaceTextValueEditor - bytearray PNG",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD ).rawValue( PNG )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
@@ -131,32 +133,38 @@ public class ValueEditorTest
* InPlaceBooleanValueEditor can only handle TRUE or FALSE values.
*/
- { "InPlaceBooleanValueEditor - TRUE",
+ {
+ "InPlaceBooleanValueEditor - TRUE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( CN ).rawValue( TRUE )
.expectedRawValue( TRUE ).expectedDisplayValue( TRUE ).expectedHasValue( true )
.expectedStringOrBinaryValue( TRUE ) },
- { "InPlaceBooleanValueEditor - FALSE",
+ {
+ "InPlaceBooleanValueEditor - FALSE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( CN ).rawValue( FALSE )
.expectedRawValue( FALSE ).expectedDisplayValue( FALSE ).expectedHasValue( true )
.expectedStringOrBinaryValue( FALSE ) },
- { "InPlaceBooleanValueEditor - INVALID",
+ {
+ "InPlaceBooleanValueEditor - INVALID",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( CN )
.rawValue( "invalid" ).expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL )
.expectedHasValue( true ).expectedStringOrBinaryValue( null ) },
- { "InPlaceBooleanValueEditor - bytearray TRUE",
+ {
+ "InPlaceBooleanValueEditor - bytearray TRUE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( USER_PWD )
.rawValue( TRUE.getBytes( UTF_8 ) ).expectedRawValue( TRUE ).expectedDisplayValue( TRUE )
.expectedHasValue( true ).expectedStringOrBinaryValue( TRUE ) },
- { "InPlaceBooleanValueEditor - bytearray FALSE",
+ {
+ "InPlaceBooleanValueEditor - bytearray FALSE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( USER_PWD )
.rawValue( FALSE.getBytes( UTF_8 ) ).expectedRawValue( FALSE ).expectedDisplayValue( FALSE )
.expectedHasValue( true ).expectedStringOrBinaryValue( FALSE ) },
- { "InPlaceBooleanValueEditor - bytearray INVALID",
+ {
+ "InPlaceBooleanValueEditor - bytearray INVALID",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( USER_PWD )
.rawValue( "invalid".getBytes( UTF_8 ) ).expectedRawValue( null )
.expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
@@ -166,34 +174,40 @@ public class ValueEditorTest
* InPlaceOidValueEditor can only handle OIDs
*/
- { "InPlaceOidValueEditor - numeric OID",
+ {
+ "InPlaceOidValueEditor - numeric OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN ).rawValue( NUMERIC_OID )
.expectedRawValue( NUMERIC_OID ).expectedDisplayValue( NUMERIC_OID + " (Start TLS)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( NUMERIC_OID ) },
- { "InPlaceOidValueEditor - descr OID",
+ {
+ "InPlaceOidValueEditor - descr OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN ).rawValue( DESCR_OID )
.expectedRawValue( DESCR_OID ).expectedDisplayValue( DESCR_OID ).expectedHasValue( true )
.expectedStringOrBinaryValue( DESCR_OID ) },
- { "InPlaceOidValueEditor - relaxed descr OID",
+ {
+ "InPlaceOidValueEditor - relaxed descr OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN )
.rawValue( "orclDBEnterpriseRole_82" ).expectedRawValue( "orclDBEnterpriseRole_82" )
.expectedDisplayValue( "orclDBEnterpriseRole_82" ).expectedHasValue( true )
- .expectedStringOrBinaryValue("orclDBEnterpriseRole_82" ) },
+ .expectedStringOrBinaryValue( "orclDBEnterpriseRole_82" ) },
- { "InPlaceOidValueEditor - INVALID",
+ {
+ "InPlaceOidValueEditor - INVALID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN ).rawValue( "in valid" )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
- { "InPlaceOidValueEditor - bytearray numeric OID",
+ {
+ "InPlaceOidValueEditor - bytearray numeric OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( USER_PWD )
.rawValue( NUMERIC_OID.getBytes( UTF_8 ) ).expectedRawValue( NUMERIC_OID )
.expectedDisplayValue( NUMERIC_OID + " (Start TLS)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( NUMERIC_OID ) },
- { "InPlaceOidValueEditor - bytearray INVALID",
+ {
+ "InPlaceOidValueEditor - bytearray INVALID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( USER_PWD )
.rawValue( "in valid".getBytes( UTF_8 ) ).expectedRawValue( null )
.expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
@@ -203,51 +217,60 @@ public class ValueEditorTest
* TextValueEditor can handle string values and binary values that can be decoded as UTF-8.
*/
- { "TextValueEditor - empty string value",
+ {
+ "TextValueEditor - empty string value",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN )
.rawValue( IValue.EMPTY_STRING_VALUE ).expectedRawValue( EMPTY_STRING )
.expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
- { "TextValueEditor - empty string",
+ {
+ "TextValueEditor - empty string",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN ).rawValue( EMPTY_STRING )
.expectedRawValue( EMPTY_STRING ).expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
- { "TextValueEditor - ascii",
+ {
+ "TextValueEditor - ascii",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN ).rawValue( ASCII )
.expectedRawValue( ASCII ).expectedDisplayValue( ASCII ).expectedHasValue( true )
.expectedStringOrBinaryValue( ASCII ) },
- { "TextValueEditor - unicode",
+ {
+ "TextValueEditor - unicode",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN ).rawValue( UNICODE )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
- { "TextValueEditor - empty binary value",
+ {
+ "TextValueEditor - empty binary value",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD )
.rawValue( IValue.EMPTY_BINARY_VALUE ).expectedRawValue( EMPTY_STRING )
.expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
- { "TextValueEditor - empty bytearray",
+ {
+ "TextValueEditor - empty bytearray",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD ).rawValue( EMPTY_BYTES )
.expectedRawValue( EMPTY_STRING ).expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
- { "TextValueEditor - bytearray UTF8",
+ {
+ "TextValueEditor - bytearray UTF8",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD ).rawValue( UTF8 )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle ISO-8859-1 encoded byte[]
- { "TextValueEditor - bytearray ISO-8859-1",
+ {
+ "TextValueEditor - bytearray ISO-8859-1",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD ).rawValue( ISO88591 )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle arbitrary byte[]
- { "TextValueEditor - bytearray PNG",
+ {
+ "TextValueEditor - bytearray PNG",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD ).rawValue( PNG )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
@@ -256,65 +279,64 @@ public class ValueEditorTest
* HexValueEditor can handle all string or binary values.
*/
- { "HexValueEditor - empty string value",
+ {
+ "HexValueEditor - empty string value",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( CN )
.rawValue( IValue.EMPTY_STRING_VALUE ).expectedRawValue( EMPTY_BYTES )
.expectedDisplayValue( "Binary Data (0 Bytes)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_BYTES ) },
- { "HexValueEditor - empty string",
+ {
+ "HexValueEditor - empty string",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( CN ).rawValue( EMPTY_STRING )
.expectedRawValue( EMPTY_BYTES ).expectedDisplayValue( "Binary Data (0 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( EMPTY_BYTES ) },
- { "HexValueEditor - ascii",
+ {
+ "HexValueEditor - ascii",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( CN ).rawValue( ASCII )
.expectedRawValue( ASCII.getBytes( StandardCharsets.US_ASCII ) )
.expectedDisplayValue( "Binary Data (9 Bytes)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( ASCII.getBytes( StandardCharsets.US_ASCII ) ) },
- { "HexValueEditor - empty binary value",
+ {
+ "HexValueEditor - empty binary value",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD )
.rawValue( IValue.EMPTY_BINARY_VALUE ).expectedRawValue( EMPTY_BYTES )
.expectedDisplayValue( "Binary Data (0 Bytes)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_BYTES ) },
- { "HexValueEditor - empty bytearray",
+ {
+ "HexValueEditor - empty bytearray",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( EMPTY_BYTES )
.expectedRawValue( EMPTY_BYTES ).expectedDisplayValue( "Binary Data (0 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( EMPTY_BYTES ) },
- { "HexValueEditor - bytearray UTF8",
+ {
+ "HexValueEditor - bytearray UTF8",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( UTF8 )
.expectedRawValue( UTF8 ).expectedDisplayValue( "Binary Data (30 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( UTF8 ) },
- { "HexValueEditor - bytearray ISO-8859-1",
+ {
+ "HexValueEditor - bytearray ISO-8859-1",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( ISO88591 )
.expectedRawValue( ISO88591 ).expectedDisplayValue( "Binary Data (4 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( ISO88591 ) },
- { "HexValueEditor - bytearray PNG",
+ {
+ "HexValueEditor - bytearray PNG",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( PNG )
.expectedRawValue( PNG ).expectedDisplayValue( "Binary Data (4 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( PNG ) },
-
- };
+ } ).map( d -> Arguments.arguments( ( String ) d[0], ( Data ) d[1] ) );
}
- @Parameter(value = 0)
- public String name;
-
- @Parameter(value = 1)
- public Data data;
-
private IValue value;
private IValueEditor editor;
-
- @Before
- public void setup() throws Exception
+ public void setup( String name, Data data ) throws Exception
{
IEntry entry = new DummyEntry( new Dn(), new DummyConnection( Schema.DEFAULT_SCHEMA ) );
IAttribute attribute = new Attribute( entry, data.attribute );
@@ -323,9 +345,11 @@ public class ValueEditorTest
}
- @Test
- public void testGetRawValue()
+ @ParameterizedTest
+ @MethodSource("data")
+ public void testGetRawValue( String name, Data data ) throws Exception
{
+ setup( name, data );
if ( data.expectedRawValue instanceof byte[] )
{
assertArrayEquals( ( byte[] ) data.expectedRawValue, ( byte[] ) editor.getRawValue( value ) );
@@ -337,23 +361,29 @@ public class ValueEditorTest
}
- @Test
- public void testGetDisplayValue()
+ @ParameterizedTest
+ @MethodSource("data")
+ public void testGetDisplayValue( String name, Data data ) throws Exception
{
+ setup( name, data );
assertEquals( data.expectedDisplayValue, editor.getDisplayValue( value ) );
}
- @Test
- public void testHasValue()
+ @ParameterizedTest
+ @MethodSource("data")
+ public void testHasValue( String name, Data data ) throws Exception
{
+ setup( name, data );
assertEquals( data.expectedHasValue, editor.hasValue( value ) );
}
- @Test
- public void testGetStringOrBinaryValue()
+ @ParameterizedTest
+ @MethodSource("data")
+ public void testGetStringOrBinaryValue( String name, Data data ) throws Exception
{
+ setup( name, data );
if ( data.expectedStringOrBinaryValue instanceof byte[] )
{
assertArrayEquals( ( byte[] ) data.expectedStringOrBinaryValue,
@@ -382,7 +412,6 @@ public class ValueEditorTest
public Object expectedStringOrBinaryValue;
-
public static Data data()
{
return new Data();