From e187c022c9d057b54e6015bd9fbefb79f50d1f17 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 26 Feb 2016 11:26:32 +0000
Subject: [PATCH] Prep work for OPENDJ-1342: align APIs for RDNs
---
opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java | 2
opendj-server-legacy/src/test/java/org/opends/server/plugins/UniqueAttributePluginTestCase.java | 224 +++++++--------------
opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java | 20 -
opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/core/GroupManagerTestCase.java | 5
opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java | 2
opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java | 2
opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java | 4
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java | 2
opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java | 2
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyDNMsg.java | 2
opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java | 18
opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java | 17 +
opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java | 2
opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java | 20 +
opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java | 2
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java | 44 ++--
opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java | 82 +++++---
opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java | 4
opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java | 4
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java | 2
opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java | 67 ++----
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 2
opendj-server-legacy/src/test/java/org/opends/server/util/TestModifyDNChangeRecordEntry.java | 4
25 files changed, 245 insertions(+), 296 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java b/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
index 1e6d570..7f5b1f0 100644
--- a/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
+++ b/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
@@ -11,7 +11,7 @@
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyright [year] [name of copyright owner]".
*
- * Copyright 2013-2015 ForgeRock AS.
+ * Copyright 2013-2016 ForgeRock AS.
*/
package org.forgerock.opendj.adapter.server3x;
@@ -185,7 +185,7 @@
*/
public static org.opends.server.types.RDN to(final RDN rdn) {
try {
- return org.opends.server.types.RDN.decode(rdn.toString());
+ return org.opends.server.types.RDN.valueOf(rdn.toString());
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java
index a5b9a78..1c8e0731 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java
@@ -246,7 +246,7 @@
{
if (newRDN == null)
{
- newRDN = RDN.decode(rawNewRDN.toString());
+ newRDN = RDN.valueOf(rawNewRDN.toString());
}
}
catch (DirectoryException de)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
index 3e5ef04..883f46a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
@@ -330,7 +330,7 @@
RDN newRDN;
try
{
- newRDN = RDN.decode(rawNewRDN.toString());
+ newRDN = RDN.valueOf(rawNewRDN.toString());
}
catch (DirectoryException de)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
index 5d830e0..666980e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -31,6 +31,7 @@
import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.ClientConnection;
@@ -1826,8 +1827,6 @@
return modifyDNOperation;
}
-
-
/**
* Processes an internal modify DN operation with the provided
* information.
@@ -1850,6 +1849,23 @@
}
/**
+ * Processes an internal modify DN operation with the provided information.
+ *
+ * @param modifyDNRequest
+ * The modify DN request with information about the processing to perform.
+ * @return A reference to the modify DN operation that was processed and contains information about
+ * the result of the processing.
+ */
+ public ModifyDNOperation processModifyDN(ModifyDNRequest modifyDNRequest)
+ {
+ org.forgerock.opendj.ldap.DN newSuperior = modifyDNRequest.getNewSuperior();
+ return processModifyDN(to(modifyDNRequest.getName()),
+ to(modifyDNRequest.getNewRDN()),
+ modifyDNRequest.isDeleteOldRDN(),
+ newSuperior != null ? to(newSuperior) : null);
+ }
+
+ /**
* Processes an internal search operation with the provided
* information.
*
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 4737efc..8deb7e4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3081,7 +3081,7 @@
String newRDN = "entryuuid=" + entryUUID + "+" + dn.rdn();
try
{
- return RDN.decode(newRDN);
+ return RDN.valueOf(newRDN);
} catch (DirectoryException e)
{
// cannot happen
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyDNMsg.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyDNMsg.java
index db9e64a..54b8a50 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyDNMsg.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyDNMsg.java
@@ -369,7 +369,7 @@
return DN.valueOf(newRDN + "," + newSuperior);
}
final DN parentDn = getDN().parent();
- return parentDn.child(RDN.decode(newRDN));
+ return parentDn.child(RDN.valueOf(newRDN));
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java b/opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java
index 2a71f70..b3917e4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java
@@ -221,7 +221,7 @@
* If a problem occurs while trying to decode the provided
* string as a RDN.
*/
- public static RDN decode(String rdnString) throws DirectoryException
+ public static RDN valueOf(String rdnString) throws DirectoryException
{
// A null or empty RDN is not acceptable.
if (rdnString == null)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
index cb6bc59..c7384b2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -1208,7 +1208,7 @@
try
{
- newRDN = RDN.decode(rdnStr);
+ newRDN = RDN.valueOf(rdnStr);
} catch (DirectoryException de)
{
logger.traceException(de);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
index d8488c4..8194454 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -704,7 +704,7 @@
// moddn robert to robert2
ModifyDNOperation modDNOp = connection.processModifyDN(
DN.valueOf("cn=Robert Hue," + baseDN5),
- RDN.decode("cn=Robert Hue2"), true,
+ RDN.valueOf("cn=Robert Hue2"), true,
baseDN5);
waitForSearchOpResult(modDNOp, ResultCode.SUCCESS);
@@ -1219,7 +1219,7 @@
final DN newSuperior = DN_OTEST2;
ModifyDNOperation op = new ModifyDNOperationBasis(connection, 1, 1, null,
DN.valueOf("uid=" + testName + "4," + replicaId.getBaseDN()), // entryDN
- RDN.decode("uid=" + testName + "new4"), // new rdn
+ RDN.valueOf("uid=" + testName + "new4"), // new rdn
true, // deleteoldrdn
newSuperior);
op.setAttachment(SYNCHROCONTEXT, new ModifyDnContext(csn, testName + "uuid4", "newparentId"));
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/GroupManagerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/GroupManagerTestCase.java
index c5c6933..869e6ff 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/GroupManagerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/GroupManagerTestCase.java
@@ -1187,9 +1187,8 @@
assertTrue(groupInstance.isMember(user1DN));
- // Rename the group and make sure the old one no longer exists but the new
- // one does.
- RDN newRDN = RDN.decode("cn=Renamed Group");
+ // Rename the group and make sure the old one no longer exists but the new one does
+ RDN newRDN = RDN.valueOf("cn=Renamed Group");
DN newDN = DN.valueOf("cn=Renamed Group,ou=Groups,o=test");
ModifyDNOperation modifyDNOperation =
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java b/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
index 03c2f8d..584fb3a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
@@ -293,7 +293,7 @@
private RDN rdn(String s) throws DirectoryException
{
- return s != null ? RDN.decode(s) : null;
+ return s != null ? RDN.valueOf(s) : null;
}
private void assertSuccessAndEntryExists(ModifyDNOperation modifyDNOperation,
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
index 87f1770..5d6adee 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
@@ -327,7 +327,7 @@
"cn: test");
ModifyDNOperation modifyDNOperation =
- getRootConnection().processModifyDN(e.getName(), RDN.decode("cn=test2"), false);
+ getRootConnection().processModifyDN(e.getName(), RDN.valueOf("cn=test2"), false);
assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS);
e = DirectoryConfig.getEntry(DN.valueOf("cn=test2,o=test"));
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
index 9576d73..e0ca0b5 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
@@ -24,6 +24,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.schema.AttributeType;
@@ -46,7 +47,6 @@
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
-import org.opends.server.types.RDN;
import org.opends.server.types.SearchResultEntry;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -1157,24 +1157,18 @@
* Perform modify DN operation.
*
* @param dn The DN to rename or move.
- * @param rdn RDN value.
+ * @param newRDN RDN value.
* @param newSuperior New superior to move to.
* @throws Exception If the operation can't be performed.
*/
- private void doModDN(String dn, String rdn, String newSuperior) throws Exception
+ private void doModDN(String dn, String newRDN, String newSuperior) throws Exception
{
- InternalClientConnection conn = getRootConnection();
- ModifyDNOperation modDNop;
- if(newSuperior != null)
+ ModifyDNRequest modifyDNRequest = Requests.newModifyDNRequest(dn, newRDN);
+ if (newSuperior != null)
{
- modDNop = conn.processModifyDN(DN.valueOf(dn), RDN.decode(rdn), true,
- DN.valueOf(newSuperior));
+ modifyDNRequest.setDeleteOldRDN(true).setNewSuperior(newSuperior);
}
- else
- {
- modDNop = conn.processModifyDN(DN.valueOf(dn), RDN.decode(rdn),
- false, null);
- }
+ ModifyDNOperation modDNop = getRootConnection().processModifyDN(modifyDNRequest);
assertEquals(modDNop.getResultCode(), ResultCode.SUCCESS);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/UniqueAttributePluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/UniqueAttributePluginTestCase.java
index 25fbcdf..f4bdea2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/UniqueAttributePluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/UniqueAttributePluginTestCase.java
@@ -17,12 +17,12 @@
package org.opends.server.plugins;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
+import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.UniqueAttributePluginCfgDefn;
@@ -31,33 +31,34 @@
import org.opends.server.core.AddOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.types.*;
-import org.testng.annotations.*;
+import org.opends.server.types.Attributes;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.Entry;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.forgerock.opendj.ldap.ResultCode.*;
+import static org.forgerock.opendj.ldap.requests.Requests.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
-/**
- * Unit test to test the unique attribute plugin.
- */
+/** Unit test to test the unique attribute plugin. */
+@SuppressWarnings("javadoc")
public class UniqueAttributePluginTestCase extends PluginTestCase {
- private DN uidConfigDN;
- private DN testConfigDN;
+ private String uidConfigDN;
+ private String testConfigDN;
private String dsConfigAttrType="ds-cfg-type";
private String dsConfigBaseDN="ds-cfg-base-dn";
- /**
- * Ensures that the Directory Server is running.
- *
- * @throws Exception If an unexpected problem occurs.
- */
@BeforeClass
- public void startServer()
- throws Exception
+ public void startServer() throws Exception
{
TestCaseUtils.restartServer();
TestCaseUtils.initializeTestBackend(true);
@@ -66,32 +67,19 @@
addTestEntries("o=test", 't');
TestCaseUtils.clearBackend("userRoot", "dc=example,dc=com");
addTestEntries("dc=example,dc=com", 'x');
- uidConfigDN=DN.valueOf("cn=UID Unique Attribute ,cn=Plugins,cn=config");
- testConfigDN=DN.valueOf("cn=Test Unique Attribute,cn=Plugins,cn=config");
+ uidConfigDN = "cn=UID Unique Attribute ,cn=Plugins,cn=config";
+ testConfigDN = "cn=Test Unique Attribute,cn=Plugins,cn=config";
}
-
- /**
- * Clears configuration information before each method run.
- *
- * @throws Exception If an unexpected problem occurs.
- */
@BeforeMethod
public void clearConfigEntries() throws Exception {
deleteAttrsFromEntry(uidConfigDN, dsConfigBaseDN);
deleteAttrsFromEntry(testConfigDN, dsConfigBaseDN);
- //Put an attribute type there that won't impact the rest of the unit
- //tests.
+ // Put an attribute type there that won't impact the rest of the unit tests.
replaceAttrInEntry(uidConfigDN, dsConfigAttrType,"oncRpcNumber");
replaceAttrInEntry(testConfigDN, dsConfigAttrType,"bootParameter");
}
-
- /**
- * Clears things up after the unit test is completed.
- *
- * @throws Exception If an unexpected problem occurs.
- */
@AfterClass
public void tearDown() throws Exception {
clearConfigEntries();
@@ -327,7 +315,7 @@
}
/**
- * Test modify DN operation with various scenerios. See method comments.
+ * Test modify DN operation with various scenarios. See method comments.
*
* @throws Exception If an unexpected result occurs.
*/
@@ -337,19 +325,15 @@
//that will be tested for.
Entry e = makeEntry("cn=test user, ou=new people,o=test");
addAttribute(e, "uid", "3user.3");
- addEntry(e, ResultCode.SUCCESS);
+ addEntry(e, SUCCESS);
//Setup uid attribute to be unique. Test using public naming contexts
//for base DNs.
replaceAttrInEntry(uidConfigDN,dsConfigAttrType,"uid");
- //Rename with new rdn, should fail, there is an entry already with that
- //uid value.
- doModDN(DN.valueOf("uid=3user.3, ou=people, o=test"), RDN.decode("uid=4"),
- false, null, ResultCode.CONSTRAINT_VIOLATION);
+ // Rename with new rdn, should fail, there is an entry already with that uid value
+ doModDN("uid=3user.3, ou=people, o=test", "uid=4", null, CONSTRAINT_VIOLATION);
//Rename with multi-valued RDN, should fail there is an entry already with
//that uid value.
- doModDN(DN.valueOf("uid=3user.3, ou=people, o=test"),
- RDN.decode("sn=xx+uid=4"),
- false, null, ResultCode.CONSTRAINT_VIOLATION);
+ doModDN("uid=3user.3, ou=people, o=test", "sn=xx+uid=4", null, CONSTRAINT_VIOLATION);
//Now add a base dn to be unique under, so new superior move can be tested.
replaceAttrInEntry(uidConfigDN,dsConfigBaseDN,"ou=new people,o=test");
@@ -357,16 +341,10 @@
//Try to move the entry to a new superior.
//Should fail, there is an entry under the new superior already with
//that uid value.
- doModDN(DN.valueOf("uid=3user.3, ou=people, o=test"),
- RDN.decode("uid=3user.3"), false,
- DN.valueOf("ou=new people, o=test"),
- ResultCode.CONSTRAINT_VIOLATION);
+ doModDN("uid=3user.3, ou=people, o=test", "uid=3user.3", "ou=new people, o=test", CONSTRAINT_VIOLATION);
//Test again with different superior, should succeed, new superior DN is
//not in base DN scope.
- doModDN(DN.valueOf("uid=3user.3, ou=people, o=test"),
- RDN.decode("uid=3user.3"), false,
- DN.valueOf("ou=new people1, o=test"),
- ResultCode.SUCCESS);
+ doModDN("uid=3user.3, ou=people, o=test", "uid=3user.3", "ou=new people1, o=test", SUCCESS);
}
/**
@@ -378,33 +356,28 @@
@Test
public void testModOperationNameContexts() throws Exception {
replaceAttrInEntry(uidConfigDN,dsConfigAttrType,"mail");
- LinkedList<Modification> mods = new LinkedList<>();
- addMods(mods,"mail",ModificationType.REPLACE,"userx@test","userxx@test", "user1t@test");
//Fail because user1t@test already exists under "o=people,o=test".
- doMods(mods, DN.valueOf("uid=5user.5,ou=People,o=test"),
- ResultCode.CONSTRAINT_VIOLATION);
- mods.clear();
- addMods(mods,"pager",ModificationType.ADD,"2-999-1234","1-999-5678");
- addMods(mods,"mail",ModificationType.ADD,"userx@test","userxx@test",
- "user1t@test");
+ ModifyRequest modifyRequest = newModifyRequest("uid=5user.5,ou=People,o=test")
+ .addModification(REPLACE, "mail", "userx@test", "userxx@test", "user1t@test");
+ doMods(modifyRequest, CONSTRAINT_VIOLATION);
//Fail because user1t@test already exists under "o=people,o=test".
- doMods(mods, DN.valueOf("uid=5user.5,ou=People,o=test"),
- ResultCode.CONSTRAINT_VIOLATION);
- mods.clear();
- addMods(mods,"pager",ModificationType.ADD,"2-999-1234","1-999-5678");
- addMods(mods,"mail",ModificationType.REPLACE,"userx@test","userxx@test", "user1t@test");
+ modifyRequest = newModifyRequest("uid=5user.5,ou=People,o=test")
+ .addModification(ADD, "pager", "2-999-1234", "1-999-5678")
+ .addModification(ADD, "mail", "userx@test", "userxx@test", "user1t@test");
+ doMods(modifyRequest, CONSTRAINT_VIOLATION);
//Ok because adding mail value user1t@test to entry that already
//contains mail value user1t@test.
- doMods(mods, DN.valueOf("uid=1user.1,ou=People,o=test"),
- ResultCode.SUCCESS);
- mods.clear();
+ modifyRequest = newModifyRequest("uid=1user.1,ou=People,o=test")
+ .addModification(ADD, "pager", "2-999-1234", "1-999-5678")
+ .addModification(REPLACE, "mail", "userx@test", "userxx@test", "user1t@test");
+ doMods(modifyRequest, SUCCESS);
//Replace employeenumber as the unique attribute.
replaceAttrInEntry(uidConfigDN,dsConfigAttrType,"employeenumber");
- addMods(mods,"employeenumber",ModificationType.INCREMENT,"1");
//Test modify increment extension.
//Fail because incremented value of employeenumber (2) already exists.
- doMods(mods, DN.valueOf("uid=1user.1,ou=People,o=test"),
- ResultCode.CONSTRAINT_VIOLATION);
+ modifyRequest = newModifyRequest("uid=1user.1,ou=People,o=test")
+ .addModification(INCREMENT, "employeenumber", "1");
+ doMods(modifyRequest, CONSTRAINT_VIOLATION);
}
@@ -427,21 +400,21 @@
//base DNs.
Entry e1 = makeEntry("cn=test user1, ou=People,o=test");
addAttribute(e1, "mail", "mailtest@test");
- addEntry(e1, ResultCode.SUCCESS);
+ addEntry(e1, SUCCESS);
Entry e2 = makeEntry("cn=test user2, ou=People1,o=test");
addAttribute(e2, "mail", "mailtest@test");
- addEntry(e2, ResultCode.SUCCESS);
+ addEntry(e2, SUCCESS);
//Now try to add two more entries with the same mail attribute value.
Entry e3 = makeEntry("cn=test user3, ou=People,o=test");
addAttribute(e3, "mail", "mailtest@test");
- addEntry(e3, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e3, CONSTRAINT_VIOLATION);
Entry e4 = makeEntry("cn=test user4, ou=People1,o=test");
addAttribute(e4, "mail", "mailtest@test");
- addEntry(e4, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e4, CONSTRAINT_VIOLATION);
}
/**
- * Test various add operation scenerios using defined base DNs.
+ * Test various add operation scenarios using defined base DNs.
* See comments in method.
*
* @throws Exception If an unexpected result occurs.
@@ -454,22 +427,22 @@
Entry e = makeEntry("cn=test user, ou=People,o=test");
addAttribute(e, "mail", "user1t@test");
//Fail because mail attribute already exists under "ou=people,o=test".
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
delAttribute(e, "mail");
//Replace mobile, pager, telephonenumber to config.
replaceAttrInEntry(uidConfigDN,dsConfigAttrType,"mobile",
"pager","telephonenumber");
addAttribute(e, "mobile", "1-999-1234","1-999-5678","1-444-9012");
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
e.setDN(DN.valueOf("cn=test user, ou=People,o=test"));
//Fail because "2-333-9012" already exists in "ou=people,o=test" in
//telephonenumber attribute.
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
delAttribute(e, "mobile");
addAttribute(e, "pager", "2-111-1234","1-999-5678","1-999-9012");
//Fail because "2-111-9012" already exists in "ou=people1,o=test" in
//mobile attribute.
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
//Test two plugin configuration. Add mail attribute to second plugin
//instance, leave the first instance as it is.
replaceAttrInEntry(testConfigDN,dsConfigAttrType,"mail");
@@ -481,7 +454,7 @@
//Add a value that will fail the second plugin.
addAttribute(e, "mail", "user1t@test");
//Should pass frirail through second plugin configuration.
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
}
@@ -498,21 +471,21 @@
addAttribute(e, "mail", "user77x@test");
//Fail because mail value "user77x@test" is a value under the
//"dc=example,dc=com" naming context.
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
delAttribute(e, "mail");
replaceAttrInEntry(uidConfigDN,dsConfigAttrType,"mobile",
"pager","telephonenumber");
addAttribute(e, "mobile", "1-999-1234","1-999-5678","2-777-9012");
//Fail because "2-777-9012" is a telephone value under the
//"dc=example,dc=com" naming context.
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
e.setDN(DN.valueOf("cn=test user, ou=People,o=test"));
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
delAttribute(e, "mobile");
addAttribute(e, "pager", "2-777-1234","1-999-5678","1-999-9012");
//Fail because "2-777-9012" is a telephone value under the
//"dc=example,dc=com" naming context.
- addEntry(e, ResultCode.CONSTRAINT_VIOLATION);
+ addEntry(e, CONSTRAINT_VIOLATION);
}
@@ -705,8 +678,8 @@
private void clearAcis(String suffix) throws Exception
{
- deleteAttrsFromEntry(DN.valueOf("ou=People," + suffix), "aci");
- deleteAttrsFromEntry(DN.valueOf("ou=People1," + suffix), "aci");
+ deleteAttrsFromEntry("ou=People," + suffix, "aci");
+ deleteAttrsFromEntry("ou=People1," + suffix, "aci");
}
/**
@@ -718,21 +691,18 @@
* entry.
* @throws Exception If an error occurs.
*/
- private void
- deleteAttrsFromEntry(DN dn, String... attrTypeStrings) throws Exception {
- LinkedList<Modification> mods = new LinkedList<>();
+ private void deleteAttrsFromEntry(String dn, String... attrTypeStrings) throws Exception {
+ ModifyRequest modifyRequest = newModifyRequest(dn);
for(String attrTypeString : attrTypeStrings) {
- AttributeType attrType = getAttributeType(attrTypeString);
- mods.add(new Modification(ModificationType.DELETE,
- Attributes.empty(attrType)));
+ modifyRequest.addModification(DELETE, attrTypeString);
}
- getRootConnection().processModify(dn, mods);
+ getRootConnection().processModify(modifyRequest);
}
- private void replaceAttrInEntry(DN dn, String attrName, String... attrValStrings) {
- LinkedList<Modification> mods = newLinkedList(
- new Modification(ModificationType.REPLACE, Attributes.create(attrName, attrValStrings)));
- getRootConnection().processModify(dn, mods);
+ private void replaceAttrInEntry(String dn, String attrName, Object... attrValStrings) {
+ ModifyRequest modifyRequest = newModifyRequest(dn)
+ .addModification(REPLACE, attrName, attrValStrings);
+ getRootConnection().processModify(modifyRequest);
}
@@ -770,67 +740,27 @@
);
}
- /**
- * Remove an attribute from the specified entry.
- *
- * @param entry The entry to remove the attribute from.
- * @param attrTypeString The attribute type string to remove.
- */
private void delAttribute(Entry entry, String attrTypeString) {
entry.removeAttribute(getAttributeType(attrTypeString));
}
- /**
- * Add an attribute to an entry with specified values.
- *
- * @param entry The entry to add the attribute to.
- * @param attrName The attribute type string name.
- * @param attrValues The values use in building the attribute.
- */
private void addAttribute(Entry entry, String attrName, String... attrValues) {
entry.addAttribute(Attributes.create(attrName, attrValues), null);
}
- /**
- * Add a new modification for attribute type string and values of modification
- * type to a list of modifications.
- *
- * @param mods The modification list to add to.
- * @param attrName The attribute type string name.
- * @param modificationType The modification type.
- * @param attrValues The values to build the modification from.
- */
- private void
- addMods(LinkedList<Modification> mods, String attrName,
- ModificationType modificationType, String... attrValues) {
- mods.add(new Modification(modificationType,
- Attributes.create(attrName, attrValues)));
- }
-
- /**
- * Perform modify operation with list of modifications. Expect return code
- * of value rc.
- *
- * @param mods The modification list to use.
- * @param dn The DN of the entry to modify.
- * @param rc The expected return code.
- */
- private void doMods(LinkedList<Modification> mods, DN dn, ResultCode rc) {
- ModifyOperation modifyOperation = getRootConnection().processModify(dn, mods);
+ private void doMods(ModifyRequest modifyRequest, ResultCode rc) throws DirectoryException {
+ ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest);
assertEquals(modifyOperation.getResultCode(), rc);
}
- /**
- * Perform modify DN operation. Expect return value of rc.
- *
- * @param dn The DN to rename or move.
- * @param rdn RDN value.
- * @param delOld Delete old flag.
- * @param newSuperior New superior to move to.
- * @param rc Expected return code from operation.
- */
- private void doModDN(DN dn, RDN rdn, boolean delOld, DN newSuperior, ResultCode rc) {
- ModifyDNOperation modifyDNOperation = getRootConnection().processModifyDN(dn, rdn, delOld, newSuperior);
+ private void doModDN(String dn, String newRdn, String newSuperior, ResultCode rc)
+ throws DirectoryException {
+ ModifyDNRequest modifyDNRequest = newModifyDNRequest(dn, newRdn);
+ if (newSuperior != null)
+ {
+ modifyDNRequest.setNewSuperior(newSuperior);
+ }
+ ModifyDNOperation modifyDNOperation = getRootConnection().processModifyDN(modifyDNRequest);
assertEquals(modifyDNOperation.getResultCode(), rc);
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
index 356d3ba..72c3e8e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
@@ -615,7 +615,7 @@
InternalClientConnection conn = getRootConnection();
ModifyDNOperation modifyDNOperation =
conn.processModifyDN(DN.valueOf("cn=test,o=test"),
- RDN.decode("cn=test2"), true);
+ RDN.valueOf("cn=test2"), true);
assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS);
}
@@ -640,7 +640,7 @@
InternalClientConnection conn = getRootConnection();
ModifyDNOperation modifyDNOperation =
conn.processModifyDN(DN.valueOf("cn=test,o=test"),
- RDN.decode("cn=test2"), true,
+ RDN.valueOf("cn=test2"), true,
DN.valueOf("dc=example,dc=com"));
assertEquals(modifyDNOperation.getResultCode(),
ResultCode.UNWILLING_TO_PERFORM);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
index afc6569..6a2fa40 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
@@ -545,7 +545,7 @@
// Try to rename the entry.
ModifyDNOperationBasis modifyDNOp = new ModifyDNOperationBasis(
conn, conn.nextOperationID(), conn.nextMessageID(), controls,
- e.getName(), RDN.decode("cn=Proxy V1 Test"), true, null);
+ e.getName(), RDN.valueOf("cn=Proxy V1 Test"), true, null);
assertSuccess(hasProxyPrivilege, modifyDNOp);
DN newEntryDN = hasProxyPrivilege ? modifyDNOp.getNewDN() : e.getName();
@@ -657,7 +657,7 @@
// Try to rename the entry.
ModifyDNOperationBasis modifyDNOp = new ModifyDNOperationBasis(
conn, conn.nextOperationID(), conn.nextMessageID(), controls,
- e.getName(), RDN.decode("cn=Proxy V2 Test"), true, null);
+ e.getName(), RDN.valueOf("cn=Proxy V2 Test"), true, null);
assertSuccess(hasProxyPrivilege, authDN, modifyDNOp);
DN newEntryDN = hasProxyPrivilege ? modifyDNOp.getNewDN() : e.getName();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
index 6b6465b..1f5c2bf 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
@@ -26,6 +26,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
@@ -53,7 +54,6 @@
import org.opends.server.types.Modification;
import org.opends.server.types.Operation;
import org.opends.server.types.OperationType;
-import org.opends.server.types.RDN;
import org.opends.server.util.TestTimer;
import org.opends.server.util.TimeThread;
import org.testng.annotations.BeforeClass;
@@ -63,6 +63,7 @@
import static java.util.concurrent.TimeUnit.*;
import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.forgerock.opendj.ldap.requests.Requests.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
@@ -871,10 +872,10 @@
personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
// - MODDN parent entry 1 to baseDn2 in the LDAP server
- connection.processModifyDN(
- baseDN1,
- RDN.decode("ou=baseDn2"), true,
- baseDN);
+ ModifyDNRequest modifyDNRequest = newModifyDNRequest(baseDN1.toString(), "ou=baseDn2")
+ .setDeleteOldRDN(true)
+ .setNewSuperior(baseDN.toString());
+ connection.processModifyDN(modifyDNRequest);
assertNotNull(getEntry(baseDN2, 10000, true),
"Entry not moved from " + baseDN1 + " to " + baseDN2);
@@ -1135,9 +1136,11 @@
assertClientReceivesExpectedMsg(broker, ModifyMsg.class, personEntry.getName());
// Modify the entry DN
+ ModifyDNRequest modifyDNRequest = newModifyDNRequest(personEntry.getName().toString(), "uid=new person")
+ .setDeleteOldRDN(true)
+ .setNewSuperior(baseDN.toString());
+ connection.processModifyDN(modifyDNRequest);
DN newDN = DN.valueOf("uid= new person," + baseDN);
- connection.processModifyDN(personEntry.getName(),
- RDN.decode("uid=new person"), true, baseDN);
assertTrue(DirectoryServer.entryExists(newDN),
"The MOD_DN operation didn't create the new person entry");
assertFalse(DirectoryServer.entryExists(personEntry.getName()),
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java
index c31b7bf..a26dca1 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/NamingConflictTest.java
@@ -181,7 +181,7 @@
// Now delete the first entry that was added at the beginning
ModifyDNOperation modDNOperation =
- getRootConnection().processModifyDN(entry.getName(), RDN.decode("cn=foo"), false);
+ getRootConnection().processModifyDN(entry.getName(), RDN.valueOf("cn=foo"), false);
assertEquals(modDNOperation.getResultCode(), ResultCode.SUCCESS);
// Expect the conflict resolution : the second entry should now
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
index c710aa1..a116600 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -16,19 +16,44 @@
*/
package org.opends.server.replication.protocol;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
import java.util.zip.DataFormatException;
import org.assertj.core.api.Assertions;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ModificationType;
+import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.controls.SubtreeDeleteControl;
-import org.opends.server.core.*;
+import org.opends.server.core.AddOperation;
+import org.opends.server.core.AddOperationBasis;
+import org.opends.server.core.DeleteOperation;
+import org.opends.server.core.DeleteOperationBasis;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyOperation;
+import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.ReplicationTestCase;
-import org.opends.server.replication.common.*;
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.types.*;
+import org.opends.server.replication.common.AssuredMode;
+import org.opends.server.replication.common.CSN;
+import org.opends.server.replication.common.DSInfo;
+import org.opends.server.replication.common.RSInfo;
+import org.opends.server.replication.common.ServerState;
+import org.opends.server.replication.common.ServerStatus;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.Attributes;
+import org.opends.server.types.DN;
+import org.opends.server.types.LDAPException;
+import org.opends.server.types.Modification;
+import org.opends.server.types.ObjectClass;
+import org.opends.server.types.RawAttribute;
import org.opends.server.util.TimeThread;
import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation;
import org.opends.server.workflowelement.localbackend.LocalBackendDeleteOperation;
@@ -38,7 +63,9 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.forgerock.opendj.ldap.requests.Requests.*;
import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.replication.protocol.OperationContext.*;
import static org.opends.server.replication.protocol.ProtocolVersion.*;
import static org.opends.server.util.CollectionUtils.*;
@@ -137,11 +164,7 @@
List<Attribute> entryAttrList)
throws Exception
{
- DN dn = DN.valueOf(rawdn);
- InternalClientConnection connection =
- InternalClientConnection.getRootConnection();
- ModifyMsg msg = new ModifyMsg(csn, dn, mods, "fakeuniqueid");
-
+ ModifyMsg msg = new ModifyMsg(csn, DN.valueOf(rawdn), mods, "fakeuniqueid");
msg.setAssured(isAssured);
msg.setAssuredMode(assuredMode);
msg.setSafeDataLevel(safeDataLevel);
@@ -165,8 +188,9 @@
// Get ECL entry attributes
assertAttributesEqual(generatedMsg.getEclIncludes(), entryAttrList);
- ModifyOperation mod1 = (ModifyOperation) msg.createOperation(connection);
- ModifyOperation mod2 = (ModifyOperation) generatedMsg.createOperation(connection);
+ InternalClientConnection conn = getRootConnection();
+ ModifyOperation mod1 = (ModifyOperation) msg.createOperation(conn);
+ ModifyOperation mod2 = (ModifyOperation) generatedMsg.createOperation(conn);
assertEquals(mod1.getRawEntryDN(), mod2.getRawEntryDN());
assertEquals(mod1.getAttachment(SYNCHROCONTEXT),
@@ -272,8 +296,6 @@
boolean subtree)
throws Exception
{
- InternalClientConnection connection =
- InternalClientConnection.getRootConnection();
DeleteOperation deleteOp =
new DeleteOperationBasis(connection, 1, 1,null, DN.valueOf(rawDN));
if (subtree)
@@ -302,7 +324,7 @@
// Get ECL entry attributes
assertAttributesEqual(generatedMsg.getEclIncludes(), entryAttrList);
- DeleteOperation mod2 = (DeleteOperation) generatedMsg.createOperation(connection);
+ DeleteOperation mod2 = (DeleteOperation) generatedMsg.createOperation(getRootConnection());
assertEquals(mod2.getRequestControl(SubtreeDeleteControl.DECODER) != null, subtree);
assertEquals(op.getRawEntryDN(), mod2.getRawEntryDN());
@@ -359,11 +381,13 @@
byte safeDataLevel, List<Attribute> entryAttrList)
throws Exception
{
- InternalClientConnection connection =
- InternalClientConnection.getRootConnection();
- ModifyDNOperation op = new ModifyDNOperationBasis(connection, 1, 1, null,
- DN.valueOf(rawDN), RDN.decode(newRdn), deleteOldRdn,
- (newSuperior.length() != 0 ? DN.valueOf(newSuperior) : null));
+ ModifyDNRequest modifyDNRequest = newModifyDNRequest(rawDN, newRdn)
+ .setDeleteOldRDN(deleteOldRdn);
+ if (newSuperior.length() != 0)
+ {
+ modifyDNRequest.setNewSuperior(newSuperior);
+ }
+ ModifyDNOperation op = getRootConnection().processModifyDN(modifyDNRequest);
CSN csn = new CSN(TimeThread.getTime(), 123, 45);
op.setAttachment(SYNCHROCONTEXT,
@@ -397,8 +421,8 @@
// Get ECL entry attributes
assertAttributesEqual(generatedMsg.getEclIncludes(), entryAttrList);
- ModifyDNOperation moddn1 = (ModifyDNOperation) msg.createOperation(connection);
- ModifyDNOperation moddn2 = (ModifyDNOperation) generatedMsg.createOperation(connection);
+ ModifyDNOperation moddn1 = (ModifyDNOperation) msg.createOperation(getRootConnection());
+ ModifyDNOperation moddn2 = (ModifyDNOperation) generatedMsg.createOperation(getRootConnection());
assertEquals(msg.getCSN(), generatedMsg.getCSN());
assertEquals(moddn1.getRawEntryDN(), moddn2.getRawEntryDN());
@@ -475,10 +499,9 @@
assertAttributesEqual(generatedMsg.getEclIncludes(), entryAttrList);
// Create an new Add Operation from the current addMsg
- InternalClientConnection connection =
- InternalClientConnection.getRootConnection();
- AddOperation addOp = msg.createOperation(connection, dn);
- AddOperation genAddOp = generatedMsg.createOperation(connection, dn);
+ InternalClientConnection conn = getRootConnection();
+ AddOperation addOp = msg.createOperation(conn, dn);
+ AddOperation genAddOp = generatedMsg.createOperation(conn, dn);
assertEquals(addOp.getRawEntryDN(), genAddOp.getRawEntryDN());
assertEquals(addOp.getAttachment(SYNCHROCONTEXT), genAddOp.getAttachment(SYNCHROCONTEXT));
@@ -490,7 +513,7 @@
assertEquals(msg.toString(), generatedMsg.toString());
//Create an Add operation and generate and Add msg from it
- AddOperation addOpB = new AddOperationBasis(connection,
+ AddOperation addOpB = new AddOperationBasis(conn,
1, 1, null, dn, objectClassList, userAttList, opList);
LocalBackendAddOperation localAddOp = new LocalBackendAddOperation(addOpB);
OperationContext opCtx = new AddContext(csn, "thisIsaUniqueID",
@@ -1322,9 +1345,6 @@
public void deleteMsgPerfs(String rawDN, List<Attribute> entryAttrList)
throws Exception
{
- InternalClientConnection connection =
- InternalClientConnection.getRootConnection();
-
long createop = 0;
long createmsgfromop = 0;
long encodemsg = 0;
@@ -1339,7 +1359,7 @@
// create op
DeleteOperation deleteOp =
- new DeleteOperationBasis(connection, 1, 1,null, DN.valueOf(rawDN));
+ new DeleteOperationBasis(getRootConnection(), 1, 1,null, DN.valueOf(rawDN));
LocalBackendDeleteOperation op =
new LocalBackendDeleteOperation(deleteOp);
CSN csn = new CSN(TimeThread.getTime(), 123, 45);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java
index 4150afd..009b298 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java
@@ -776,7 +776,7 @@
private ModifyDNMsg modDNMsg(CSNGenerator csnGen) throws DirectoryException
{
ModifyDNOperationBasis op = new ModifyDNOperationBasis(
- connection, 1, 1, null, EXAMPLE_DN, RDN.decode("o=example2"), true, null);
+ connection, 1, 1, null, EXAMPLE_DN, RDN.valueOf("o=example2"), true, null);
op.setAttachment(SYNCHROCONTEXT, new ModifyDnContext(csnGen.newCSN(), "uniqueid", "newparentId"));
LocalBackendModifyDNOperation localOp = new LocalBackendModifyDNOperation(op);
return new ModifyDNMsg(localOp);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
index 3070824..be3736b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
@@ -74,6 +74,7 @@
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.types.Privilege.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
@@ -408,7 +409,12 @@
private void assertPrivilege(ResultCode actual, boolean hasPrivilege)
{
- assertEquals(actual, hasPrivilege ? SUCCESS : INSUFFICIENT_ACCESS_RIGHTS);
+ assertEquals(actual, hasPrivilegeRC(hasPrivilege));
+ }
+
+ private ResultCode hasPrivilegeRC(boolean hasPrivilege)
+ {
+ return hasPrivilege ? SUCCESS : INSUFFICIENT_ACCESS_RIGHTS;
}
private void assertProxyPrivilege(ResultCode actual, boolean hasProxyPrivilege)
@@ -549,20 +555,11 @@
{
assertEquals(conn.hasPrivilege(Privilege.CONFIG_WRITE, null), hasPrivilege);
- ModifyDNOperation modifyDNOperation =
- conn.processModifyDN(DN.valueOf("cn=Work Queue,cn=config"),
- RDN.decode("cn=New RDN for Work Queue"), true,
- null);
- if (hasPrivilege)
- {
- // We don't support modify DN operations in the server configuration, but
- // at least we need to make sure we're getting past the privilege check.
- assertEquals(modifyDNOperation.getResultCode(), UNWILLING_TO_PERFORM);
- }
- else
- {
- assertEquals(modifyDNOperation.getResultCode(), INSUFFICIENT_ACCESS_RIGHTS);
- }
+ processModifyDN(
+ conn, "cn=Work Queue,cn=config", "cn=New RDN for Work Queue",
+ // We don't support modify DN operations in the server configuration, but
+ // at least we need to make sure we're getting past the privilege check.
+ (hasPrivilege ? UNWILLING_TO_PERFORM : INSUFFICIENT_ACCESS_RIGHTS));
}
@@ -664,26 +661,15 @@
boolean hasPrivilege)
throws Exception
{
- assertEquals(conn.hasPrivilege(Privilege.SUBENTRY_WRITE, null),
- hasPrivilege);
+ assertEquals(conn.hasPrivilege(SUBENTRY_WRITE, null), hasPrivilege);
- ModifyDNOperation modifyDNOperation =
- conn.processModifyDN(DN.valueOf("cn=Subentry Target,o=test"),
- RDN.decode("cn=New Subentry Target"),
- true, null);
- assertPrivilege(modifyDNOperation.getResultCode(), hasPrivilege);
+ processModifyDN(conn, "cn=Subentry Target,o=test", "cn=New Subentry Target", hasPrivilegeRC(hasPrivilege));
if (hasPrivilege)
{
- modifyDNOperation =
- conn.processModifyDN(DN.valueOf("cn=New Subentry Target,o=test"),
- RDN.decode("cn=Subentry Target"),
- true, null);
- assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS);
+ processModifyDN(conn, "cn=New Subentry Target,o=test", "cn=Subentry Target", SUCCESS);
}
}
-
-
/**
* Tests to ensure that modify operations which attempt to reset a user's
* password properly respect the PASSWORD_RESET privilege.
@@ -722,8 +708,7 @@
userPassword = "password";
}
- assertEquals(conn.hasPrivilege(Privilege.PASSWORD_RESET, null),
- hasPrivilege);
+ assertEquals(conn.hasPrivilege(PASSWORD_RESET, null), hasPrivilege);
String path = TestCaseUtils.createTempFile(
"dn: cn=PWReset Target,o=test",
@@ -855,8 +840,7 @@
boolean hasPrivilege)
throws Exception
{
- assertEquals(conn.hasPrivilege(Privilege.UPDATE_SCHEMA, null),
- hasPrivilege);
+ assertEquals(conn.hasPrivilege(UPDATE_SCHEMA, null), hasPrivilege);
String attrDefinition =
"( testupdateschemaat-oid NAME 'testUpdateSchemaAT' " +
@@ -896,11 +880,7 @@
boolean hasPrivilege)
throws Exception
{
- assertEquals(conn.hasPrivilege(Privilege.UPDATE_SCHEMA, null),
- hasPrivilege);
-
-
- String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath();
+ assertEquals(conn.hasPrivilege(UPDATE_SCHEMA, null), hasPrivilege);
String identifier;
Entry authNEntry = conn.getAuthenticationInfo().getAuthenticationEntry();
@@ -927,6 +907,7 @@
+ " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )"
};
+ String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath();
File validFile = new File(schemaDirectory, "05-" + identifier + ".ldif");
try (BufferedWriter writer = new BufferedWriter(new FileWriter(validFile)))
{
@@ -1193,7 +1174,7 @@
// Try to rename the entry.
ModifyDNOperation modifyDNOperation = new ModifyDNOperationBasis(conn, nextOperationID(),
nextMessageID(), controls, e.getName(),
- RDN.decode("cn=Proxy V1 Test"), true, null);
+ RDN.valueOf("cn=Proxy V1 Test"), true, null);
modifyDNOperation.run();
assertProxyPrivilege(modifyOperation.getResultCode(), hasProxyPrivilege);
@@ -1335,7 +1316,7 @@
// Try to rename the entry.
ModifyDNOperation modifyDNOperation = new ModifyDNOperationBasis(conn, nextOperationID(),
nextMessageID(), controls, e.getName(),
- RDN.decode("cn=Proxy V2 Test"), true, null);
+ RDN.valueOf("cn=Proxy V2 Test"), true, null);
modifyDNOperation.run();
assertProxyPrivilege(modifyDNOperation.getResultCode(), hasProxyPrivilege);
@@ -2429,4 +2410,10 @@
return task;
}
+
+ private void processModifyDN(InternalClientConnection conn, String dn, String newRdn, ResultCode expectedRC)
+ {
+ ModifyDNOperation op = conn.processModifyDN(newModifyDNRequest(dn, newRdn).setDeleteOldRDN(true));
+ assertEquals(op.getResultCode(), expectedRC);
+ }
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
index 0120baf..7b23fa0 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -234,7 +234,7 @@
*/
@Test
public void testCreateWithSingleRDN1() throws Exception {
- DN dn = new DN(new RDN[] { RDN.decode("dc=com") });
+ DN dn = new DN(new RDN[] { RDN.valueOf("dc=com") });
assertEquals(dn, DN.valueOf("dc=com"));
}
@@ -249,8 +249,8 @@
*/
@Test
public void testCreateWithMultipleRDNs1() throws Exception {
- DN dn = new DN(new RDN[] { RDN.decode("dc=foo"),
- RDN.decode("dc=opends"), RDN.decode("dc=org") });
+ DN dn = new DN(new RDN[] { RDN.valueOf("dc=foo"),
+ RDN.valueOf("dc=opends"), RDN.valueOf("dc=org") });
assertEquals(dn, DN.valueOf("dc=foo,dc=opends,dc=org"));
}
@@ -266,9 +266,9 @@
@Test
public void testCreateWithMultipleRDNs2() throws Exception {
ArrayList<RDN> rdnList = new ArrayList<>();
- rdnList.add(RDN.decode("dc=foo"));
- rdnList.add(RDN.decode("dc=opends"));
- rdnList.add(RDN.decode("dc=org"));
+ rdnList.add(RDN.valueOf("dc=foo"));
+ rdnList.add(RDN.valueOf("dc=opends"));
+ rdnList.add(RDN.valueOf("dc=org"));
DN dn = new DN(rdnList);
assertEquals(dn, DN.valueOf("dc=foo,dc=opends,dc=org"));
@@ -550,7 +550,7 @@
public void testGetParentDNInSuffix(DN namingContext) throws Exception {
assertNull(DirectoryServer.getParentDNInSuffix(namingContext));
- DN childDN = namingContext.child(RDN.decode("ou=People"));
+ DN childDN = namingContext.child(RDN.valueOf("ou=People"));
assertNotNull(DirectoryServer.getParentDNInSuffix(childDN));
assertEquals(DirectoryServer.getParentDNInSuffix(childDN), namingContext);
}
@@ -588,18 +588,18 @@
assertEquals(p.toNormalizedUrlSafeString(), e.toNormalizedUrlSafeString());
assertEquals(p.toString(), e.toString());
- assertEquals(p.rdn(), RDN.decode("dc=bar"));
+ assertEquals(p.rdn(), RDN.valueOf("dc=bar"));
- assertEquals(p.getRDN(0), RDN.decode("dc=bar"));
- assertEquals(p.getRDN(1), RDN.decode("dc=opends"));
- assertEquals(p.getRDN(2), RDN.decode("dc=org"));
+ assertEquals(p.getRDN(0), RDN.valueOf("dc=bar"));
+ assertEquals(p.getRDN(1), RDN.valueOf("dc=opends"));
+ assertEquals(p.getRDN(2), RDN.valueOf("dc=org"));
assertEquals(p.parent(), DN.valueOf("dc=opends,dc=org"));
assertEquals(p.parent(), e.parent());
- assertEquals(p.child(RDN.decode("dc=foo")), DN
+ assertEquals(p.child(RDN.valueOf("dc=foo")), DN
.valueOf("dc=foo,dc=bar,dc=opends,dc=org"));
- assertEquals(p.child(RDN.decode("dc=foo")), c);
+ assertEquals(p.child(RDN.valueOf("dc=foo")), c);
assertEquals(p.child(DN.valueOf("dc=xxx,dc=foo")), DN
.valueOf("dc=xxx,dc=foo,dc=bar,dc=opends,dc=org"));
}
@@ -622,7 +622,7 @@
public void testGetRDN(String s, String p, String r)
throws Exception {
DN dn = DN.valueOf(s);
- RDN rdn = r != null ? RDN.decode(r) : null;
+ RDN rdn = r != null ? RDN.valueOf(r) : null;
assertEquals(dn.rdn(), rdn, "For DN " + s);
}
@@ -663,7 +663,7 @@
public void testGetRDNIndexed(String s, int i, String r)
throws Exception {
DN dn = DN.valueOf(s);
- RDN rdn = RDN.decode(r);
+ RDN rdn = RDN.valueOf(r);
assertEquals(dn.getRDN(i), rdn, "For DN " + s);
}
@@ -802,17 +802,17 @@
assertEquals(c.toNormalizedUrlSafeString(), e.toNormalizedUrlSafeString());
assertEquals(c.toString(), e.toString());
- assertEquals(c.rdn(), RDN.decode("dc=foo"));
+ assertEquals(c.rdn(), RDN.valueOf("dc=foo"));
- assertEquals(c.getRDN(0), RDN.decode("dc=foo"));
- assertEquals(c.getRDN(1), RDN.decode("dc=bar"));
- assertEquals(c.getRDN(2), RDN.decode("dc=opends"));
- assertEquals(c.getRDN(3), RDN.decode("dc=org"));
+ assertEquals(c.getRDN(0), RDN.valueOf("dc=foo"));
+ assertEquals(c.getRDN(1), RDN.valueOf("dc=bar"));
+ assertEquals(c.getRDN(2), RDN.valueOf("dc=opends"));
+ assertEquals(c.getRDN(3), RDN.valueOf("dc=org"));
assertEquals(c.parent(), DN.valueOf("dc=bar,dc=opends,dc=org"));
assertEquals(c.parent(), e.parent());
- assertEquals(c.child(RDN.decode("dc=xxx")), DN
+ assertEquals(c.child(RDN.valueOf("dc=xxx")), DN
.valueOf("dc=xxx,dc=foo,dc=bar,dc=opends,dc=org"));
assertEquals(c.child(DN.valueOf("dc=xxx,dc=yyy")), DN
.valueOf("dc=xxx,dc=yyy,dc=foo,dc=bar,dc=opends,dc=org"));
@@ -850,7 +850,7 @@
public void testConcatSingleRDN(String s, String r, String e)
throws Exception {
DN dn = DN.valueOf(s);
- RDN rdn = RDN.decode(r);
+ RDN rdn = RDN.valueOf(r);
DN expected = DN.valueOf(e);
assertEquals(dn.child(rdn), expected);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
index fd52e8c..d506f9b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
@@ -236,7 +236,7 @@
*/
@Test(dataProvider = "testRDNs")
public void testNormalizationToSafeUrlString(String rawRDN, String normRDN, String stringRDN) throws Exception {
- RDN rdn = RDN.decode(rawRDN);
+ RDN rdn = RDN.valueOf(rawRDN);
assertEquals(rdn.toNormalizedUrlSafeString(), normRDN);
}
@@ -272,7 +272,7 @@
*/
@Test(dataProvider = "illegalRDNs", expectedExceptions = DirectoryException.class)
public void testDecodeString(String rawRDN) throws Exception {
- RDN.decode(rawRDN);
+ RDN.valueOf(rawRDN);
fail("Expected exception for value \"" + rawRDN + "\"");
}
@@ -404,7 +404,7 @@
@Test(dataProvider = "testRDNs")
public void testToString(String rawRDN, String normRDN,
String stringRDN) throws Exception {
- RDN rdn = RDN.decode(rawRDN);
+ RDN rdn = RDN.valueOf(rawRDN);
assertEquals(rdn.toString(), stringRDN);
}
@@ -458,8 +458,8 @@
@Test(dataProvider = "createRDNEqualityData")
public void testEquality(String first, String second, int result)
throws Exception {
- RDN rdn1 = RDN.decode(first);
- RDN rdn2 = RDN.decode(second);
+ RDN rdn1 = RDN.valueOf(first);
+ RDN rdn2 = RDN.valueOf(second);
if (result == 0) {
assertEquals(rdn1, rdn2,
@@ -487,8 +487,8 @@
@Test(dataProvider = "createRDNEqualityData")
public void testHashCode(String first, String second, int result)
throws Exception {
- RDN rdn1 = RDN.decode(first);
- RDN rdn2 = RDN.decode(second);
+ RDN rdn1 = RDN.valueOf(first);
+ RDN rdn2 = RDN.valueOf(second);
int h1 = rdn1.hashCode();
int h2 = rdn2.hashCode();
@@ -519,8 +519,8 @@
@Test(dataProvider = "createRDNEqualityData")
public void testCompareTo(String first, String second, int result)
throws Exception {
- RDN rdn1 = RDN.decode(first);
- RDN rdn2 = RDN.decode(second);
+ RDN rdn1 = RDN.valueOf(first);
+ RDN rdn2 = RDN.valueOf(second);
int rc = rdn1.compareTo(rdn2);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java b/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
index 11f249f..fbf4dc3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
@@ -465,7 +465,7 @@
.valueOf("cn=Paul Jensen, ou=Product Development, dc=airius, dc=com");
Assert.assertEquals(modifyDN.getDN(), dn);
- rdn = RDN.decode("cn=paula jensen");
+ rdn = RDN.valueOf("cn=paula jensen");
Assert.assertEquals(modifyDN.getNewRDN(), rdn);
Assert.assertNull(modifyDN.getNewSuperiorDN());
Assert.assertTrue(modifyDN.deleteOldRDN());
@@ -479,7 +479,7 @@
.valueOf("ou=PD Accountants, ou=Product Development, dc=airius, dc=com");
Assert.assertEquals(modifyDN.getDN(), dn);
- rdn = RDN.decode("ou=Product Development Accountants");
+ rdn = RDN.valueOf("ou=Product Development Accountants");
Assert.assertEquals(modifyDN.getNewRDN(), rdn);
dn = DN.valueOf("ou=Accounting, dc=airius, dc=com");
Assert.assertEquals(modifyDN.getNewSuperiorDN(), dn);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/util/TestModifyDNChangeRecordEntry.java b/opendj-server-legacy/src/test/java/org/opends/server/util/TestModifyDNChangeRecordEntry.java
index 04db152..e3f2f35 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/util/TestModifyDNChangeRecordEntry.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/util/TestModifyDNChangeRecordEntry.java
@@ -12,7 +12,7 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS.
+ * Portions Copyright 2014-2016 ForgeRock AS.
*/
package org.opends.server.util;
@@ -49,7 +49,7 @@
TestCaseUtils.startServer();
newSuperiorDN = DN.valueOf("dc=com");
- newRDN = RDN.decode("dc=foo");
+ newRDN = RDN.valueOf("dc=foo");
}
/**
--
Gitblit v1.10.0