From 44a563a5e38a0b1054fd61f373eb107433a0a8d8 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 21 Apr 2015 15:07:12 +0000
Subject: [PATCH] AutoRefactor'ed TestNG assertions Code cleanup: - factorized code by extracting methods
---
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AlternateRootDN.java | 13
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetTestCase.java | 11
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java | 7
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java | 3
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/spi/PropertySetTest.java | 5
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestJebFormat.java | 3
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java | 10
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java | 96 +-
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java | 26
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java | 42
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java | 1309 +++---------------------------
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordControlTest.java | 107 -
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/UtilsTest.java | 9
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java | 5
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/GetEffectiveRightsTestCase.java | 41
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/NestedGroupDNTestCase.java | 21
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/FileManagerTest.java | 48
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java | 12
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/ConfigurationTest.java | 7
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java | 23
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/ModifyEntryMockLDAPConnection.java | 20
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestJebFormat.java | 3
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/AdditionalLogItemTest.java | 13
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ServerSideSortControlTestCase.java | 3
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/CreateEntryMockLDAPConnection.java | 22
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordPolicyControlTestCase.java | 502 +---------
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ProxiedAuthV1ControlTestCase.java | 10
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java | 38
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java | 11
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java | 13
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java | 28
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java | 74
32 files changed, 547 insertions(+), 1,988 deletions(-)
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/ConfigurationTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/ConfigurationTest.java
index 59bf548..7643acc 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/ConfigurationTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/ConfigurationTest.java
@@ -22,8 +22,8 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2015 ForgeRock AS.
*/
-
package org.opends.quicksetup;
import static org.testng.Assert.*;
@@ -35,10 +35,11 @@
/**
* Configuration Tester.
*/
+@SuppressWarnings("javadoc")
@Test(groups = {"slow"})
public class ConfigurationTest extends QuickSetupTestCase {
- Configuration config;
+ private Configuration config;
@BeforeClass
public void setUp() throws Exception {
@@ -53,7 +54,7 @@
@Test(enabled = false)
public void testGetPort() throws IOException {
- assertTrue(TestUtilities.ldapPort.equals(config.getPort()));
+ assertEquals(TestUtilities.ldapPort, (Integer) config.getPort());
}
@Test(enabled = false)
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/FileManagerTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/FileManagerTest.java
index bee3f2a..4d1b48c 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/FileManagerTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/FileManagerTest.java
@@ -51,11 +51,12 @@
/**
* FileManager Tester.
*/
+@SuppressWarnings("javadoc")
@Test(groups = {"slow"}, sequential=true)
public class FileManagerTest extends QuickSetupTestCase {
- File fmWorkspace;
- FileManager fileManager;
+ private File fmWorkspace;
+ private FileManager fileManager;
@BeforeClass
public void setUp() throws Exception {
@@ -121,22 +122,19 @@
// Make sure files we deleted above were copied from the source dir
assertTrue(t_f2b1.exists());
- assertTrue(childOfS.equals(contentsOf(t_f2b1)));
+ assertEquals(childOfS, contentsOf(t_f2b1));
assertTrue(t_d2b.exists());
assertTrue(t_f1a.exists());
- assertTrue(childOfS.equals(contentsOf(t_f1a)));
+ assertEquals(childOfS, contentsOf(t_f1a));
// Make sure files that pre-existed didn't get touched
- assertTrue(childOfT.equals(contentsOf(t_f1b)));
- assertTrue(childOfT.equals(contentsOf(t_f2a)));
+ assertEquals(childOfT, contentsOf(t_f1b));
+ assertEquals(childOfT, contentsOf(t_f2a));
}
- /**
- * Tests the rename.
- * @throws Exception
- */
+ /** Tests the rename. */
@Test
public void testRenameNonExistentTarget() throws Exception {
File src = File.createTempFile("src", null);
@@ -330,7 +328,7 @@
FileManager.DeletionPolicy.DELETE_IMMEDIATELY);
assertTrue(dir.exists());
// Make sure we didn't lose any kids
- assertTrue(childCount == countSelfAndAllChildren(dir));
+ assertEquals(childCount, countSelfAndAllChildren(dir));
// Test that using a filter to delete one file works
FileFilter killChildFileFilter = new FileFilter() {
@@ -344,7 +342,7 @@
fileManager.deleteRecursively(dir, killChildFileFilter,
FileManager.DeletionPolicy.DELETE_IMMEDIATELY);
assertTrue(dir.exists());
- assertTrue((childCount -1) == countSelfAndAllChildren(dir));
+ assertEquals((childCount -1), countSelfAndAllChildren(dir));
assertFalse(f2b1.exists());
}
@@ -361,7 +359,7 @@
assertTrue(children == null || children.length == 0);
fileManager.copy(file, dir);
assertTrue(file.exists());
- assertTrue(dir.list().length == 1);
+ assertEquals(dir.list().length, 1);
}
/**
@@ -392,15 +390,13 @@
String ORIGINAL_CHILD_CONTENT = "orinld";
writeContents(dirChild, ORIGINAL_CHILD_CONTENT);
- // Try a copy without overwriting and make sure the original
- // file didn't get replaced.
+ // Try a copy without overwriting and make sure the original file didn't get replaced.
fileManager.copy(file, dir, false);
- assertTrue(contentsOf(dirChild).equals(ORIGINAL_CHILD_CONTENT));
+ assertEquals(contentsOf(dirChild), ORIGINAL_CHILD_CONTENT);
- // New try a copy with overwrite true and make sure the original
- // file got replaced.
+ // New try a copy with overwrite true and make sure the original file got replaced.
fileManager.copy(file, dir, true);
- assertTrue(contentsOf(dirChild).equals(NEW_CHILD_CONTENT));
+ assertEquals(contentsOf(dirChild), NEW_CHILD_CONTENT);
}
/**
@@ -418,7 +414,7 @@
File copiedSource = new File(dest, "source");
assertTrue(copiedSource.exists());
- assertTrue(count == countSelfAndAllChildren(copiedSource));
+ assertEquals(count, countSelfAndAllChildren(copiedSource));
}
/**
@@ -447,7 +443,7 @@
File copiedSource = new File(dest, "source");
assertFalse(copiedSource.exists());
- assertTrue(countSelfAndAllChildren(dest) == 1);
+ assertEquals(countSelfAndAllChildren(dest), 1);
// Test that using a filter to delete one file works
FileFilter copyChildFileFilter = new FileFilter() {
@@ -461,11 +457,11 @@
File copiedD2b = new File(d2, "d2b");
final File copiedF2b1 = new File(d2b, "f2b1");
assertTrue(copiedSource.exists());
- assertTrue(countSelfAndAllChildren(copiedSource) == 4);
+ assertEquals(countSelfAndAllChildren(copiedSource), 4);
assertTrue(copiedD2.exists());
- assertTrue(countSelfAndAllChildren(copiedD2) == 3);
+ assertEquals(countSelfAndAllChildren(copiedD2), 3);
assertTrue(copiedD2b.exists());
- assertTrue(countSelfAndAllChildren(copiedD2b) == 2);
+ assertEquals(countSelfAndAllChildren(copiedD2b), 2);
assertTrue(copiedF2b1.exists());
}
@@ -501,11 +497,11 @@
};
// With overwrite off make sure it doesn't get replaced
fileManager.copyRecursively(source, dest, copyChildFileFilter, false);
- assertTrue(ORIGINAL.equals(contentsOf(copiedF2b1)));
+ assertEquals(ORIGINAL, contentsOf(copiedF2b1));
// Now with overwrite make sure it gets replaced.
fileManager.copyRecursively(source, dest, copyChildFileFilter, true);
- assertTrue(ORIGINAL.equals(contentsOf(copiedF2b1)));
+ assertEquals(ORIGINAL, contentsOf(copiedF2b1));
}
@DataProvider(name = "differTestData")
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/UtilsTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/UtilsTest.java
index 982b83a..4d15e31 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/UtilsTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/quicksetup/util/UtilsTest.java
@@ -22,8 +22,8 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2015 ForgeRock AS.
*/
-
package org.opends.quicksetup.util;
import static org.testng.Assert.*;
@@ -52,7 +52,7 @@
@Test(dataProvider = "breakHtmlStringData")
public void testBreakHtmlString(String s, int maxll, String expectedValue) {
- assertTrue(Utils.breakHtmlString(s, maxll).equals(expectedValue));
+ assertEquals(Utils.breakHtmlString(s, maxll), expectedValue);
}
@DataProvider(name = "stripHtmlData")
@@ -71,7 +71,7 @@
@Test(enabled = false, dataProvider = "stripHtmlData")
public void testStripHtml(String html, String expectedResult) {
- assertTrue(expectedResult.equals(Utils.stripHtml(html)));
+ assertEquals(expectedResult, Utils.stripHtml(html));
}
@DataProvider(name = "containsHtmlData")
@@ -84,7 +84,6 @@
@Test(enabled = false, dataProvider = "containsHtmlData")
public void testContainsHtml(String s, boolean expectedResult) {
- assertTrue(expectedResult == Utils.containsHtml(s));
+ assertEquals(expectedResult, Utils.containsHtml(s));
}
-
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
index 2dc000b..843ab9a 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
@@ -71,12 +71,10 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.opends.server.types.FilePermission;
-import org.opends.server.types.InitializationException;
-import org.opends.server.types.LDIFImportConfig;
-import org.opends.server.types.Schema;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.LDIFReader;
+import org.testng.Assert;
import com.forgerock.opendj.util.OperatingSystem;
@@ -1987,4 +1985,28 @@
}
return dump.toString();
}
+
+ /** FIXME Replace with {@link Assert#assertNotEquals(Object, Object)} once we upgrade to testng >= 6.1. */
+ public static void assertNotEquals(Object actual1, Object actual2)
+ {
+ assertNotEquals(actual1, actual2, null);
+ }
+
+ /** FIXME Replace with {@link Assert#assertNotEquals(Object, Object, String)} once we upgrade to testng >= 6.1. */
+ public static void assertNotEquals(Object actual1, Object actual2, String message)
+ {
+ boolean fail = false;
+ try
+ {
+ Assert.assertEquals(actual1, actual2);
+ fail = true;
+ }
+ catch (AssertionError e)
+ {
+ }
+ if (fail)
+ {
+ Assert.fail(message);
+ }
+ }
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java
index 475f873..1854746 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java
@@ -22,13 +22,11 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
+ * Portions Copyright 2014-2015 ForgeRock AS
*/
-
package org.opends.server.admin;
-
-
+import static org.opends.server.TestCaseUtils.*;
import static org.testng.Assert.*;
import org.opends.server.DirectoryServerTestCase;
@@ -49,8 +47,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-
-
/**
* ManagedObjectPath test cases.
*/
@@ -121,7 +117,7 @@
@Test
public void testEmptyPathHasNoRelation() {
ManagedObjectPath<?, ?> path = ManagedObjectPath.emptyPath();
- assertEquals(path.getRelationDefinition(), null);
+ assertNull(path.getRelationDefinition());
}
@@ -300,20 +296,20 @@
assertTrue(child1.matches(child2));
assertTrue(child2.matches(child1));
- assertTrue(child1.equals(child1));
- assertTrue(child2.equals(child2));
- assertFalse(child1.equals(child2));
- assertFalse(child2.equals(child1));
+ assertEquals(child1, child1);
+ assertEquals(child2, child2);
+ assertNotEquals(child1, child2);
+ assertNotEquals(child2, child1);
assertFalse(child1.matches(child3));
assertFalse(child2.matches(child3));
assertFalse(child3.matches(child1));
assertFalse(child3.matches(child2));
- assertFalse(child1.equals(child3));
- assertFalse(child2.equals(child3));
- assertFalse(child3.equals(child1));
- assertFalse(child3.equals(child2));
+ assertNotEquals(child1, child3);
+ assertNotEquals(child2, child3);
+ assertNotEquals(child3, child1);
+ assertNotEquals(child3, child2);
}
/**
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java
index 07268a1..e2ba87d 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java
@@ -71,7 +71,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setLowerLimit(1);
SizePropertyDefinition spd = buildTestDefinition(builder);
- assertTrue(spd.getLowerLimit() == 1);
+ assertEquals(spd.getLowerLimit(), 1);
}
/**
@@ -107,11 +107,11 @@
* @param expectedValue to compare
*/
@Test(dataProvider = "stringLimitData")
- public void testLowerLimit2(String limit, Long expectedValue) {
+ public void testLowerLimit2(String limit, long expectedValue) {
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setLowerLimit(limit);
SizePropertyDefinition spd = buildTestDefinition(builder);
- assertTrue(spd.getLowerLimit() == expectedValue);
+ assertEquals(spd.getLowerLimit(), expectedValue);
}
/**
@@ -122,7 +122,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setLowerLimit(1);
SizePropertyDefinition spd = buildTestDefinition(builder);
- assertTrue(spd.getLowerLimit() == 1);
+ assertEquals(spd.getLowerLimit(), 1);
}
/**
@@ -131,11 +131,11 @@
* @param expectedValue to compare
*/
@Test(dataProvider = "stringLimitData")
- public void testUpperLimit2(String limit, long expectedValue) {
+ public void testUpperLimit2(String limit, Long expectedValue) {
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setUpperLimit(limit);
SizePropertyDefinition spd = buildTestDefinition(builder);
- assertTrue(spd.getUpperLimit().equals(expectedValue));
+ assertEquals(spd.getUpperLimit(), expectedValue);
}
/**
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/CreateEntryMockLDAPConnection.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/CreateEntryMockLDAPConnection.java
index bc3a4cb..85bad91 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/CreateEntryMockLDAPConnection.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/CreateEntryMockLDAPConnection.java
@@ -26,7 +26,7 @@
*/
package org.opends.server.admin.client.ldap;
-
+import static org.testng.Assert.*;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,9 +41,6 @@
import javax.naming.ldap.LdapName;
import org.forgerock.util.Reject;
-import org.testng.Assert;
-
-
/**
* A mock LDAP connection which is used to verify that an add
@@ -100,7 +97,7 @@
* Asserts that the entry was created.
*/
public void assertEntryIsCreated() {
- Assert.assertTrue(alreadyAdded);
+ assertTrue(alreadyAdded);
}
@@ -109,25 +106,20 @@
@Override
public void createEntry(LdapName dn, Attributes attributes)
throws NamingException {
- Assert.assertFalse(alreadyAdded);
- Assert.assertEquals(dn, expectedDN);
+ assertFalse(alreadyAdded);
+ assertEquals(dn, expectedDN);
- Map<String, List<String>> expected = new HashMap<String, List<String>>(
- this.attributes);
+ Map<String, List<String>> expected = new HashMap<>(this.attributes);
NamingEnumeration<? extends Attribute> ne = attributes.getAll();
while (ne.hasMore()) {
Attribute attribute = ne.next();
String attrID = attribute.getID();
List<String> values = expected.remove(attrID);
- if (values == null) {
- Assert.fail("Unexpected attribute " + attrID);
- }
+ assertNotNull(values, "Unexpected attribute " + attrID);
assertAttributeEquals(attribute, values);
}
- if (!expected.isEmpty()) {
- Assert.fail("Missing expected attributes: " + expected.keySet());
- }
+ assertTrue(expected.isEmpty(), "Missing expected attributes: " + expected.keySet());
alreadyAdded = true;
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java
index 1525a9e..aea4cc1 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java
@@ -543,11 +543,10 @@
.getInstance(), "test child new", null);
// Check pre-commit values.
- Assert.assertEquals(child.isMandatoryBooleanProperty(), null);
+ Assert.assertNull(child.isMandatoryBooleanProperty());
Assert.assertEquals(child.getMandatoryClassProperty(),
"org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- Assert
- .assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), null);
+ Assert.assertNull(child.getMandatoryReadOnlyAttributeTypeProperty());
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(),
"dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(),
@@ -588,11 +587,10 @@
.getInstance(), "test child new", null);
// Check pre-commit values.
- Assert.assertEquals(child.isMandatoryBooleanProperty(), null);
+ Assert.assertNull(child.isMandatoryBooleanProperty());
Assert.assertEquals(child.getMandatoryClassProperty(),
"org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- Assert
- .assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), null);
+ Assert.assertNull(child.getMandatoryReadOnlyAttributeTypeProperty());
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(),
"dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(),
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/ModifyEntryMockLDAPConnection.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/ModifyEntryMockLDAPConnection.java
index 97a5fe2..d6c27f3 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/ModifyEntryMockLDAPConnection.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/ModifyEntryMockLDAPConnection.java
@@ -26,7 +26,7 @@
*/
package org.opends.server.admin.client.ldap;
-
+import static org.testng.Assert.*;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,9 +41,6 @@
import javax.naming.ldap.LdapName;
import org.forgerock.util.Reject;
-import org.testng.Assert;
-
-
/**
* A mock LDAP connection which is used to verify that a modify
@@ -111,25 +108,20 @@
/** {@inheritDoc} */
@Override
public void modifyEntry(LdapName dn, Attributes mods) throws NamingException {
- Assert.assertFalse(alreadyModified);
- Assert.assertEquals(dn, expectedDN);
+ assertFalse(alreadyModified);
+ assertEquals(dn, expectedDN);
- Map<String, List<String>> expected = new HashMap<String, List<String>>(
- modifications);
+ Map<String, List<String>> expected = new HashMap<>(modifications);
NamingEnumeration<? extends Attribute> ne = mods.getAll();
while (ne.hasMore()) {
Attribute mod = ne.next();
String attrID = mod.getID();
List<String> values = expected.remove(attrID);
- if (values == null) {
- Assert.fail("Unexpected modification to attribute " + attrID);
- }
+ assertNotNull(values, "Unexpected modification to attribute " + attrID);
assertAttributeEquals(mod, values);
}
- if (!expected.isEmpty()) {
- Assert.fail("Missing modifications to: " + expected.keySet());
- }
+ assertTrue(expected.isEmpty(), "Missing modifications to: " + expected.keySet());
alreadyModified = true;
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/spi/PropertySetTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/spi/PropertySetTest.java
index 912ccaf..c8dc3ee 100755
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/spi/PropertySetTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/admin/client/spi/PropertySetTest.java
@@ -200,7 +200,7 @@
PropertySet ps = createTestPropertySet(pp);
Property<T> p = ps.getProperty(pd);
SortedSet<T> ss = p.getActiveValues();
- assertTrue(ss.size() == values.size());
+ assertEquals(ss.size(), values.size());
for (T v : values) {
assertTrue(ss.contains(v));
}
@@ -325,11 +325,10 @@
ps.setPropertyValues(pd, newValues);
Set<T> ev2 = p.getEffectiveValues();
- assertTrue(ev2.size() == newValues.size());
+ assertEquals(ev2.size(), newValues.size());
for(T v : ev2) {
assertTrue(newValues.contains(v));
}
-
}
/**
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java
index 35028d2..9fe1dce 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/api/PasswordValidatorTestCase.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.api;
-
-
import java.net.Socket;
import java.util.ArrayList;
import java.util.Set;
@@ -50,6 +48,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.opends.server.TestCaseUtils.*;
import static org.testng.Assert.*;
/**
@@ -184,7 +183,7 @@
int returnCode = LDAPPasswordModify.mainPasswordModify(args, false, null,
null);
- assertFalse(returnCode == 0);
+ assertNotEquals(returnCode, 0);
assertEquals(TestPasswordValidator.getLastNewPassword(),
ByteString.valueOf("newPassword"));
@@ -525,7 +524,7 @@
message = r.readMessage();
ModifyResponseProtocolOp modifyResponse =
message.getModifyResponseProtocolOp();
- assertFalse(modifyResponse.getResultCode() == 0);
+ assertNotEquals(modifyResponse.getResultCode(), 0);
assertEquals(TestPasswordValidator.getLastNewPassword(),
ByteString.valueOf("newPassword"));
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java
index 6d1b963..19a8bec 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java
@@ -24,10 +24,10 @@
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
* Portions Copyright 2013 Manuel Gaupp
- *
*/
package org.opends.server.authorization.dseecompat;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -1795,7 +1795,7 @@
String userResults =
ldapCompare(adminParam.getLdapCompareArgs("cn:level3 user"),
LDAPResultCode.COMPARE_TRUE);
- Assert.assertFalse(userResults.equals(""));
+ assertNotEquals(userResults, "");
}
@@ -1840,12 +1840,12 @@
makeModDN(SALES_DN, "cn=sales dept", "0", MANAGER_NEW_DN);
modEntries(modrdnLdif, LEVEL_1_USER_DN, "pa$$word", PROXY_USER_DN);
String userNewResults = ldapSearch(userParamNew.getLdapSearchArgs());
- Assert.assertFalse(userNewResults.equals(""));
+ assertNotEquals(userNewResults, "");
String modrdnLdif1 =
makeModDN(SALES_NEW_DN, "cn=sales dept", "0", MANAGER_DN);
modEntries(modrdnLdif1, LEVEL_1_USER_DN, "pa$$word", PROXY_USER_DN);
String userOrigResults = ldapSearch(userParamOrig.getLdapSearchArgs());
- Assert.assertFalse(userOrigResults.equals(""));
+ assertNotEquals(userOrigResults, "");
}
}
@@ -1880,12 +1880,12 @@
makeModDN(SALES_DN, "cn=sales dept", "0", MANAGER_NEW_DN);
modEntries(modrdnLdif, LEVEL_1_USER_DN, "pa$$word");
String userNewResults = ldapSearch(userParamNew.getLdapSearchArgs());
- Assert.assertFalse(userNewResults.equals(""));
+ assertNotEquals(userNewResults, "");
String modrdnLdif1 =
makeModDN(SALES_NEW_DN, "cn=sales dept", "0", MANAGER_DN);
modEntries(modrdnLdif1, LEVEL_1_USER_DN, "pa$$word");
String userOrigResults = ldapSearch(userParamOrig.getLdapSearchArgs());
- Assert.assertFalse(userOrigResults.equals(""));
+ assertNotEquals(userOrigResults, "");
}
}
@@ -1940,7 +1940,7 @@
addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW);
modEntries(DNS_ALL_ACI, DIR_MGR_DN, DIR_MGR_PW);
String userResults = ldapSearch(userParam.getLdapSearchArgs());
- Assert.assertFalse(userResults.equals(""));
+ assertNotEquals(userResults, "");
}
}
@@ -1965,9 +1965,9 @@
addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW);
modEntries(GROUP1_GROUPDN_MODS, DIR_MGR_DN, DIR_MGR_PW);
String userResults = ldapSearch(userParam.getLdapSearchArgs());
- Assert.assertFalse(userResults.equals(""));
+ assertNotEquals(userResults, "");
String adminResults = ldapSearch(adminParam.getLdapSearchArgs());
- Assert.assertTrue(adminResults.equals(""));
+ Assert.assertEquals(adminResults, "");
}
}
@@ -1992,14 +1992,14 @@
addEntries(BASIC_LDIF__SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW);
modEntries(GLOBAL_MODS, DIR_MGR_DN, DIR_MGR_PW);
String monitorResults = ldapSearch(monitorParam.getLdapSearchArgs());
- Assert.assertFalse(monitorResults.equals(""));
+ assertNotEquals(monitorResults, "");
String baseResults = ldapSearch(baseParam.getLdapSearchArgs());
- Assert.assertFalse(baseResults.equals(""));
+ assertNotEquals(baseResults, "");
deleteAttrFromEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI, true);
monitorResults = ldapSearch(monitorParam.getLdapSearchArgs());
- Assert.assertTrue(monitorResults.equals(""));
+ Assert.assertEquals(monitorResults, "");
baseResults = ldapSearch(baseParam.getLdapSearchArgs());
- Assert.assertTrue(baseResults.equals(""));
+ Assert.assertEquals(baseResults, "");
}
@Test(dataProvider = "searchTestParams")
@@ -2019,7 +2019,7 @@
diffFromExpected = diffLdif(params._expectedResultsLdif, searchResults);
// Ignoring whitespace the diff should be empty.
- Assert.assertTrue(diffFromExpected.replaceAll("\\s", "").length() == 0);
+ assertEquals(diffFromExpected.trim(), "");
} catch (Throwable e) {
System.err.println(
"Started with dit:\n" +
@@ -2064,8 +2064,7 @@
String diffFromExpected = diffLdif(actualResults, expectedLdif);
// Ignoring whitespace the diff should be empty.
- Assert.assertTrue(diffFromExpected.replaceAll("\\s", "").length() == 0,
- "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif);
+ assertEquals(diffFromExpected.trim(), "", "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif);
// Add the ACI: this will prevent the cn and sn attributes from being read
@@ -2081,8 +2080,7 @@
diffFromExpected = diffLdif(actualResults, expectedLdif);
// Ignoring whitespace the diff should be empty.
- Assert.assertTrue(diffFromExpected.replaceAll("\\s", "").length() == 0,
- "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif);
+ assertEquals(diffFromExpected.trim(), "", "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif);
}
@@ -2121,14 +2119,14 @@
null, null, null);
String monitorResults = ldapSearch(monitorParam.getLdapSearchArgs());
- Assert.assertFalse(monitorResults.equals(""));
+ assertNotEquals(monitorResults, "");
String baseResults = ldapSearch(baseParam.getLdapSearchArgs());
- Assert.assertFalse(baseResults.equals(""));
+ assertNotEquals(baseResults, "");
deleteAttrFromEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI, true);
monitorResults = ldapSearch(monitorParam.getLdapSearchArgs());
- Assert.assertTrue(monitorResults.equals(""));
+ Assert.assertEquals(monitorResults, "");
baseResults = ldapSearch(baseParam.getLdapSearchArgs());
- Assert.assertTrue(baseResults.equals(""));
+ Assert.assertEquals(baseResults, "");
// Test selfwrite right. Attempt to bind as level3 user and remove
// level1 user from a group, should fail.
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AlternateRootDN.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AlternateRootDN.java
index aa7ca0e..787fac3 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AlternateRootDN.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AlternateRootDN.java
@@ -26,6 +26,7 @@
*/
package org.opends.server.authorization.dseecompat;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -96,19 +97,19 @@
String adminDNResults =
LDAPSearchParams(adminDN, PWD, null, null, null,
user1, pwdFilter, ATTR_USER_PASSWORD);
- Assert.assertFalse("".equals(adminDNResults));
+ assertNotEquals(adminDNResults, "");
Map<String, String> attrMap = getAttrMap(adminDNResults);
Assert.assertTrue(attrMap.containsKey(ATTR_USER_PASSWORD));
String adminRootDNResults =
LDAPSearchParams(adminRootDN, PWD, null, null, null,
user1, pwdFilter, ATTR_USER_PASSWORD);
- Assert.assertFalse("".equals(adminRootDNResults));
+ assertNotEquals(adminRootDNResults, "");
Map<String, String> attrMap1 = getAttrMap(adminRootDNResults);
Assert.assertTrue(attrMap1.containsKey(ATTR_USER_PASSWORD));
String rootDNResults =
LDAPSearchParams(rootDN, PWD, null, null, null,
user1, pwdFilter, ATTR_USER_PASSWORD);
- Assert.assertFalse("".equals(rootDNResults));
+ assertNotEquals(rootDNResults, "");
Map<String, String> attrMap2 = getAttrMap(rootDNResults);
Assert.assertTrue(attrMap2.containsKey(ATTR_USER_PASSWORD));
deleteAttrFromEntry(user1, "aci");
@@ -133,19 +134,19 @@
String adminDNResults =
LDAPSearchParams(user3, PWD, adminDN, null, null,
user1, pwdFilter, ATTR_USER_PASSWORD);
- Assert.assertFalse("".equals(adminDNResults));
+ assertNotEquals(adminDNResults, "");
Map<String, String> attrMap = getAttrMap(adminDNResults);
Assert.assertTrue(attrMap.containsKey(ATTR_USER_PASSWORD));
String adminRootDNResults =
LDAPSearchParams(user3, PWD, adminRootDN, null, null,
user1, pwdFilter, ATTR_USER_PASSWORD);
- Assert.assertFalse("".equals(adminRootDNResults));
+ assertNotEquals(adminRootDNResults, "");
Map<String, String> attrMap1 = getAttrMap(adminRootDNResults);
Assert.assertTrue(attrMap1.containsKey(ATTR_USER_PASSWORD));
String rootDNResults =
LDAPSearchParams(user3, PWD, adminDN, null, null,
user1, pwdFilter, ATTR_USER_PASSWORD);
- Assert.assertFalse("".equals(rootDNResults));
+ assertNotEquals(rootDNResults, "");
Map<String, String> attrMap2 = getAttrMap(rootDNResults);
Assert.assertTrue(attrMap2.containsKey(ATTR_USER_PASSWORD));
deleteAttrFromEntry(user1, "aci");
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/GetEffectiveRightsTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/GetEffectiveRightsTestCase.java
index ff7b47d..91d0436 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/GetEffectiveRightsTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/GetEffectiveRightsTestCase.java
@@ -26,12 +26,13 @@
*/
package org.opends.server.authorization.dseecompat;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
+import static org.testng.Assert.*;
import java.util.Map;
-import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -184,7 +185,7 @@
String userResults =
LDAPSearchParams(DIR_MGR_DN, PWD, null, "dn:", null,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkEntryLevel(attrMap, rRights);
}
@@ -204,7 +205,7 @@
String userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkEntryLevel(attrMap, rRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", addAci);
@@ -212,7 +213,7 @@
userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, arRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", delAci);
@@ -220,7 +221,7 @@
userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, adrRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", writeAci);
@@ -228,7 +229,7 @@
userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, adrwRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", proxyAci);
@@ -236,7 +237,7 @@
userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, allRights);
}
@@ -257,7 +258,7 @@
String userResults =
LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkEntryLevel(attrMap, rRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", addAci);
@@ -265,7 +266,7 @@
userResults =
LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, arRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", delAci);
@@ -273,7 +274,7 @@
userResults =
LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, adrRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", writeAci);
@@ -281,7 +282,7 @@
userResults =
LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, adrwRights);
aciLdif=makeAddLDIF("aci", "ou=People,o=test", proxyAci);
@@ -289,7 +290,7 @@
userResults =
LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
attrMap=getAttrMap(userResults);
checkEntryLevel(attrMap, allRights);
}
@@ -307,7 +308,7 @@
String userResults =
LDAPSearchCtrl(DIR_MGR_DN, PWD, null, OID_GET_EFFECTIVE_RIGHTS,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkEntryLevel(attrMap, bypassRights);
}
@@ -331,7 +332,7 @@
String userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null,
base, filter, "aclRights mail description");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkAttributeLevel(attrMap, "mail", srwMailAttrRights);
checkAttributeLevel(attrMap, "description", srDescrptionAttrRights);
@@ -362,7 +363,7 @@
String userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, attrList,
base, filter, "aclRights mail description");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkAttributeLevel(attrMap, "mail", srwMailAttrRights);
checkAttributeLevel(attrMap, "description", srDescrptionAttrRights);
@@ -391,7 +392,7 @@
String userResults =
LDAPSearchParams(superUser, PWD, null, "dn: " + user1, memberAttrList,
base, filter, "aclRights");
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkAttributeLevel(attrMap, "member", selfWriteAttrRights);
}
@@ -401,13 +402,11 @@
String reqRightsStr) throws Exception {
String attrType=attributeLevel.toLowerCase() + attr;
String retRightsStr=attrMap.get(attrType);
- Assert.assertTrue(retRightsStr.equals(reqRightsStr));
+ assertEquals(retRightsStr, reqRightsStr);
}
- private void
- checkEntryLevel(Map<String, String> attrMap, String reqRightsStr)
- throws Exception {
+ private void checkEntryLevel(Map<String, String> attrMap, String reqRightsStr) throws Exception {
String retRightsStr=attrMap.get(entryLevel.toLowerCase());
- Assert.assertTrue(retRightsStr.equals(reqRightsStr));
+ assertEquals(retRightsStr, reqRightsStr);
}
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/NestedGroupDNTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/NestedGroupDNTestCase.java
index 9b46152..f57e6f1 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/NestedGroupDNTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/NestedGroupDNTestCase.java
@@ -24,19 +24,20 @@
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2015 ForgeRock AS
*/
-
-
package org.opends.server.authorization.dseecompat;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.testng.Assert;
+
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.config.ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI;
/**
* Test the groupdn keyword using nested groups.
*/
+@SuppressWarnings("javadoc")
public class NestedGroupDNTestCase extends AciTestCase {
private static final String peopleBase="ou=People,o=test";
@@ -82,7 +83,7 @@
LDAPSearchParams(user5, PWD, null, null, null,
user5, filter, null);
//Access to user5 should be denied, user5 is not in any groups.
- Assert.assertTrue(userResults.equals(""));
+ Assert.assertEquals(userResults, "");
//Add user5 to group1.
String member5Ldif=makeAddLDIF("member", group3DN, user5);
LDIFModify(member5Ldif, DIR_MGR_DN, PWD);
@@ -96,7 +97,7 @@
LDAPSearchParams(user5, PWD, null, null, null,
user5, filter, null);
//Results should be returned since user5 now has access.
- Assert.assertFalse(userResults1.equals(""));
+ assertNotEquals(userResults1, "");
}
@@ -113,7 +114,7 @@
String userResults =
LDAPSearchParams(user5, PWD, null, null, null,
user5, filter, null);
- Assert.assertTrue(userResults.equals(""));
+ Assert.assertEquals(userResults, "");
//Add group4 (dynamic) to group3.
String group3Ldif=makeAddLDIF("member", group3DN, group4DN);
LDIFModify(group3Ldif, DIR_MGR_DN, PWD);
@@ -124,9 +125,8 @@
String userResults1 =
LDAPSearchParams(user5, PWD, null, null, null,
user5, filter, null);
- //Results should be returned, since user5 now has access because of
- //nested group4.
- Assert.assertFalse(userResults1.equals(""));
+ //Results should be returned, since user5 now has access because of nested group4.
+ assertNotEquals(userResults1, "");
}
@@ -143,7 +143,7 @@
String userResults =
LDAPSearchParams(user5, PWD, null, null, null,
user5, filter, null);
- Assert.assertTrue(userResults.equals(""));
+ Assert.assertEquals(userResults, "");
//Nest group1 in group3, creating circular nesting.
String group3Ldif=makeAddLDIF("member", group3DN, group1DN);
LDIFModify(group3Ldif, DIR_MGR_DN, PWD);
@@ -155,7 +155,6 @@
LDAPSearchParams(user5, PWD, null, null, null,
user5, filter, null);
//Results should not be returned because of circular condition.
- Assert.assertTrue(userResults1.equals(""));
+ Assert.assertEquals(userResults1, "");
}
-
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
index 788e515..891c0a9 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
@@ -26,13 +26,14 @@
*/
package org.opends.server.authorization.dseecompat;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.testng.Assert.*;
import java.util.Map;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
-import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -139,7 +140,7 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, attrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
checkAttributeVal(attrMap, "l", "Austin");
checkAttributeVal(attrMap, "sn", "1");
@@ -147,7 +148,7 @@
String userResults1 =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, attrList1);
- Assert.assertFalse("".equals(userResults1));
+ assertNotEquals(userResults1, "");
Map<String, String> attrMap1 = getAttrMap(userResults1);
checkAttributeVal(attrMap1, "sn", "1");
checkAttributeVal(attrMap1, "uid", "user.1");
@@ -157,7 +158,7 @@
String userResults2 =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, attrList);
- Assert.assertFalse("".equals(userResults2));
+ assertNotEquals(userResults2, "");
Map<String, String> attrMap2 = getAttrMap(userResults2);
checkAttributeVal(attrMap2, "l", "Austin");
checkAttributeVal(attrMap2, "sn", "1");
@@ -178,13 +179,13 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, opAttrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
//The aci attribute type is operational, it should not be there.
//The other two should be there.
- Assert.assertFalse(attrMap.containsKey("aci"));
- Assert.assertTrue(attrMap.containsKey("sn"));
- Assert.assertTrue(attrMap.containsKey("uid"));
+ assertFalse(attrMap.containsKey("aci"));
+ assertTrue(attrMap.containsKey("sn"));
+ assertTrue(attrMap.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
//Add aci that allows both non-operational attributes and the operational
//attribute "aci" search/read.
@@ -193,12 +194,12 @@
String userResults1 =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, opAttrList);
- Assert.assertFalse("".equals(userResults1));
+ assertNotEquals(userResults1, "");
Map<String, String> attrMap1 = getAttrMap(userResults1);
//All three attributes should be there.
- Assert.assertTrue(attrMap1.containsKey("aci"));
- Assert.assertTrue(attrMap1.containsKey("sn"));
- Assert.assertTrue(attrMap1.containsKey("uid"));
+ assertTrue(attrMap1.containsKey("aci"));
+ assertTrue(attrMap1.containsKey("sn"));
+ assertTrue(attrMap1.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
//Add ACI that only allows only aci operational attribute search/read.
String aciLdif2=makeAddLDIF("aci", user1, opAttrAci);
@@ -206,12 +207,12 @@
String userResults2 =
LDAPSearchParams(user3, PWD, null, null, null,
user1, aciFilter, opAttrList);
- Assert.assertFalse("".equals(userResults2));
+ assertNotEquals(userResults2, "");
Map<String, String> attrMap2 = getAttrMap(userResults2);
// Only operational attribute aci should be there, the other two should not.
- Assert.assertTrue(attrMap2.containsKey("aci"));
- Assert.assertFalse(attrMap2.containsKey("sn"));
- Assert.assertFalse(attrMap2.containsKey("uid"));
+ assertTrue(attrMap2.containsKey("aci"));
+ assertFalse(attrMap2.containsKey("sn"));
+ assertFalse(attrMap2.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
}
@@ -229,12 +230,12 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, opAttrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
//All should be returned.
- Assert.assertTrue(attrMap.containsKey("aci"));
- Assert.assertTrue(attrMap.containsKey("sn"));
- Assert.assertTrue(attrMap.containsKey("uid"));
+ assertTrue(attrMap.containsKey("aci"));
+ assertTrue(attrMap.containsKey("sn"));
+ assertTrue(attrMap.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
}
@@ -253,12 +254,12 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, opAttrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
//Only aci should be returned.
- Assert.assertTrue(attrMap.containsKey("aci"));
- Assert.assertFalse(attrMap.containsKey("sn"));
- Assert.assertFalse(attrMap.containsKey("uid"));
+ assertTrue(attrMap.containsKey("aci"));
+ assertFalse(attrMap.containsKey("sn"));
+ assertFalse(attrMap.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
}
@@ -277,12 +278,12 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, opAttrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
//All should be returned.
- Assert.assertTrue(attrMap.containsKey("aci"));
- Assert.assertTrue(attrMap.containsKey("sn"));
- Assert.assertTrue(attrMap.containsKey("uid"));
+ assertTrue(attrMap.containsKey("aci"));
+ assertTrue(attrMap.containsKey("sn"));
+ assertTrue(attrMap.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
}
@@ -302,12 +303,12 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, aciFilter, opAttrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
//All should be returned.
- Assert.assertTrue(attrMap.containsKey("aci"));
- Assert.assertTrue(attrMap.containsKey("sn"));
- Assert.assertTrue(attrMap.containsKey("uid"));
+ assertTrue(attrMap.containsKey("aci"));
+ assertTrue(attrMap.containsKey("sn"));
+ assertTrue(attrMap.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
//Add two ACIs, one with '+' and the other with '*'.
String aciLdif1=makeAddLDIF("aci", user1, allOpAttrAci1, userAttrAci);
@@ -315,12 +316,12 @@
String userResults1 =
LDAPSearchParams(user3, PWD, null, null, null,
user1, aciFilter, opAttrList);
- Assert.assertFalse("".equals(userResults1));
+ assertNotEquals(userResults1, "");
Map<String, String> attrMap1 = getAttrMap(userResults1);
//All should be returned.
- Assert.assertTrue(attrMap1.containsKey("aci"));
- Assert.assertTrue(attrMap1.containsKey("sn"));
- Assert.assertTrue(attrMap1.containsKey("uid"));
+ assertTrue(attrMap1.containsKey("aci"));
+ assertTrue(attrMap1.containsKey("sn"));
+ assertTrue(attrMap1.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
//Add two ACIs, one with '+' and the other with '*'.
String aciLdif2=makeAddLDIF("aci", user1, notAllOpAttrAci1, userAttrAci);
@@ -328,12 +329,12 @@
String userResults2 =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, opAttrList);
- Assert.assertFalse("".equals(userResults2));
+ assertNotEquals(userResults2, "");
Map<String, String> attrMap2 = getAttrMap(userResults2);
//Only non-operation should be returned.
- Assert.assertFalse(attrMap2.containsKey("aci"));
- Assert.assertTrue(attrMap2.containsKey("sn"));
- Assert.assertTrue(attrMap2.containsKey("uid"));
+ assertFalse(attrMap2.containsKey("aci"));
+ assertTrue(attrMap2.containsKey("sn"));
+ assertTrue(attrMap2.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
}
@@ -349,11 +350,11 @@
String userResults =
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, attrList);
- Assert.assertFalse("".equals(userResults));
+ assertNotEquals(userResults, "");
Map<String, String> attrMap = getAttrMap(userResults);
- Assert.assertTrue(attrMap.containsKey("l"));
- Assert.assertTrue(attrMap.containsKey("sn"));
- Assert.assertTrue(attrMap.containsKey("uid"));
+ assertTrue(attrMap.containsKey("l"));
+ assertTrue(attrMap.containsKey("sn"));
+ assertTrue(attrMap.containsKey("uid"));
deleteAttrFromEntry(user1, "aci");
String aciLdif1=makeAddLDIF("aci", user1, grp1AttrAci);
LDIFModify(aciLdif1, DIR_MGR_DN, PWD);
@@ -361,14 +362,14 @@
LDAPSearchParams(user3, PWD, null, null, null,
user1, filter, attrList);
//This search should return nothing since the URL has a bogus DN.
- Assert.assertTrue("".equals(userResults1));
+ assertEquals("", userResults1);
}
private void
checkAttributeVal(Map<String, String> attrMap, String attr,
String val) throws Exception {
String mapVal=attrMap.get(attr);
- Assert.assertTrue(mapVal.equals(val));
+ assertEquals(mapVal, val);
}
/** New tests to really unit test the isApplicable method. */
@@ -415,7 +416,6 @@
if (attrType == null) {
attrType = DirectoryServer.getDefaultAttributeType(attribute);
}
- boolean res = TargetAttr.isApplicable(attrType, targetAttr);
- Assert.assertEquals(res, expectedResult);
+ assertEquals(TargetAttr.isApplicable(attrType, targetAttr), expectedResult);
}
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetTestCase.java
index 49135b4..3f5a4ae 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetTestCase.java
@@ -31,13 +31,13 @@
import org.opends.server.types.DirectoryException;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.server.config.ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import static org.testng.Assert.*;
+
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
-import org.testng.Assert;
+@SuppressWarnings("javadoc")
public class TargetTestCase extends AciTestCase
{
private static final String testUser="uid=user.3,ou=People,o=test";
@@ -444,8 +444,7 @@
boolean match = AciTargets.isTargetApplicable(aci,
aci.getTargets(),
DN.valueOf(entryDN));
- assertTrue(!match, aciString + " in entry " + aciDN +
- " incorrectly applied to " + entryDN);
+ assertFalse(match, aciString + " in entry " + aciDN + " incorrectly applied to " + entryDN);
}
/**
@@ -463,7 +462,7 @@
String userResults =
LDAPSearchParams(testUser, PWD, null,null, null,
testUser, filter, null);
- Assert.assertTrue(userResults.equals(""));
+ assertEquals(userResults, "");
}
finally
{
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java
index d9485b3..678a6da 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java
@@ -26,6 +26,7 @@
*/
package org.opends.server.backends;
+import static org.opends.server.TestCaseUtils.*;
import static org.testng.Assert.*;
import java.util.ArrayList;
@@ -89,7 +90,7 @@
{
DN[] baseDNs = b.getBaseDNs();
assertNotNull(baseDNs);
- assertFalse(baseDNs.length == 0);
+ assertNotEquals(baseDNs.length, 0);
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
index 1c7c8d4..ea57ab4 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -26,6 +26,7 @@
*/
package org.opends.server.backends;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.StaticUtils.*;
@@ -446,16 +447,7 @@
"add: objectClass",
"objectClass: extensibleObject");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -479,16 +471,7 @@
"add: objectClass",
"objectClass: extensibleObject");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -508,16 +491,7 @@
"changetype: modify",
"delete: attributeTypes");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -537,16 +511,7 @@
"changetype: modify",
"replace: attributeTypes");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -573,16 +538,7 @@
String attrName = "testaddattributetypesuccessful";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -611,16 +567,7 @@
String attrName = "testaddattributetypesuccessfulnooid";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -649,16 +596,7 @@
String attrName = "testaddattributetypenospacebeforeparenthesis";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -691,16 +629,7 @@
"98-schema-test-attrtype.ldif");
assertFalse(schemaFile.exists());
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
assertTrue(schemaFile.exists());
}
@@ -747,7 +676,7 @@
"-f", path
};
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(args), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -798,7 +727,7 @@
"-f", path
};
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(args), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
assertTrue(schemaFile.exists());
}
@@ -821,16 +750,7 @@
"add: attributeTypes",
"attributeTypes: invalidsyntax");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -854,16 +774,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.99999 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -887,16 +798,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -920,16 +822,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -953,16 +846,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -986,16 +870,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-APPROX 'xxxundefinedxxx' X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -1019,16 +894,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"USAGE xxxinvalidxxx X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -1057,16 +923,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -1096,16 +953,7 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
+ assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
@@ -1129,16 +977,7 @@
"1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
"'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1162,16 +1001,7 @@
"1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
"'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1208,16 +1038,7 @@
String attrName = "testremoveattributetypesuccessful";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -1259,16 +1080,7 @@
String attrName = "testremoveattributetypesuccessful";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -1296,16 +1108,7 @@
String attrName = "testremoveattributetypeundefined";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1333,16 +1136,7 @@
String attrName = "name";
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -1370,16 +1164,7 @@
String attrName = "uid";
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -1427,16 +1212,7 @@
String attrName = "testremoveattributetypereferencedbynf";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -1483,16 +1259,7 @@
String attrName = "testremoveattributetypereferencedbydcr";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
@@ -1537,16 +1304,7 @@
String attrName = "testremoveatrefbymruat";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -1580,16 +1338,7 @@
String ocName = "testaddobjectclasssuccessful";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -1618,16 +1367,7 @@
String ocName = "testaddobjectclasssuccessfulnooid";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -1659,16 +1399,7 @@
"98-schema-test-oc.ldif");
assertFalse(schemaFile.exists());
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
assertTrue(schemaFile.exists());
}
@@ -1713,7 +1444,7 @@
"-f", path
};
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(args), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -1741,16 +1472,7 @@
String ocName = "testaddobjectclassmultipleconflicts";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -1791,16 +1513,7 @@
String ocName = "testremovethenaddobjectclasssuccessful";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -1822,16 +1535,7 @@
"add: objectClasses",
"objectClasses: invalidsyntax");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1854,16 +1558,7 @@
"'testAddOCUndefinedSuperior' SUP undefined STRUCTURAL " +
"MUST cn X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1890,16 +1585,7 @@
"SUP testAddOCObsoleteSuperiorSup STRUCTURAL MUST cn " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1929,16 +1615,7 @@
"STRUCTURAL MUST testAddOCObsoleteRequiredAttrAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -1968,16 +1645,7 @@
"STRUCTURAL MAY testAddOCObsoleteOptionalAttrAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2000,16 +1668,7 @@
"'testAddOCUndefinedRequired' SUP top STRUCTURAL " +
"MUST undefined X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2034,16 +1693,7 @@
"MUST ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2066,16 +1716,7 @@
"'testAddOCUndefinedOptional' SUP top STRUCTURAL " +
"MAY undefined X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2100,16 +1741,7 @@
"MAY ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2132,16 +1764,7 @@
"'testAddAbstractOCWithNonAbstractSuperior' SUP person " +
"ABSTRACT MAY description X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2164,16 +1787,7 @@
"'testAddAuxiliaryOCWithStructuralSuperior' SUP person " +
"AUXILIARY MAY description X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2196,16 +1810,7 @@
"'testAddStructuralOCWithAuxiliarySuperior' SUP posixAccount " +
"STRUCTURAL MAY description X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2238,16 +1843,7 @@
String ocName = "testremoveobjectclasssuccessful";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -2274,16 +1870,7 @@
String ocName = "person";
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -2333,7 +1920,7 @@
"-f", path
};
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(args), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
@@ -2372,21 +1959,21 @@
String ocName = "testremoveobjectclassreferencedbydcr";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
+ assertNotEquals(runModify(standardArgs(path)), 0);
+ assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
+ }
+
+ private String[] standardArgs(String path)
+ {
+ return new String[] {
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
"-w", "password",
"-f", path
};
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
- assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that doesn't already exist.
@@ -2414,16 +2001,7 @@
String nameFormName = "testaddnameformsuccessful";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2461,16 +2039,7 @@
"98-schema-test-nameform.ldif");
assertFalse(schemaFile.exists());
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
assertTrue(schemaFile.exists());
}
@@ -2505,16 +2074,7 @@
String nameFormName = "testaddnameformwithundefinedreqat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2549,16 +2109,7 @@
String nameFormName = "testaddnameformwithmultipleundefinedreqat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2592,16 +2143,7 @@
String nameFormName = "testaddnameformwithundefinedoptat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2636,16 +2178,7 @@
String nameFormName = "testaddnameformwithmultipleundefinedoptat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2672,16 +2205,7 @@
String nameFormName = "testaddnameformwithundefinedoc";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2714,16 +2238,7 @@
String nameFormName = "testaddnameformwithauxiliaryoc";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2756,16 +2271,7 @@
String nameFormName = "testaddnameformwithobsoleteoc";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2801,16 +2307,7 @@
"MUST testAddNFWithObsoleteReqATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2845,16 +2342,7 @@
"MUST cn MAY testAddNFWithObsoleteOptATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -2895,16 +2383,7 @@
String nameFormName = "testaddnameformocconflict2";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertTrue(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -2945,16 +2424,7 @@
String nameFormName = "testremovenameformsuccessful";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -3001,16 +2471,7 @@
String nameFormName = "testremovethenaddnameformsuccessful";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -3054,19 +2515,10 @@
"OC testRemoveNameFormReferencedByDSROC MUST cn " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
String nameFormName = "testremovenameformreferencedbydsrnf";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
@@ -3095,19 +2547,10 @@
"NAME 'testAddDITContentRuleSuccessful' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
String ocName = "testaddditcontentrulesuccessfuloc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -3162,7 +2605,7 @@
String ocName = "testreplaceditcontentrulesuccessfuloc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(args), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -3199,15 +2642,6 @@
"X-SCHEMA-FILE '98-schema-test-dcr.ldif' " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
String ocName = "testadddcrtoaltschemafileoc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
@@ -3215,7 +2649,7 @@
"98-schema-test-dcr.ldif");
assertFalse(schemaFile.exists());
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -3264,19 +2698,10 @@
"NAME 'testRemoveThenAddDITContentRule' MAY sn " +
"NOT description X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
String ocName = "testremovethenaddditcontentruleoc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -3306,16 +2731,7 @@
"NAME 'testAddDITContentRuleUndefinedOC' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3343,16 +2759,7 @@
"NAME 'testAddDITContentRuleAuxiliaryOC' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3380,16 +2787,7 @@
"NAME 'testAddDITContentRuleObsoleteOC' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3425,16 +2823,7 @@
"NAME 'testAddDITContentRuleConflictingOC2' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3462,16 +2851,7 @@
"NAME 'testAddDITContentRuleUndefinedAuxOC' " +
"AUX xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3501,16 +2881,7 @@
"AUX ( posixAccount $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3538,16 +2909,7 @@
"NAME 'testAddDITContentRuleAuxOCNotAuxOC' " +
"AUX person X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3577,16 +2939,7 @@
"AUX ( posixAccount $ person ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3618,16 +2971,7 @@
"AUX testAddDITContentRuleObsoleteAuxOCAuxiliary " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3655,16 +2999,7 @@
"NAME 'testAddDITContentRuleUndefinedReqAT' " +
"MUST xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3694,16 +3029,7 @@
"MUST ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3731,16 +3057,7 @@
"NAME 'testAddDITContentRuleUndefinedOptAT' " +
"MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3770,16 +3087,7 @@
"MAY ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3807,16 +3115,7 @@
"NAME 'testAddDITContentRuleUndefinedNotAT' " +
"NOT xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3846,16 +3145,7 @@
"NOT ( description $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3884,16 +3174,7 @@
"NAME 'testAddDCRProhibitReqStructuralAT' " +
"NOT cn X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3922,16 +3203,7 @@
"NAME 'testAddDCRProhibitReqAuxiliaryAT' AUX posixAccount " +
"NOT uid X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -3965,16 +3237,7 @@
"MUST testAddDCRObsoleteReqATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -4008,16 +3271,7 @@
"MAY testAddDCRObsoleteOptATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -4051,16 +3305,7 @@
"NOT testAddDCRObsoleteNotATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -4095,19 +3340,10 @@
"NAME 'testRemoveDITContentRuleSuccessful' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
String ocName = "testremoveditcontentrulesuccessfuloc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -4148,19 +3384,10 @@
"FORM testAddDITStructureRuleSuccessfulNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999001;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4218,7 +3445,7 @@
int ruleID = 999002;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(args), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4257,15 +3484,6 @@
"X-SCHEMA-FILE '98-schema-test-dsr.ldif' " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999010;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
@@ -4273,7 +3491,7 @@
"98-schema-test-dsr.ldif");
assertFalse(schemaFile.exists());
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
assertTrue(schemaFile.exists());
@@ -4327,19 +3545,10 @@
"FORM testRemoveAndAddDITStructureRuleSuccessfulNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999003;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4364,19 +3573,10 @@
"FORM xxxundefinedxxx " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999004;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4412,19 +3612,10 @@
"FORM testAddDSRUndefinedSuperiorNF SUP 999000 " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999005;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4460,16 +3651,7 @@
"FORM testAddDITStructureRuleObsoleteNameFormNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -4515,16 +3697,7 @@
"FORM testAddDITStructureRuleObsoleteSuperiorNF2 SUP 999012 " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -4567,19 +3740,10 @@
"FORM testRemoveDITStructureRuleSuccessfulNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999006;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4635,19 +3799,10 @@
"FORM testRemoveSuperiorDITStructureRuleNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
int ruleID = 999007;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
@@ -4664,16 +3819,7 @@
"FORM testRemoveSuperiorDITStructureRuleNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- args = new String[]
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -4713,16 +3859,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4757,20 +3894,11 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
"98-schema-test-mru.ldif");
assertFalse(schemaFile.exists());
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4822,7 +3950,7 @@
"-f", path
};
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(args), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4868,16 +3996,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4916,16 +4035,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4953,16 +4063,7 @@
"NAME 'testAddMRUMRUndefined' APPLIES cn " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
/**
@@ -4990,16 +4091,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -5029,16 +4121,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
/**
@@ -5064,16 +4147,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ assertNotEquals(runModify(standardArgs(path)), 0);
}
@@ -5106,16 +4180,12 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
+ assertNotEquals(runModify(standardArgs(path)), 0);
+ }
- assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
+ private int runModify(String[] args)
+ {
+ return LDAPModify.mainModify(args, false, null, null);
}
/**
@@ -5148,16 +4218,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -5197,16 +4258,7 @@
String attrName = "testattributetypesmatchingrule";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
}
@@ -5242,16 +4294,7 @@
String objectClassName = "testobjectclassesmatchingrule";
assertFalse(DirectoryServer.getSchema().hasObjectClass(objectClassName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
}
@@ -5295,16 +4338,7 @@
String nameFormName = "testnameformsmatchingrule";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
}
@@ -5348,16 +4382,7 @@
String objectClassName = "testditcontentrulesmatchingruleoc";
assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
}
@@ -5425,16 +4450,7 @@
String objectClassName = "testditcontentrulesmatchingruleoc1";
assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
}
@@ -5486,16 +4502,7 @@
String attrName = "testmatchingruleusematchingruleat1";
assertNull(DirectoryServer.getSchema().getAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
}
@@ -5545,16 +4552,7 @@
"objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " +
"MUST testIssue1381AT )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
}
/**
@@ -5562,10 +4560,9 @@
* are added without a space before closing parenthesis.
*/
@Test
- public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception
+ public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception
{
-
- String path = TestCaseUtils.createTempFile(
+ String path = TestCaseUtils.createTempFile(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -5586,26 +4583,8 @@
" caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch " +
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 X-ORIGIN 'RFC 4519')");
-
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
-
- }
-
-
-
-
-
-
-
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ }
/**
* Tests to ensure that the schema subentry includes the lastmod attributes
@@ -5647,19 +4626,10 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
-
// Sleep longer than the TimeThread delay to ensure the modifytimestamp
// will be different.
Thread.sleep(6000);
- assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+ assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
schemaEntry = DirectoryServer.getEntry(DN.valueOf("cn=schema"));
assertNotNull(schemaEntry);
@@ -5670,10 +4640,13 @@
ByteString newMTValue =
schemaEntry.getAttribute(mtType).get(0).iterator().next();
- assertFalse(oldMTValue.equals(newMTValue));
+ assertNotEquals(oldMTValue, newMTValue);
}
-
+ private int runModifyWithSystemErr(String[] args)
+ {
+ return LDAPModify.mainModify(args, false, null, System.err);
+ }
/**
* Tests the ability to properly handle adding and removing a schema
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestJebFormat.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestJebFormat.java
index 7f704b1..4d9243e 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestJebFormat.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestJebFormat.java
@@ -471,8 +471,7 @@
List<Attribute> listBefore = entryBefore.getAttribute(attrType);
List<Attribute> listAfter = entryAfter.getAttribute(attrType);
- assertTrue(listAfter != null);
-
+ assertNotNull(listAfter);
assertEquals(listBefore.size(), listAfter.size());
for (Attribute attrBefore : listBefore) {
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestJebFormat.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestJebFormat.java
index e061b67..d417d79 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestJebFormat.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestJebFormat.java
@@ -396,8 +396,7 @@
List<Attribute> listBefore = entryBefore.getAttribute(attrType);
List<Attribute> listAfter = entryAfter.getAttribute(attrType);
- assertTrue(listAfter != null);
-
+ assertNotNull(listAfter);
assertEquals(listBefore.size(), listAfter.size());
for (Attribute attrBefore : listBefore) {
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
index cfbdfc6..3a2e45d 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
@@ -43,6 +43,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -173,7 +174,7 @@
int resultCode = TestCaseUtils.applyModifications(true,
"dn: " + taskDN,
"changetype: delete");
- assertFalse(resultCode == 0);
+ assertNotEquals(resultCode, 0);
assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
}
@@ -322,7 +323,7 @@
"changetype: modify",
"replace: description",
"description: foo");
- assertFalse(resultCode == 0);
+ assertNotEquals(resultCode, 0);
// Perform a modification to cancel the task.
@@ -383,7 +384,7 @@
"changetype: modify",
"add: description",
"description: foo");
- assertFalse(resultCode == 0);
+ assertNotEquals(resultCode, 0);
// Perform a modification to delete that task.
@@ -500,7 +501,7 @@
// Make sure recurring task iteration got scheduled.
long tasksCountAfter = taskBackend.numSubordinates(DN.valueOf(
"cn=Scheduled Tasks,cn=tasks"), true);
- assertTrue(tasksCountAfter == (tasksCountBefore + 1));
+ assertEquals(tasksCountAfter, tasksCountBefore + 1);
// Perform a modification to update a non-state attribute.
int resultCode =
@@ -508,7 +509,7 @@
"changetype: modify",
"replace: ds-recurring-task-schedule",
"ds-recurring-task-schedule: * * * * *");
- assertFalse(resultCode == 0);
+ assertNotEquals(resultCode, 0);
// Delete recurring task.
resultCode =
@@ -520,7 +521,7 @@
// Make sure recurring task iteration got canceled and removed.
tasksCountAfter = taskBackend.numSubordinates(DN.valueOf(
"cn=Scheduled Tasks,cn=tasks"), true);
- assertTrue(tasksCountAfter == tasksCountBefore);
+ assertEquals(tasksCountAfter, tasksCountBefore);
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordControlTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordControlTest.java
index e0dd983..03e89fb 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordControlTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordControlTest.java
@@ -27,25 +27,25 @@
package org.opends.server.controls;
import static org.opends.server.util.ServerConstants.*;
+import static org.testng.Assert.*;
import java.util.HashMap;
import java.util.Set;
-import org.opends.server.types.*;
+import org.forgerock.opendj.io.ASN1;
+import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.protocols.ldap.LDAPReader;
-import org.forgerock.opendj.io.ASN1;
-import org.forgerock.opendj.io.ASN1Writer;
+import org.opends.server.types.DirectoryException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
/**
* Test password control.
*/
+@SuppressWarnings("javadoc")
public class PasswordControlTest
extends ControlsTestCase
{
@@ -56,7 +56,6 @@
@DataProvider(name = "passwordPolicyErrorTypeData")
public Object[][] createPasswordPolicyErrorTypeData()
{
-
HashMap<Integer, String> values = new HashMap<Integer, String>();
values.put(0, "passwordExpired");
values.put(1, "accountLocked");
@@ -67,9 +66,7 @@
values.put(6, "passwordTooShort");
values.put(7, "passwordTooYoung");
values.put(8, "passwordInHistory");
- return new Object[][]
- {
- { values } };
+ return new Object[][] { { values } };
}
/**
@@ -129,13 +126,10 @@
@DataProvider(name = "passwordPolicyWarningTypeData")
public Object[][] createPasswordPolicyWarningTypeData()
{
-
HashMap<Byte, String> values = new HashMap<Byte, String>();
values.put((byte)0x80, "timeBeforeExpiration");
values.put((byte)0x81, "graceAuthNsRemaining");
- return new Object[][]
- {
- { values } };
+ return new Object[][] { { values } };
}
/**
@@ -166,7 +160,7 @@
// Retrieve the values
PasswordPolicyWarningType[] vals = PasswordPolicyWarningType.values();
- // Check if we have the correct munber
+ // Check if we have the correct number
assertEquals(vals.length, exceptedValues.size());
// Check if we have the correct byte value
@@ -187,17 +181,12 @@
for (int i = 0x70; i < 0x90; i++)
{
byte b = new Integer(i).byteValue();
- if (keys.contains(b))
- {
- continue;
- }
- else
+ if (!keys.contains(b))
{
assertNull(PasswordPolicyWarningType.valueOf(b));
PasswordPolicyWarningType val = PasswordPolicyWarningType.valueOf(b);
assertNull(val);
}
-
}
}
@@ -207,7 +196,6 @@
@DataProvider(name = "passwordExpiredControlData")
public Object[][] createPasswordExpiredControlData()
{
-
return new Object[][] {
{ true },
{ false },
@@ -256,14 +244,10 @@
try
{
pec = PasswordExpiredControl.DECODER.decode(control.isCritical(), control.getValue());
- assertTrue(false,
- "should be allow to create a passwordExpiredControl with value");
+ fail("should be allow to create a passwordExpiredControl with value");
}
- catch (DirectoryException e)
+ catch (DirectoryException expected)
{
- // Normal case
- assertTrue(true,
- "should be allow to create a passwordExpiredControl with value");
}
// Check toString
@@ -288,7 +272,6 @@
@DataProvider(name = "passwordExpiringControlData")
public Object[][] createPasswordExpiringControlData()
{
-
return new Object[][] {
{ true, 1},
{ false, 2},
@@ -322,14 +305,10 @@
try
{
pec = PasswordExpiringControl.DECODER.decode(control.isCritical(), control.getValue());
- assertTrue(false,
- "shouldn't be allow to create PasswordExpiringControl without value");
+ fail("shouldn't be allowed to create PasswordExpiringControl without value");
}
- catch (DirectoryException e)
+ catch (DirectoryException expected)
{
- // Normal case
- assertTrue(true,
- "shouldn't be allow to create PasswordExpiringControl without value");
}
control = new LDAPControl(OID_NS_PASSWORD_EXPIRING, isCritical,
@@ -337,14 +316,10 @@
try
{
pec = PasswordExpiringControl.DECODER.decode(control.isCritical(), control.getValue());
- assertTrue(false,
- "shouldn't be allow to create PasswordExpiringControl with a wrong value");
+ fail("shouldn't be allowed to create PasswordExpiringControl with a wrong value");
}
- catch (DirectoryException e)
+ catch (DirectoryException expected)
{
- // Normal case
- assertTrue(true,
- "shouldn't be allow to create PasswordExpiringControl with a wrong value");
}
// Check encode/decode
@@ -366,7 +341,6 @@
@DataProvider(name = "passwordPolicyRequestControlData")
public Object[][] createPasswordPolicyRequestControlData()
{
-
return new Object[][] {
{ true},
{ false},
@@ -409,14 +383,10 @@
try
{
pec = PasswordPolicyRequestControl.DECODER.decode(control.isCritical(), control.getValue());
- assertTrue(false,
- "should be allow to create a PasswordPolicyRequestControl with value");
+ fail("should be allow to create a PasswordPolicyRequestControl with value");
}
- catch (DirectoryException e)
+ catch (DirectoryException expected)
{
- // Normal case
- assertTrue(true,
- "should be allow to create a PasswordPolicyRequestControl with value");
}
// Check toString
@@ -430,7 +400,6 @@
@DataProvider(name = "passwordPolicyResponseControl")
public Object[][] createPasswordPolicyResponseControlData()
{
-
return new Object[][] {
{ true , -1},
{ false , -1},
@@ -443,8 +412,7 @@
* Test PasswordPolicyResponseControl.
*/
@Test(dataProvider = "passwordPolicyResponseControl")
- public void passwordPolicyResponseControlTest(
- boolean isCritical, int warningValue)
+ public void passwordPolicyResponseControlTest(boolean isCritical, int warningValue)
throws Exception
{
// Check default constructor
@@ -480,8 +448,7 @@
// PasswordPolicyErrorType errorType)
for (PasswordPolicyErrorType errorType : PasswordPolicyErrorType.values())
{
- for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType
- .values())
+ for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType.values())
{
pprc = new PasswordPolicyResponseControl(isCritical,
warningType, warningValue, errorType);
@@ -495,17 +462,15 @@
// check encode/decode
- PasswordPolicyResponseControl control ;
ByteStringBuilder bsb = new ByteStringBuilder();
ASN1Writer writer = ASN1.getWriter(bsb);
for (PasswordPolicyErrorType errorType : PasswordPolicyErrorType.values())
{
- for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType
- .values())
+ for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType.values())
{
bsb.clear();
- control = new PasswordPolicyResponseControl(isCritical,
- warningType, warningValue, errorType);
+ PasswordPolicyResponseControl control = new PasswordPolicyResponseControl(
+ isCritical, warningType, warningValue, errorType);
control.write(writer);
LDAPControl c = LDAPReader.readControl(ASN1.getReader(bsb));
pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue());
@@ -526,12 +491,10 @@
{
c = new LDAPControl(OID_PASSWORD_POLICY_CONTROL, isCritical);
pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue());
- assertTrue(false,"the control should have a value");
+ fail("the control should have a value");
}
- catch (DirectoryException e)
+ catch (DirectoryException expected)
{
- // normal case
- assertTrue(true,"the control should have a value");
}
@@ -541,15 +504,8 @@
null, warningValue, errorType);
control.write(writer);
c = LDAPReader.readControl(ASN1.getReader(bsb));
- try
- {
- pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue());
- assertNull(pprc.getWarningType());
- }
- catch (DirectoryException e)
- {
- assertTrue(false,"We should be able to decode the control");
- }
+ pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue());
+ assertNull(pprc.getWarningType());
// check null error type
bsb.clear();
@@ -557,15 +513,8 @@
warningType, warningValue, null);
control.write(writer);
c = LDAPReader.readControl(ASN1.getReader(bsb));
- try
- {
- pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue());
- assertNull(pprc.getErrorType());
- }
- catch (DirectoryException e)
- {
- assertTrue(false,"We should be able to decode the control");
- }
+ pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue());
+ assertNull(pprc.getErrorType());
}
}
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordPolicyControlTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordPolicyControlTestCase.java
index 211b30a..af21264 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordPolicyControlTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PasswordPolicyControlTestCase.java
@@ -32,12 +32,13 @@
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.protocols.ldap.*;
import org.opends.server.types.Control;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
+import org.opends.server.types.DirectoryException;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.RawModification;
import org.opends.server.util.StaticUtils;
@@ -45,6 +46,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -84,10 +86,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -125,27 +124,7 @@
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for (Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
ArrayList<RawAttribute> rawAttrs = new ArrayList<RawAttribute>();
@@ -163,40 +142,17 @@
message = r.readMessage();
AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp();
- assertFalse(addResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- found = false;
- for (Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
@@ -253,33 +209,13 @@
message = r.readMessage();
AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp();
- assertFalse(addResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY));
}
finally
{
@@ -287,6 +223,29 @@
}
}
+ private boolean passwordPolicyControlExists(List<Control> controls, PasswordPolicyErrorType expectedErrorType)
+ throws DirectoryException
+ {
+ boolean found = false;
+ for(Control c : controls)
+ {
+ if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
+ {
+ PasswordPolicyResponseControl pwpControl;
+ if(c instanceof LDAPControl)
+ {
+ pwpControl = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl) c).getValue());
+ }
+ else
+ {
+ pwpControl = (PasswordPolicyResponseControl)c;
+ }
+ assertEquals(pwpControl.getErrorType(), expectedErrorType);
+ found = true;
+ }
+ }
+ return found;
+ }
/**
@@ -301,10 +260,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--add", "password-validator:Length-Based Password Validator");
+ setPasswordPolicyProp("--add", "password-validator:Length-Based Password Validator");
Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort());
org.opends.server.tools.LDAPReader r = new org.opends.server.tools.LDAPReader(s);
@@ -342,40 +298,17 @@
message = r.readMessage();
AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp();
- assertFalse(addResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--remove", "password-validator:Length-Based Password Validator");
+ setPasswordPolicyProp("--remove", "password-validator:Length-Based Password Validator");
StaticUtils.close(s);
}
@@ -396,10 +329,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "lockout-failure-count:3");
+ setPasswordPolicyProp("--set", "lockout-failure-count:3");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -431,7 +361,7 @@
message = r.readMessage();
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
- assertFalse(bindResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
}
bindRequest = new BindRequestProtocolOp(
@@ -446,47 +376,23 @@
message = r.readMessage();
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
- assertFalse(bindResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.ACCOUNT_LOCKED);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.ACCOUNT_LOCKED));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "lockout-failure-count:0");
+ setPasswordPolicyProp("--set", "lockout-failure-count:0");
StaticUtils.close(s);
}
}
-
/**
* Tests that an appropriate password policy response control is returned for
* a compare operation when the user's password is in a "must change" state.
@@ -499,10 +405,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -547,40 +450,17 @@
message = r.readMessage();
CompareResponseProtocolOp compareResponse =
message.getCompareResponseProtocolOp();
- assertFalse(compareResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(compareResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
@@ -600,10 +480,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntries(
"dn: uid=test.user,o=test",
@@ -652,40 +529,17 @@
message = r.readMessage();
DeleteResponseProtocolOp deleteResponse =
message.getDeleteResponseProtocolOp();
- assertFalse(deleteResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(deleteResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
@@ -752,10 +606,7 @@
"userPassword: password",
"ds-privilege-name: bypass-acl");
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -847,10 +698,7 @@
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
@@ -903,10 +751,7 @@
"userPassword: password",
"ds-privilege-name: bypass-acl");
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntry(
"dn: uid=authz.user,o=test",
@@ -964,34 +809,11 @@
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
@@ -1012,10 +834,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "allow-user-password-changes:false");
+ setPasswordPolicyProp("--set", "allow-user-password-changes:false");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -1064,47 +883,22 @@
message = r.readMessage();
ModifyResponseProtocolOp modifyResponse =
message.getModifyResponseProtocolOp();
- assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "allow-user-password-changes:true");
+ setPasswordPolicyProp("--set", "allow-user-password-changes:true");
StaticUtils.close(s);
}
}
-
-
/**
* Tests that an appropriate password policy response control is returned for
* a modify operation when the proposed password is in the user's password
@@ -1118,10 +912,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "password-history-count:5");
+ setPasswordPolicyProp("--set", "password-history-count:5");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -1170,40 +961,17 @@
message = r.readMessage();
ModifyResponseProtocolOp modifyResponse =
message.getModifyResponseProtocolOp();
- assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.PASSWORD_IN_HISTORY);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.PASSWORD_IN_HISTORY));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "password-history-count:0");
+ setPasswordPolicyProp("--set", "password-history-count:0");
StaticUtils.close(s);
}
@@ -1224,10 +992,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "password-change-requires-current-password:true");
+ setPasswordPolicyProp("--set", "password-change-requires-current-password:true");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -1276,40 +1041,17 @@
message = r.readMessage();
ModifyResponseProtocolOp modifyResponse =
message.getModifyResponseProtocolOp();
- assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.MUST_SUPPLY_OLD_PASSWORD);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.MUST_SUPPLY_OLD_PASSWORD));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "password-change-requires-current-password:false");
+ setPasswordPolicyProp("--set", "password-change-requires-current-password:false");
StaticUtils.close(s);
}
@@ -1330,10 +1072,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "min-password-age:24 hours");
+ setPasswordPolicyProp("--set", "min-password-age:24 hours");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -1382,40 +1121,17 @@
message = r.readMessage();
ModifyResponseProtocolOp modifyResponse =
message.getModifyResponseProtocolOp();
- assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.PASSWORD_TOO_YOUNG);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.PASSWORD_TOO_YOUNG));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "min-password-age:0 seconds");
+ setPasswordPolicyProp("--set", "min-password-age:0 seconds");
StaticUtils.close(s);
}
@@ -1435,10 +1151,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntries(
"dn: uid=test.user,o=test",
@@ -1489,47 +1202,22 @@
message = r.readMessage();
ModifyDNResponseProtocolOp modifyDNResponse =
message.getModifyDNResponseProtocolOp();
- assertFalse(modifyDNResponse.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(modifyDNResponse.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
}
-
-
/**
* Tests that an appropriate password policy response control is returned for
* a search operation when the user's password is in a "must change" state.
@@ -1542,10 +1230,7 @@
{
TestCaseUtils.initializeTestBackend(true);
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:true");
+ setPasswordPolicyProp("--set", "force-change-on-add:true");
TestCaseUtils.addEntry(
"dn: uid=test.user,o=test",
@@ -1593,43 +1278,24 @@
message = r.readMessage();
SearchResultDoneProtocolOp searchDone =
message.getSearchResultDoneProtocolOp();
- assertFalse(searchDone.getResultCode() == LDAPResultCode.SUCCESS);
+ assertNotEquals(searchDone.getResultCode(), LDAPResultCode.SUCCESS);
controls = message.getControls();
assertNotNull(controls);
assertFalse(controls.isEmpty());
- boolean found = false;
- for(Control c : controls)
- {
- if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL))
- {
- PasswordPolicyResponseControl pwpControl;
- if(c instanceof LDAPControl)
- {
- pwpControl =
- PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue());
- }
- else
- {
- pwpControl = (PasswordPolicyResponseControl)c;
- }
- assertEquals(pwpControl.getErrorType(),
- PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- found = true;
- }
- }
- assertTrue(found);
+ assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET));
}
finally
{
- TestCaseUtils.dsconfig(
- "set-password-policy-prop",
- "--policy-name", "Default Password Policy",
- "--set", "force-change-on-add:false");
+ setPasswordPolicyProp("--set", "force-change-on-add:false");
StaticUtils.close(s);
}
}
-}
+ private void setPasswordPolicyProp(String arg, String value)
+ {
+ TestCaseUtils.dsconfig("set-password-policy-prop", "--policy-name", "Default Password Policy", arg, value);
+ }
+}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java
index 93f31d9..b5fda50 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/PersistentSearchControlTest.java
@@ -27,6 +27,7 @@
package org.opends.server.controls;
import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.controls.PersistentSearchChangeType.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
@@ -431,9 +432,8 @@
}
catch (DirectoryException e)
{
- assertFalse(type.compareTo(MODIFY_DN) == 0,
- "couldn't decode a control with previousDN "
- + "not null and type=modDN");
+ assertNotEquals(type.compareTo(MODIFY_DN), 0,
+ "couldn't decode a control with previousDN not null and type=modDN");
}
}
@@ -469,9 +469,8 @@
}
catch (DirectoryException e)
{
- assertFalse(type.compareTo(PersistentSearchChangeType.MODIFY_DN) == 0,
- "couldn't decode a control with previousDN "
- + "not null and type=modDN");
+ assertNotEquals(type.compareTo(PersistentSearchChangeType.MODIFY_DN), 0,
+ "couldn't decode a control with previousDN not null and type=modDN");
}
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ProxiedAuthV1ControlTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ProxiedAuthV1ControlTestCase.java
index 1940656..cce398c 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ProxiedAuthV1ControlTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ProxiedAuthV1ControlTestCase.java
@@ -88,7 +88,7 @@
// Try an empty DN, which is acceptable.
proxyControl = new ProxiedAuthV1Control(ByteString.valueOf(""));
- assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1));
+ assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1);
assertTrue(proxyControl.isCritical());
assertTrue(proxyControl.getAuthorizationDN().isRootDN());
@@ -96,7 +96,7 @@
// Try a valid DN, which is acceptable.
proxyControl =
new ProxiedAuthV1Control(ByteString.valueOf("uid=test,o=test"));
- assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1));
+ assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1);
assertTrue(proxyControl.isCritical());
assertEquals(proxyControl.getAuthorizationDN(),
DN.valueOf("uid=test,o=test"));
@@ -105,7 +105,7 @@
// Try an invalid DN, which will be initally accepted but will fail when
// attempting to get the authorization DN.
proxyControl = new ProxiedAuthV1Control(ByteString.valueOf("invalid"));
- assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1));
+ assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1);
assertTrue(proxyControl.isCritical());
try
{
@@ -140,7 +140,7 @@
// Try an empty DN, which is acceptable.
proxyControl = new ProxiedAuthV1Control(DN.rootDN());
- assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1));
+ assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1);
assertTrue(proxyControl.isCritical());
assertTrue(proxyControl.getAuthorizationDN().isRootDN());
@@ -148,7 +148,7 @@
// Try a valid DN, which is acceptable.
proxyControl =
new ProxiedAuthV1Control(DN.valueOf("uid=test,o=test"));
- assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1));
+ assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1);
assertTrue(proxyControl.isCritical());
assertEquals(proxyControl.getAuthorizationDN(),
DN.valueOf("uid=test,o=test"));
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ServerSideSortControlTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ServerSideSortControlTestCase.java
index 2473501..996f073 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ServerSideSortControlTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/controls/ServerSideSortControlTestCase.java
@@ -49,6 +49,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
@@ -514,7 +515,7 @@
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
.addControl(new ServerSideSortRequestControl(true, "givenName:undefinedOrderingMatch"));
InternalSearchOperation internalSearch = getRootConnection().processSearch(request);
- assertFalse(internalSearch.getResultCode() == ResultCode.SUCCESS);
+ assertNotEquals(internalSearch.getResultCode(), ResultCode.SUCCESS);
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/AdditionalLogItemTest.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/AdditionalLogItemTest.java
index d81c3e4..de5a23e 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/AdditionalLogItemTest.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/AdditionalLogItemTest.java
@@ -21,21 +21,14 @@
* CDDL HEADER END
*
*
- * Portions Copyright 2011-2014 ForgeRock AS
+ * Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.types;
-
-
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.*;
import org.testng.annotations.Test;
-
-
/**
* Tests for {@link AdditionalLogItem}.
*/
@@ -51,7 +44,7 @@
AdditionalLogItem item = AdditionalLogItem.keyOnly(getClass(), "testKey");
assertEquals(item.getSource(), getClass());
assertEquals(item.getKey(), "testKey");
- assertEquals(item.getValue(), null);
+ assertNull(item.getValue());
assertEquals(item.toString(), "testKey");
assertEquals(item.toString(new StringBuilder()).toString(), "testKey");
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
index cfd681e..30a980e 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
@@ -82,6 +82,7 @@
import org.testng.annotations.Test;
import static org.forgerock.opendj.ldap.ResultCode.*;
+import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
@@ -241,15 +242,10 @@
// Build the array of connections we will use to perform the tests.
- connections.put(new InternalClientConnection(new AuthenticationInfo()),
- false);
-
+ connections.put(new InternalClientConnection(new AuthenticationInfo()), false);
connections.put(InternalClientConnection.getRootConnection(), true);
-
- connections.put(
- newConn("cn=Directory Manager,cn=Root DNs,cn=config", true), true);
- connections.put(
- newConn("cn=Unprivileged Root,cn=Root DNs,cn=config", true), false);
+ connections.put(newConn("cn=Directory Manager,cn=Root DNs,cn=config", true), true);
+ connections.put(newConn("cn=Unprivileged Root,cn=Root DNs,cn=config", true), false);
connections.put(newConn("cn=Proxy Root,cn=Root DNs,cn=config", true), true);
connections.put(newConn("cn=Unprivileged User,o=test", false), false);
connections.put(newConn("cn=Privileged User,o=test", false), true);
@@ -1465,7 +1461,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1496,7 +1492,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1527,7 +1523,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1558,7 +1554,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1589,7 +1585,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1620,7 +1616,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1651,7 +1647,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -1682,7 +1678,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1713,7 +1709,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -1744,7 +1740,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -1775,7 +1771,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1806,7 +1802,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -1837,7 +1833,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1868,7 +1864,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1899,7 +1895,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1930,7 +1926,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1961,7 +1957,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -1992,7 +1988,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -2023,7 +2019,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -2054,7 +2050,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -2085,7 +2081,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -2116,7 +2112,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -2147,7 +2143,7 @@
"(objectClass=*)"
};
- assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
+ assertEquals(runSearchWithSystemErr(args), 0);
}
@@ -2178,7 +2174,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
+ assertNotEquals(runSearch(args), 0);
}
@@ -2209,7 +2205,7 @@
"(objectClass=*)"
};
- assertFalse(LDAPSearch.mainSearch(searchArgs, false, null, null) == 0);
+ assertNotEquals(runSearch(searchArgs), 0);
// Disable the PROXIED_AUTH privilege and verify that the operation now
@@ -2217,7 +2213,7 @@
TestCaseUtils.dsconfig(
"set-global-configuration-prop",
"--add", "disabled-privilege:proxied-auth");
- assertEquals(LDAPSearch.mainSearch(searchArgs, false, null, null), 0);
+ assertEquals(runSearch(searchArgs), 0);
// Re-enable the PROXIED_AUTH privilege and verify that the operation
@@ -2226,10 +2222,18 @@
"set-global-configuration-prop",
"--remove", "disabled-privilege:proxied-auth");
- assertFalse(LDAPSearch.mainSearch(searchArgs, false, null, null) == 0);
+ assertNotEquals(runSearch(searchArgs), 0);
}
+ private int runSearch(String[] args)
+ {
+ return LDAPSearch.mainSearch(args, false, null, null);
+ }
+ private int runSearchWithSystemErr(String[] args)
+ {
+ return LDAPSearch.mainSearch(args, false, null, System.err);
+ }
/**
* Tests the ability to update the set of privileges for a user on the fly
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
index 254c416..e8e1e68 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -27,6 +27,7 @@
package org.opends.server.types;
import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.TestCaseUtils.*;
import static org.testng.Assert.*;
import java.util.ArrayList;
@@ -417,7 +418,7 @@
public void testNullDN() throws Exception {
DN nullDN = DN.rootDN();
- assertTrue(nullDN.size() == 0);
+ assertEquals(nullDN.size(), 0);
assertEquals(nullDN.toString(), "");
}
@@ -1151,11 +1152,9 @@
DN dn2 = DN.valueOf(second);
if (result == 0) {
- assertTrue(dn1.equals(dn2), "DN equality for <" + first
- + "> and <" + second + ">");
+ assertEquals (dn1, dn2, "DN equality for <" + first + "> and <" + second + ">");
} else {
- assertFalse(dn1.equals(dn2), "DN equality for <" + first
- + "> and <" + second + ">");
+ assertNotEquals(dn1, dn2, "DN equality for <" + first + "> and <" + second + ">");
}
}
@@ -1171,7 +1170,7 @@
public void testEqualsNonDN() throws Exception {
DN dn = DN.valueOf("dc=example,dc=com");
- assertFalse(dn.equals("not a DN"));
+ assertNotEquals(dn, "not a DN");
}
@@ -1198,15 +1197,11 @@
int h2 = dn2.hashCode();
if (result == 0) {
- if (h1 != h2) {
- Assert.fail("Hash codes for <" + first + "> and <" + second
- + "> should be the same.");
- }
+ assertEquals(h1, h2,
+ "Hash codes for <" + first + "> and <" + second + "> should be the same.");
} else {
- if (h1 == h2) {
- Assert.fail("Hash codes for <" + first + "> and <" + second
- + "> should be the same.");
- }
+ assertNotEquals(h1, h2,
+ "Hash codes for <" + first + "> and <" + second + "> should be the same.");
}
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java
index 9c71f16..54920b5 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java
@@ -1599,15 +1599,14 @@
ObjectClass parent2,
ObjectClassType type,
boolean isValid) throws Exception {
- ObjectClassBuilder builder = new ObjectClassBuilder("testType",
- "1.2.3");
+ ObjectClassBuilder builder = new ObjectClassBuilder("testType", "1.2.3");
builder.setObjectClassType(type);
Set<ObjectClass> superiors = new LinkedHashSet<ObjectClass>();
superiors.add(parent1);
superiors.add(parent2);
builder.setSuperior(superiors);
ObjectClass child = builder.getInstance();
- Assert.assertTrue(child.getSuperiorClasses().size()==2);
+ Assert.assertEquals(child.getSuperiorClasses().size(), 2);
}
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
index 5647d2d..38821a4 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
@@ -28,6 +28,7 @@
import java.util.ArrayList;
+import static org.opends.server.TestCaseUtils.*;
import static org.testng.Assert.*;
import org.forgerock.opendj.ldap.ByteString;
@@ -483,7 +484,7 @@
RDN rdn1 = new RDN(AT_DC, AV_DC_ORG);
RDN rdn2 = rdn1.duplicate();
- assertFalse(rdn1 == rdn2);
+ assertNotSame(rdn1, rdn2);
assertEquals(rdn1, rdn2);
}
@@ -504,7 +505,7 @@
RDN rdn1 = new RDN(types, names, values);
RDN rdn2 = rdn1.duplicate();
- assertFalse(rdn1 == rdn2);
+ assertNotSame(rdn1, rdn2);
assertEquals(rdn1, rdn2);
}
@@ -564,11 +565,11 @@
RDN rdn2 = RDN.decode(second);
if (result == 0) {
- assertTrue(rdn1.equals(rdn2), "RDN equality for <" + first
- + "> and <" + second + ">");
+ assertEquals(rdn1, rdn2,
+ "RDN equality for <" + first + "> and <" + second + ">");
} else {
- assertFalse(rdn1.equals(rdn2), "RDN equality for <" + first
- + "> and <" + second + ">");
+ assertNotEquals(rdn1, rdn2,
+ "RDN equality for <" + first + "> and <" + second + ">");
}
}
@@ -596,15 +597,11 @@
int h2 = rdn2.hashCode();
if (result == 0) {
- if (h1 != h2) {
- fail("Hash codes for <" + first + "> and <" + second
- + "> should be the same.");
- }
+ assertEquals(h1, h2, "Hash codes for <" + first + "> and <" + second
+ + "> should be the same.");
} else {
- if (h1 == h2) {
- fail("Hash codes for <" + first + "> and <" + second
- + "> should be the same.");
- }
+ assertNotEquals(h1, h2, "Hash codes for <" + first + "> and <" + second
+ + "> should be the same.");
}
}
@@ -637,38 +634,31 @@
rc = 1;
}
- assertEquals(rc, result, "Comparison for <" + first + "> and <"
- + second + ">.");
+ assertEquals(rc, result, "Comparison for <" + first + "> and <" + second + ">.");
}
/**
* Tests the equals method with a null argument.
- *
- * @throws Exception
- * If the test failed unexpectedly.
*/
@Test
public void testEqualityNull() {
RDN rdn = new RDN(AT_DC, AV_DC_ORG);
- assertFalse(rdn.equals(null));
+ assertNotEquals(rdn, null);
}
/**
* Tests the equals method with a non-RDN argument.
- *
- * @throws Exception
- * If the test failed unexpectedly.
*/
@Test
public void testEqualityNonRDN() {
RDN rdn = new RDN(AT_DC, AV_DC_ORG);
- assertFalse(rdn.equals("this isn't an RDN"));
+ assertNotEquals(rdn, "this isn't an RDN");
}
}
--
Gitblit v1.10.0