From dfbe880eb338a1d752ce790f689b5133761d7079 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 26 Sep 2013 07:35:55 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java               |   22 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java  |   82 +-
 opends/src/server/org/opends/server/replication/protocol/LDAPUpdateMsg.java                                      |   41 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java        |   58 
 opends/src/server/org/opends/server/replication/plugin/FakeDelOperation.java                                     |    5 
 opends/src/server/org/opends/server/replication/server/ServerWriter.java                                         |   14 
 opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java                                       |    9 
 opends/src/server/org/opends/server/replication/server/ECLServerHandler.java                                     |   31 
 opends/src/server/org/opends/server/replication/plugin/FakeAddOperation.java                                     |    2 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java                      |    8 
 opends/src/server/org/opends/server/replication/protocol/InitializeTargetMsg.java                                |   40 
 opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java                                     |   34 
 opends/src/server/org/opends/server/replication/server/MessageHandler.java                                       |   12 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java                  |  129 +--
 opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java                                          |   21 
 opends/src/server/org/opends/server/replication/server/ServerReader.java                                         |   12 
 opends/src/server/org/opends/server/replication/protocol/InitializeRequestMsg.java                               |   38 
 opends/src/server/org/opends/server/replication/service/ReplicationDomain.java                                   |    4 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java                          |   14 
 opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java                    |   45 
 opends/src/server/org/opends/server/replication/server/ECLServerWriter.java                                      |    4 
 opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java                                |   90 +-
 opends/src/server/org/opends/server/replication/plugin/FakeModdnOperation.java                                   |    2 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java |   32 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java             |   10 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java                    |    2 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java |   33 
 opends/src/server/org/opends/server/replication/protocol/ReplServerStartDSMsg.java                               |   36 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java    |   49 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java               |   26 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java     |  139 +--
 opends/src/server/org/opends/server/replication/server/ReplicationBackend.java                                   |    4 
 opends/src/server/org/opends/server/replication/server/ServerHandler.java                                        |    4 
 opends/src/server/org/opends/server/replication/service/ReplicationBroker.java                                   |   36 
 opends/src/server/org/opends/server/replication/protocol/ReplServerStartMsg.java                                 |   49 
 opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java                             |    5 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java                  |   16 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/DbHandlerTest.java   |   34 
 opends/src/server/org/opends/server/replication/protocol/AddMsg.java                                             |   22 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java    |   42 
 opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java                                        |   18 
 opends/src/server/org/opends/server/replication/server/DataServerHandler.java                                    |   23 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java                 |  314 +++-----
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java                      |  126 +-
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java           |   58 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java                 |   11 
 opends/src/server/org/opends/server/replication/plugin/PendingChange.java                                        |   12 
 opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java                                    |   23 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java        |  252 ++----
 opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java                                          |   21 
 50 files changed, 960 insertions(+), 1,154 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/FakeAddOperation.java b/opends/src/server/org/opends/server/replication/plugin/FakeAddOperation.java
index e1113ea..357d7e8 100644
--- a/opends/src/server/org/opends/server/replication/plugin/FakeAddOperation.java
+++ b/opends/src/server/org/opends/server/replication/plugin/FakeAddOperation.java
@@ -61,7 +61,7 @@
   @Override
   public AddMsg generateMessage()
   {
-    return new AddMsg(getCSN(), entry.getDN().toString(),
+    return new AddMsg(getCSN(), entry.getDN(),
                EntryHistorical.getEntryUUID(entry),
                LDAPReplicationDomain.findEntryUUID(
                    entry.getDN().getParentDNInSuffix()),
diff --git a/opends/src/server/org/opends/server/replication/plugin/FakeDelOperation.java b/opends/src/server/org/opends/server/replication/plugin/FakeDelOperation.java
index 0e9d604..48b2977 100644
--- a/opends/src/server/org/opends/server/replication/plugin/FakeDelOperation.java
+++ b/opends/src/server/org/opends/server/replication/plugin/FakeDelOperation.java
@@ -30,6 +30,7 @@
 import org.opends.server.replication.common.CSN;
 import org.opends.server.replication.protocol.DeleteMsg;
 import org.opends.server.replication.protocol.ReplicationMsg;
+import org.opends.server.types.DN;
 
 /**
  * This class if used to build pseudo DEL Operation from the historical
@@ -40,7 +41,7 @@
  */
 public class FakeDelOperation extends FakeOperation
 {
-  private final String dn;
+  private final DN dn;
   private final String entryUUID;
 
   /**
@@ -50,7 +51,7 @@
    * @param csn   The CSN of the operation.
    * @param entryUUID      The Unique ID of the deleted entry.
    */
-  public FakeDelOperation(String dn, CSN csn, String entryUUID)
+  public FakeDelOperation(DN dn, CSN csn, String entryUUID)
   {
     super(csn);
     this.dn = dn;
diff --git a/opends/src/server/org/opends/server/replication/plugin/FakeModdnOperation.java b/opends/src/server/org/opends/server/replication/plugin/FakeModdnOperation.java
index 69e0eef..0eb2a3d 100644
--- a/opends/src/server/org/opends/server/replication/plugin/FakeModdnOperation.java
+++ b/opends/src/server/org/opends/server/replication/plugin/FakeModdnOperation.java
@@ -63,7 +63,7 @@
   public ReplicationMsg generateMessage()
   {
     DN dn = entry.getDN();
-    return new ModifyDNMsg(dn.toString(), getCSN(),
+    return new ModifyDNMsg(dn, getCSN(),
         EntryHistorical.getEntryUUID(entry),
         LDAPReplicationDomain.findEntryUUID(dn.getParent()),
         false, dn.getParent().toString(), dn.getRDN().toString());
diff --git a/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index c4f9497..f8d1c64 100644
--- a/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -1729,11 +1729,9 @@
         {
           replayOperations.remove(replayOperations.firstKey());
         }
-        replayOperations.put(
-            csn,
-            new FakeDelOperation(
-                deleteOperation.getEntryDN().toString(),
-                csn, modifiedEntryUUID));
+        FakeOperation op = new FakeDelOperation(
+            deleteOperation.getEntryDN(), csn, modifiedEntryUUID);
+        replayOperations.put(csn, op);
       }
 
     }
@@ -2791,7 +2789,7 @@
       {
         // There is an entry with the same unique id as this modify operation
         // replay the modify using the current dn of this entry.
-        msg.setDn(newDN.toString());
+        msg.setDN(newDN);
         numResolvedNamingConflicts.incrementAndGet();
         return false;
       }
@@ -2878,8 +2876,8 @@
      /*
       * Find if the entry is still in the database.
       */
-     DN currentDn = findEntryDN(entryUUID);
-     if (currentDn == null)
+     DN currentDN = findEntryDN(entryUUID);
+     if (currentDN == null)
      {
        /*
         * The entry has already been deleted, either because this delete
@@ -2892,10 +2890,8 @@
      }
      else
      {
-       /*
-        * This entry has been renamed, replay the delete using its new DN.
-        */
-       msg.setDn(currentDn.toString());
+       // This entry has been renamed, replay the delete using its new DN.
+       msg.setDN(currentDN);
        numResolvedNamingConflicts.incrementAndGet();
        return false;
      }
@@ -2911,7 +2907,6 @@
       * The action taken here must be consistent with the actions
       * done in the solveNamingConflict(AddOperation) method
       * when we are adding an entry whose parent entry has already been deleted.
-      *
       */
      if (findAndRenameChild(op.getEntryDN(), op))
      {
@@ -3020,7 +3015,7 @@
      * reconstruct the operation with the DN we just built
      */
     ModifyDNMsg modifyDnMsg = (ModifyDNMsg) msg;
-    msg.setDn(currentDN.toString());
+    modifyDnMsg.setDN(currentDN);
     modifyDnMsg.setNewSuperior(newSuperior.toString());
     numResolvedNamingConflicts.incrementAndGet();
     return false;
@@ -3099,8 +3094,9 @@
          */
         addConflict(msg);
 
-        msg.setDn(generateConflictRDN(entryUUID,
-            op.getEntryDN().getRDN().toString()) + "," + getBaseDNString());
+        String conflictRDN =
+            generateConflictRDN(entryUUID, op.getEntryDN().getRDN().toString());
+        msg.setDN(DN.decode(conflictRDN + "," + getBaseDNString()));
         // reset the parent entryUUID so that the check done is the
         // handleConflict phase does not fail.
         msg.setParentEntryUUID(null);
@@ -3108,8 +3104,7 @@
       }
       else
       {
-        RDN entryRdn = DN.decode(msg.getDn()).getRDN();
-        msg.setDn(entryRdn + "," + parentDn);
+        msg.setDN(DN.decode(msg.getDN().getRDN() + "," + parentDn));
         numResolvedNamingConflicts.incrementAndGet();
       }
       return false;
@@ -3133,7 +3128,9 @@
       else
       {
         addConflict(msg);
-        msg.setDn(generateConflictRDN(entryUUID, msg.getDn()));
+        String conflictRDN =
+            generateConflictRDN(entryUUID, msg.getDN().toNormalizedString());
+        msg.setDN(DN.decode(conflictRDN));
         numUnresolvedNamingConflicts.incrementAndGet();
         return false;
       }
@@ -3152,7 +3149,7 @@
 
   /**
    * Find all the entries below the provided DN and rename them
-   * so that they stay below the baseDn of this replicationDomain and
+   * so that they stay below the baseDN of this replicationDomain and
    * use the conflicting name and attribute.
    *
    * @param entryDN    The DN of the entry whose child must be renamed.
@@ -3229,7 +3226,7 @@
 
   /**
    * Rename an entry that was conflicting so that it stays below the
-   * baseDn of the replicationDomain.
+   * baseDN of the replicationDomain.
    *
    * @param conflictOp The Operation that caused the conflict.
    * @param dn         The DN of the entry to be renamed.
@@ -3313,14 +3310,7 @@
    */
   private void addConflict(AddMsg msg) throws ASN1Exception
   {
-    String normalizedDN;
-    try
-    {
-      normalizedDN = DN.decode(msg.getDn()).toNormalizedString();
-    } catch (DirectoryException e)
-    {
-      normalizedDN = msg.getDn();
-    }
+    String normalizedDN = msg.getDN().toNormalizedString();
 
     // Generate an alert to let the administrator know that some
     // conflict could not be solved.
@@ -3763,7 +3753,7 @@
       os = output;
     }
 
-    // baseDn branch is the only one included in the export
+    // baseDN branch is the only one included in the export
     List<DN> includeBranches = new ArrayList<DN>(1);
     includeBranches.add(getBaseDN());
     LDIFExportConfig exportConfig = new LDIFExportConfig(os);
@@ -4007,15 +3997,15 @@
   }
 
   /**
-   * Retrieves a replication domain based on the baseDn.
+   * Retrieves a replication domain based on the baseDN.
    *
-   * @param baseDn The baseDn of the domain to retrieve
+   * @param baseDN The baseDN of the domain to retrieve
    * @return The domain retrieved
    * @throws DirectoryException When an error occurred or no domain
-   * match the provided baseDn.
+   * match the provided baseDN.
    */
-  public static LDAPReplicationDomain retrievesReplicationDomain(DN baseDn)
-  throws DirectoryException
+  public static LDAPReplicationDomain retrievesReplicationDomain(DN baseDN)
+      throws DirectoryException
   {
     LDAPReplicationDomain replicationDomain = null;
 
@@ -4031,7 +4021,7 @@
 
       // From the domainDN retrieves the replication domain
       LDAPReplicationDomain domain =
-        MultimasterReplication.findDomain(baseDn, null);
+        MultimasterReplication.findDomain(baseDN, null);
       if (domain == null)
       {
         break;
@@ -4048,7 +4038,7 @@
     if (replicationDomain == null)
     {
       throw new DirectoryException(ResultCode.OTHER,
-          ERR_NO_MATCHING_DOMAIN.get(String.valueOf(baseDn)));
+          ERR_NO_MATCHING_DOMAIN.get(String.valueOf(baseDN)));
     }
     return replicationDomain;
   }
@@ -4528,7 +4518,7 @@
    * attribute. The only changes that will be send will be the one generated on
    * the serverId provided in fromCSN.
    *
-   * @param baseDn
+   * @param baseDN
    *          the base DN
    * @param fromCSN
    *          The CSN from which we want the changes
@@ -4540,7 +4530,7 @@
    * @throws Exception
    *           when raised.
    */
-  private static InternalSearchOperation searchForChangedEntries(DN baseDn,
+  private static InternalSearchOperation searchForChangedEntries(DN baseDN,
       CSN fromCSN, CSN lastCSN, InternalSearchListener resultListener)
       throws Exception
   {
@@ -4564,7 +4554,7 @@
           "(" + HISTORICAL_ATTRIBUTE_NAME + "<=dummy:" + maxValueForId + "))");
 
     return conn.processSearch(
-      ByteString.valueOf(baseDn.toString()),
+      ByteString.valueOf(baseDN.toString()),
       SearchScope.WHOLE_SUBTREE,
       DereferencePolicy.NEVER_DEREF_ALIASES,
       0, 0, false, filter,
@@ -4577,7 +4567,7 @@
    * attribute. The only changes that will be send will be the one generated on
    * the serverId provided in fromCSN.
    *
-   * @param baseDn
+   * @param baseDN
    *          the base DN
    * @param fromCSN
    *          The CSN from which we want the changes
@@ -4587,10 +4577,10 @@
    * @throws Exception
    *           when raised.
    */
-  public static InternalSearchOperation searchForChangedEntries(DN baseDn,
+  public static InternalSearchOperation searchForChangedEntries(DN baseDN,
       CSN fromCSN, InternalSearchListener resultListener) throws Exception
   {
-    return searchForChangedEntries(baseDn, fromCSN, null, resultListener);
+    return searchForChangedEntries(baseDN, fromCSN, null, resultListener);
   }
 
 
@@ -4933,15 +4923,15 @@
     /**
      * Base DN the fractional configuration is for.
      */
-    private DN baseDn;
+    private DN baseDN;
 
     /**
      * Constructs a new fractional configuration object.
-     * @param baseDn The base dn the object is for.
+     * @param baseDN The base DN the object is for.
      */
-    FractionalConfig(DN baseDn)
+    FractionalConfig(DN baseDN)
     {
-      this.baseDn = baseDn;
+      this.baseDN = baseDN;
     }
 
     /**
@@ -5022,12 +5012,12 @@
     }
 
     /**
-     * Getter for the base baseDn.
-     * @return The baseDn attribute.
+     * Getter for the base baseDN.
+     * @return The baseDN attribute.
      */
     DN getBaseDn()
     {
-      return baseDn;
+      return baseDN;
     }
 
     /**
diff --git a/opends/src/server/org/opends/server/replication/plugin/PendingChange.java b/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
index b261419..9d9503a 100644
--- a/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
+++ b/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
@@ -31,7 +31,6 @@
 import org.opends.server.replication.common.ServerState;
 import org.opends.server.replication.protocol.LDAPUpdateMsg;
 import org.opends.server.types.DN;
-import org.opends.server.types.DirectoryException;
 import org.opends.server.types.operation.PluginOperation;
 
 /**
@@ -164,16 +163,9 @@
   {
     synchronized (this)
     {
-      if (targetDN != null)
+      if (targetDN == null)
       {
-        return targetDN;
-      }
-      try
-      {
-        targetDN = DN.decode(msg.getDn());
-      }
-      catch (DirectoryException e)
-      {
+        targetDN = msg.getDN();
       }
       return targetDN;
     }
diff --git a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
index b63a095..c6ea471 100644
--- a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
@@ -28,12 +28,12 @@
 package org.opends.server.replication.protocol;
 
 import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.zip.DataFormatException;
 
+import org.opends.server.core.AddOperation;
 import org.opends.server.core.AddOperationBasis;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.asn1.ASN1;
@@ -67,8 +67,7 @@
    */
   public AddMsg(PostOperationAddOperation op)
   {
-    super((AddContext) op.getAttachment(SYNCHROCONTEXT),
-          op.getRawEntryDN().toString());
+    super((AddContext) op.getAttachment(SYNCHROCONTEXT), op.getEntryDN());
 
     AddContext ctx = (AddContext) op.getAttachment(SYNCHROCONTEXT);
 
@@ -93,7 +92,7 @@
    * @param operationalAttributes operational attributes of the added entry.
    */
   public AddMsg(CSN csn,
-                String dn,
+                DN dn,
                 String entryUUID,
                 String parentEntryUUID,
                 Map<ObjectClass, String> objectClasses,
@@ -123,7 +122,7 @@
    * @param operationalAttributes operational attributes of the added entry.
    */
   public AddMsg(CSN csn,
-                String dn,
+                DN dn,
                 String uniqueId,
                 String parentId,
                 Attribute objectClass,
@@ -172,16 +171,16 @@
    * {@inheritDoc}
    */
   @Override
-  public AddOperationBasis createOperation(
-      InternalClientConnection connection, String newDn)
+  public AddOperation createOperation(
+      InternalClientConnection connection, DN newDN)
   throws LDAPException, ASN1Exception
   {
-    ArrayList<RawAttribute> attr = decodeRawAttributes(encodedAttributes);
+    List<RawAttribute> attr = decodeRawAttributes(encodedAttributes);
 
-    AddOperationBasis add =  new AddOperationBasis(connection,
+    AddOperation add =  new AddOperationBasis(connection,
         InternalClientConnection.nextOperationID(),
         InternalClientConnection.nextMessageID(), null,
-        ByteString.valueOf(newDn), attr);
+        ByteString.valueOf(newDN.toString()), attr);
     AddContext ctx = new AddContext(getCSN(), getEntryUUID(),
         parentEntryUUID);
     add.setAttachment(SYNCHROCONTEXT, ctx);
@@ -579,8 +578,7 @@
   @Override
   public int size()
   {
-    return encodedAttributes.length + + encodedEclIncludes.length
-      + headerSize();
+    return encodedAttributes.length + encodedEclIncludes.length + headerSize();
   }
 
 }
diff --git a/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java b/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
index 2f8b64e..2a86679 100644
--- a/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
@@ -27,19 +27,19 @@
  */
 package org.opends.server.replication.protocol;
 
-import static org.opends.server.replication.protocol.OperationContext.*;
-
 import java.io.UnsupportedEncodingException;
 import java.util.zip.DataFormatException;
 
 import org.opends.server.controls.SubtreeDeleteControl;
+import org.opends.server.core.DeleteOperation;
 import org.opends.server.core.DeleteOperationBasis;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.replication.common.CSN;
-import org.opends.server.types.ByteString;
-import org.opends.server.types.Operation;
+import org.opends.server.types.DN;
 import org.opends.server.types.operation.PostOperationDeleteOperation;
 
+import static org.opends.server.replication.protocol.OperationContext.*;
+
 /**
  * Object used when sending delete information to replication servers.
  */
@@ -58,7 +58,7 @@
   public DeleteMsg(PostOperationDeleteOperation operation)
   {
     super((OperationContext) operation.getAttachment(SYNCHROCONTEXT),
-           operation.getRawEntryDN().toString());
+           operation.getEntryDN());
     try
     {
       if (operation.getRequestControl(SubtreeDeleteControl.DECODER) != null)
@@ -75,7 +75,7 @@
    * @param csn          The CSN with which the message must be created.
    * @param entryUUID    The unique id with which the message must be created.
    */
-  public DeleteMsg(String dn, CSN csn, String entryUUID)
+  public DeleteMsg(DN dn, CSN csn, String entryUUID)
   {
     super(new DeleteContext(csn, entryUUID), dn);
   }
@@ -111,13 +111,12 @@
    * {@inheritDoc}
    */
   @Override
-  public Operation createOperation(InternalClientConnection connection,
-      String newDn)
+  public DeleteOperation createOperation(InternalClientConnection connection,
+      DN newDN)
   {
-    DeleteOperationBasis del =  new DeleteOperationBasis(connection,
+    DeleteOperation del =  new DeleteOperationBasis(connection,
         InternalClientConnection.nextOperationID(),
-        InternalClientConnection.nextMessageID(), null,
-        ByteString.valueOf(newDn));
+        InternalClientConnection.nextMessageID(), null, newDN);
 
     if (isSubtreeDelete)
       del.addRequestControl(new SubtreeDeleteControl(false));
diff --git a/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java b/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java
index db47298..d06b6af 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java
@@ -31,6 +31,7 @@
 import java.util.zip.DataFormatException;
 
 import org.opends.server.replication.common.MultiDomainServerState;
+import org.opends.server.types.DN;
 import org.opends.server.types.DirectoryException;
 
 /**
@@ -43,7 +44,7 @@
   private final LDAPUpdateMsg updateMsg;
 
   /** The baseDN of the domain to which applies the change. */
-  private final String baseDN;
+  private final DN baseDN;
 
   /** The value of the cookie updated with the current change. */
   private MultiDomainServerState cookie;
@@ -59,7 +60,7 @@
    * @param changeNumber The provided change number.
    */
   public ECLUpdateMsg(LDAPUpdateMsg updateMsg, MultiDomainServerState cookie,
-      String baseDN, long changeNumber)
+      DN baseDN, long changeNumber)
   {
     this.cookie = cookie;
     this.baseDN = baseDN;
@@ -98,7 +99,7 @@
 
       // Decode the baseDN
       length = getNextLength(in, pos);
-      this.baseDN = new String(in, pos, length, "UTF-8");
+      this.baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length + 1;
 
       // Decode the changeNumber
@@ -148,7 +149,7 @@
    *
    * @return The baseDN.
    */
-  public String getBaseDN()
+  public DN getBaseDN()
   {
     return baseDN;
   }
diff --git a/opends/src/server/org/opends/server/replication/protocol/InitializeRequestMsg.java b/opends/src/server/org/opends/server/replication/protocol/InitializeRequestMsg.java
index 06d307c..0b99451 100644
--- a/opends/src/server/org/opends/server/replication/protocol/InitializeRequestMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/InitializeRequestMsg.java
@@ -41,22 +41,22 @@
  */
 public class InitializeRequestMsg extends RoutableMsg
 {
-  private String baseDn = null;
+  private DN baseDN;
   private int initWindow = 0;
 
   /**
    * Creates a InitializeRequestMsg message.
    *
-   * @param baseDn      the base DN of the replication domain.
+   * @param baseDN      the base DN of the replication domain.
    * @param destination destination of this message
    * @param serverID    serverID of the server that will send this message
    * @param initWindow  initialization window for flow control
    */
-  public InitializeRequestMsg(String baseDn, int serverID, int destination,
+  public InitializeRequestMsg(DN baseDN, int serverID, int destination,
       int initWindow)
   {
     super(serverID, destination);
-    this.baseDn = baseDn;
+    this.baseDN = baseDN;
     this.initWindow = initWindow; // V4
   }
 
@@ -79,9 +79,9 @@
             "input is not a valid InitializeRequestMessage");
       int pos = 1;
 
-      // baseDn
+      // baseDN
       int length = getNextLength(in, pos);
-      baseDn = new String(in, pos, length, "UTF-8");
+      baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length +1;
 
       // sender
@@ -104,10 +104,15 @@
         initWindow = Integer.valueOf(initWindowString);
         pos += length +1;
       }
-    } catch (UnsupportedEncodingException e)
+    }
+    catch (UnsupportedEncodingException e)
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
@@ -115,17 +120,9 @@
    *
    * @return the base DN from this InitializeRequestMsg.
    */
-  public DN getBaseDn()
+  public DN getBaseDN()
   {
-    if (baseDn == null)
-      return null;
-    try
-    {
-      return DN.decode(baseDn);
-    } catch (DirectoryException e)
-    {
-      return null;
-    }
+    return baseDN;
   }
 
   // ============
@@ -139,7 +136,7 @@
   public byte[] getBytes(short version)
   {
     try {
-      byte[] baseDNBytes = baseDn.getBytes("UTF-8");
+      byte[] baseDNBytes = baseDN.toString().getBytes("UTF-8");
       byte[] senderBytes = String.valueOf(senderID).getBytes("UTF-8");
       byte[] destinationBytes = String.valueOf(destination).getBytes("UTF-8");
       byte[] initWindowBytes = null;
@@ -186,10 +183,11 @@
    * Get a string representation of this object.
    * @return A string representation of this object.
    */
+  @Override
   public String toString()
   {
-    return "InitializeRequestMessage: baseDn="+baseDn+" senderId="+senderID +
-    " destination=" + destination + " initWindow=" + initWindow;
+    return "InitializeRequestMessage: baseDN=" + baseDN + " senderId="
+       + senderID + " destination=" + destination + " initWindow=" + initWindow;
   }
 
   /**
diff --git a/opends/src/server/org/opends/server/replication/protocol/InitializeTargetMsg.java b/opends/src/server/org/opends/server/replication/protocol/InitializeTargetMsg.java
index e433e83..6194c85 100644
--- a/opends/src/server/org/opends/server/replication/protocol/InitializeTargetMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/InitializeTargetMsg.java
@@ -30,6 +30,9 @@
 import java.io.UnsupportedEncodingException;
 import java.util.zip.DataFormatException;
 
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+
 /**
  * This message is part of the replication protocol.
  * This message is sent by a server to one or several servers as the
@@ -37,15 +40,16 @@
  */
 public class InitializeTargetMsg extends RoutableMsg
 {
-  private String baseDN = null;
+  private DN baseDN;
 
-  // Specifies the number of entries expected to be exported.
+  /** Specifies the number of entries expected to be exported. */
   private long entryCount;
 
-  // Specifies the serverID of the server that requested this export
-  // to happen. It allows a server that previously sent an
-  // InitializeRequestMessage to know that the current message
-  // is related to its own request.
+  /**
+   * Specifies the serverID of the server that requested this export to happen.
+   * It allows a server that previously sent an InitializeRequestMessage to know
+   * that the current message is related to its own request.
+   */
   private int requestorID;
 
   private int initWindow;
@@ -55,16 +59,16 @@
    *
    * @param baseDN     The base DN for which the InitializeMessage is created.
    * @param serverID   The serverID of the server that sends this message.
-   * @param target     The destination of this message.
-   * @param target2    The server that initiates this export.
+   * @param destination     The destination of this message.
+   * @param requestorID    The server that initiates this export.
    * @param entryCount The count of entries that will be sent.
    * @param initWindow the initialization window.
    */
-  public InitializeTargetMsg(String baseDN, int serverID,
-      int target, int target2, long entryCount, int initWindow)
+  public InitializeTargetMsg(DN baseDN, int serverID,
+      int destination, int requestorID, long entryCount, int initWindow)
   {
-    super(serverID, target);
-    this.requestorID = target2;
+    super(serverID, destination);
+    this.requestorID = requestorID;
     this.baseDN = baseDN;
     this.entryCount = entryCount;
     this.initWindow = initWindow; // V4
@@ -95,9 +99,9 @@
       this.destination = Integer.valueOf(destinationString);
       pos += length +1;
 
-      // baseDn
+      // baseDN
       length = getNextLength(in, pos);
-      baseDN = new String(in, pos, length, "UTF-8");
+      baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length +1;
 
       // sender
@@ -131,6 +135,10 @@
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
@@ -159,7 +167,7 @@
    *
    * @return the base DN
    */
-  public String getBaseDN()
+  public DN getBaseDN()
   {
     return this.baseDN;
   }
@@ -188,7 +196,7 @@
     try
     {
       byte[] byteDestination = String.valueOf(destination).getBytes("UTF-8");
-      byte[] byteDn = baseDN.getBytes("UTF-8");
+      byte[] byteDn = baseDN.toString().getBytes("UTF-8");
       byte[] byteSender = String.valueOf(senderID).getBytes("UTF-8");
       byte[] byteRequestor = String.valueOf(requestorID).getBytes("UTF-8");
       byte[] byteEntryCount = String.valueOf(entryCount).getBytes("UTF-8");
diff --git a/opends/src/server/org/opends/server/replication/protocol/LDAPUpdateMsg.java b/opends/src/server/org/opends/server/replication/protocol/LDAPUpdateMsg.java
index 20cfc5f..b27f8b8 100644
--- a/opends/src/server/org/opends/server/replication/protocol/LDAPUpdateMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/LDAPUpdateMsg.java
@@ -52,7 +52,7 @@
   /**
    * The DN on which the update was originally done.
    */
-  protected String dn;
+  protected DN dn;
 
   /**
    * The entryUUID of the entry that was updated.
@@ -84,7 +84,7 @@
    * @param dn The DN of the entry on which the change
    *           that caused the creation of this object happened
    */
-  public LDAPUpdateMsg(OperationContext ctx, String dn)
+  public LDAPUpdateMsg(OperationContext ctx, DN dn)
   {
     this.protocolVersion = ProtocolVersion.getCurrentVersion();
     this.csn = ctx.getCSN();
@@ -102,7 +102,7 @@
    * @param dn        The DN of the entry on which the change
    *                  that caused the creation of this object happened
    */
-  public LDAPUpdateMsg(CSN csn, String entryUUID, String dn)
+  public LDAPUpdateMsg(CSN csn, String entryUUID, DN dn)
   {
     this.protocolVersion = ProtocolVersion.getCurrentVersion();
     this.csn = csn;
@@ -146,7 +146,7 @@
    *
    * @return The DN on which the operations happened.
    */
-  public String getDn()
+  public DN getDN()
   {
     return dn;
   }
@@ -155,7 +155,7 @@
    * Set the DN.
    * @param dn The dn that must now be used for this message.
    */
-  public void setDn(String dn)
+  public void setDN(DN dn)
   {
     this.dn = dn;
   }
@@ -190,14 +190,14 @@
    * Create and Operation from the message using the provided DN.
    *
    * @param   conn connection to use when creating the message.
-   * @param   newDn the DN to use when creating the operation.
+   * @param   newDN the DN to use when creating the operation.
    * @return  the created Operation.
    * @throws  LDAPException In case of LDAP decoding exception.
    * @throws  ASN1Exception In case of ASN1 decoding exception.
    * @throws DataFormatException In case of bad msg format.
    */
   public abstract Operation createOperation(InternalClientConnection conn,
-      String newDn) throws LDAPException, ASN1Exception, DataFormatException;
+      DN newDN) throws LDAPException, ASN1Exception, DataFormatException;
 
 
   // ============
@@ -237,7 +237,7 @@
   public byte[] encodeHeader(byte type, int additionalLength, short version)
     throws UnsupportedEncodingException
   {
-    byte[] byteDn = dn.getBytes("UTF-8");
+    byte[] byteDn = dn.toString().getBytes("UTF-8");
     byte[] csnByte = getCSN().toString().getBytes("UTF-8");
     byte[] byteEntryuuid = getEntryUUID().getBytes("UTF-8");
 
@@ -297,7 +297,7 @@
   public byte[] encodeHeader_V1(byte type, int additionalLength)
     throws UnsupportedEncodingException
   {
-    byte[] byteDn = dn.getBytes("UTF-8");
+    byte[] byteDn = dn.toString().getBytes("UTF-8");
     byte[] csnByte = getCSN().toString().getBytes("UTF-8");
     byte[] byteEntryuuid = getEntryUUID().getBytes("UTF-8");
 
@@ -474,7 +474,7 @@
 
        // Read the dn
        length = getNextLength(encodedMsg, pos);
-       dn = new String(encodedMsg, pos, length, "UTF-8");
+       dn = DN.decode(new String(encodedMsg, pos, length, "UTF-8"));
        pos += length + 1;
 
        // Read the entryuuid
@@ -492,12 +492,18 @@
        safeDataLevel = encodedMsg[pos++];
 
        return pos;
-     } catch (UnsupportedEncodingException e)
+     }
+     catch (UnsupportedEncodingException e)
      {
        throw new DataFormatException("UTF-8 is not supported by this jvm.");
-     } catch (IllegalArgumentException e)
+     }
+     catch (IllegalArgumentException e)
      {
-       throw new DataFormatException(e.getMessage());
+       throw new DataFormatException(e.getLocalizedMessage());
+     }
+     catch (DirectoryException e)
+     {
+       throw new DataFormatException(e.getLocalizedMessage());
      }
   }
 
@@ -539,7 +545,7 @@
 
       // read the dn
       length = getNextLength(encodedMsg, pos);
-      dn = new String(encodedMsg, pos, length, "UTF-8");
+      dn = DN.decode(new String(encodedMsg, pos, length, "UTF-8"));
       pos += length + 1;
 
       // read the entryuuid
@@ -548,10 +554,15 @@
       pos += length + 1;
 
       return pos;
-    } catch (UnsupportedEncodingException e)
+    }
+    catch (UnsupportedEncodingException e)
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
index 70f9fef..6033fa2 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
@@ -66,7 +66,7 @@
    * @param dn The DN of the entry on which the change
    *           that caused the creation of this object happened
    */
-  public ModifyCommonMsg(OperationContext ctx, String dn)
+  public ModifyCommonMsg(OperationContext ctx, DN dn)
   {
    super(ctx, dn);
   }
@@ -81,7 +81,7 @@
    * @param dn        The DN of the entry on which the change
    *                  that caused the creation of this object happened
    */
-  public ModifyCommonMsg(CSN csn, String entryUUID, String dn)
+  public ModifyCommonMsg(CSN csn, String entryUUID, DN dn)
   {
     super(csn, entryUUID, dn);
   }
@@ -104,14 +104,7 @@
    */
   public List<Modification> getMods() throws ASN1Exception, LDAPException
   {
-    List<Modification> mods = new ArrayList<Modification>();
-
-    ASN1Reader reader = ASN1.getReader(encodedMods);
-
-    while (reader.hasNextElement())
-      mods.add((LDAPModification.decode(reader)).toModification());
-
-    return mods;
+    return decodeMods(encodedMods);
   }
 
   // ============
@@ -175,8 +168,8 @@
    * @throws LDAPException when occurs.
    * @return The decoded mods.
    */
-  protected List<Modification> decodeMods(byte[] in)
-  throws ASN1Exception, LDAPException
+  protected List<Modification> decodeMods(byte[] in) throws ASN1Exception,
+      LDAPException
   {
     List<Modification> mods = new ArrayList<Modification>();
     ASN1Reader reader = ASN1.getReader(in);
@@ -194,10 +187,10 @@
    * @throws ASN1Exception when occurs.
    * @throws LDAPException when occurs.
    */
-  protected ArrayList<RawModification> decodeRawMods(byte[] in)
-  throws LDAPException, ASN1Exception
+  protected List<RawModification> decodeRawMods(byte[] in)
+      throws LDAPException, ASN1Exception
   {
-    ArrayList<RawModification> ldapmods = new ArrayList<RawModification>();
+    List<RawModification> ldapmods = new ArrayList<RawModification>();
     ASN1Reader asn1Reader = ASN1.getReader(in);
     while(asn1Reader.hasNextElement())
     {
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
index f0ea42e..ca16cd2 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
@@ -31,6 +31,7 @@
 import java.util.List;
 import java.util.zip.DataFormatException;
 
+import org.opends.server.core.ModifyDNOperation;
 import org.opends.server.core.ModifyDNOperationBasis;
 import org.opends.server.protocols.asn1.ASN1Exception;
 import org.opends.server.protocols.internal.InternalClientConnection;
@@ -58,7 +59,7 @@
   public ModifyDNMsg(PostOperationModifyDNOperation operation)
   {
     super((OperationContext) operation.getAttachment(SYNCHROCONTEXT),
-        operation.getRawEntryDN().toString());
+        operation.getEntryDN());
 
     encodedMods = encodeMods(operation.getModifications());
 
@@ -89,7 +90,7 @@
    * @param newSuperior  The new Superior entry to use for building the message.
    * @param newRDN       The new Rdn to use for building the message.
    */
-  public ModifyDNMsg(String dn, CSN csn, String entryUUID,
+  public ModifyDNMsg(DN dn, CSN csn, String entryUUID,
                      String newSuperiorEntryUUID, boolean deleteOldRdn,
                      String newSuperior, String newRDN)
   {
@@ -115,7 +116,7 @@
    * @param newRDN       The new Rdn to use for building the message.
    * @param mods         The mod of the operation.
    */
-  public ModifyDNMsg(String dn, CSN csn, String entryUUID,
+  public ModifyDNMsg(DN dn, CSN csn, String entryUUID,
       String newSuperiorEntryUUID, boolean deleteOldRdn, String newSuperior,
       String newRDN, List<Modification> mods)
   {
@@ -158,13 +159,14 @@
    * {@inheritDoc}
    */
   @Override
-  public Operation createOperation(InternalClientConnection connection,
-      String newDn) throws LDAPException, ASN1Exception
+  public ModifyDNOperation createOperation(InternalClientConnection connection,
+      DN newDN) throws LDAPException, ASN1Exception
   {
-    ModifyDNOperationBasis moddn =  new ModifyDNOperationBasis(connection,
+    ModifyDNOperation moddn =  new ModifyDNOperationBasis(connection,
         InternalClientConnection.nextOperationID(),
         InternalClientConnection.nextMessageID(), null,
-        ByteString.valueOf(newDn), ByteString.valueOf(newRDN),
+        ByteString.valueOf(newDN.toString()),
+        ByteString.valueOf(newRDN),
         deleteOldRdn,
         (newSuperior == null ? null : ByteString.valueOf(newSuperior)));
 
@@ -670,7 +672,7 @@
   {
     if (newSuperior == null)
     {
-      DN parentDn = DN.decode(this.getDn()).getParent();
+      DN parentDn = getDN().getParent();
       return parentDn.concat(RDN.decode(newRDN));
     }
     else
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
index 3706f18..b66947a 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
@@ -28,10 +28,10 @@
 package org.opends.server.replication.protocol;
 
 import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.zip.DataFormatException;
 
+import org.opends.server.core.ModifyOperation;
 import org.opends.server.core.ModifyOperationBasis;
 import org.opends.server.protocols.asn1.ASN1Exception;
 import org.opends.server.protocols.internal.InternalClientConnection;
@@ -54,7 +54,7 @@
   public ModifyMsg(PostOperationModifyOperation op)
   {
     super((OperationContext) op.getAttachment(OperationContext.SYNCHROCONTEXT),
-          op.getRawEntryDN().toString());
+          op.getEntryDN());
     encodedMods = encodeMods(op.getModifications());
   }
 
@@ -69,8 +69,7 @@
    */
   public ModifyMsg(CSN csn, DN dn, List<Modification> mods, String entryUUID)
   {
-    super(new ModifyContext(csn, entryUUID),
-          dn.toNormalizedString());
+    super(new ModifyContext(csn, entryUUID), dn);
     this.encodedMods = encodeMods(mods);
   }
 
@@ -127,18 +126,18 @@
    * {@inheritDoc}
    */
   @Override
-  public Operation createOperation(InternalClientConnection connection,
-      String newDn) throws LDAPException, ASN1Exception, DataFormatException
+  public ModifyOperation createOperation(InternalClientConnection connection,
+      DN newDN) throws LDAPException, ASN1Exception, DataFormatException
   {
-    if (newDn == null)
-      newDn = getDn();
+    if (newDN == null)
+      newDN = getDN();
 
-    ArrayList<RawModification> ldapmods = decodeRawMods(encodedMods);
+    List<RawModification> ldapmods = decodeRawMods(encodedMods);
 
-    ModifyOperationBasis mod = new ModifyOperationBasis(connection,
+    ModifyOperation mod = new ModifyOperationBasis(connection,
         InternalClientConnection.nextOperationID(),
         InternalClientConnection.nextMessageID(), null,
-        ByteString.valueOf(newDn), ldapmods);
+        ByteString.valueOf(newDN.toString()), ldapmods);
     ModifyContext ctx = new ModifyContext(getCSN(), getEntryUUID());
     mod.setAttachment(SYNCHROCONTEXT, ctx);
     return mod;
diff --git a/opends/src/server/org/opends/server/replication/protocol/ReplServerStartDSMsg.java b/opends/src/server/org/opends/server/replication/protocol/ReplServerStartDSMsg.java
index 2018214..a4c50a6 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ReplServerStartDSMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ReplServerStartDSMsg.java
@@ -31,6 +31,8 @@
 import java.util.zip.DataFormatException;
 
 import org.opends.server.replication.common.ServerState;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
 
 /**
  * Message sent by a replication server to a directory server in reply to the
@@ -40,7 +42,7 @@
 {
   private int serverId;
   private String serverURL;
-  private String baseDn = null;
+  private DN baseDN;
   private int windowSize;
   private ServerState serverState;
 
@@ -72,9 +74,9 @@
    *
    * @param serverId replication server id
    * @param serverURL replication server URL
-   * @param baseDn base DN for which the ReplServerStartDSMsg is created.
+   * @param baseDN base DN for which the ReplServerStartDSMsg is created.
    * @param windowSize The window size.
-   * @param serverState our ServerState for this baseDn.
+   * @param serverState our ServerState for this baseDN.
    * @param generationId The generationId for this server.
    * @param sslEncryption Whether to continue using SSL to encrypt messages
    *                      after the start messages have been exchanged.
@@ -84,7 +86,7 @@
    * @param connectedDSNumber Number of currently connected DS to the
    *        replication server.
    */
-  public ReplServerStartDSMsg(int serverId, String serverURL, String baseDn,
+  public ReplServerStartDSMsg(int serverId, String serverURL, DN baseDN,
                                int windowSize,
                                ServerState serverState,
                                long generationId,
@@ -97,10 +99,7 @@
     super((short) -1 /* version set when sending */, generationId);
     this.serverId = serverId;
     this.serverURL = serverURL;
-    if (baseDn != null)
-      this.baseDn = baseDn;
-    else
-      this.baseDn = null;
+    this.baseDN = baseDN;
     this.windowSize = windowSize;
     this.serverState = serverState;
     this.sslEncryption = sslEncryption;
@@ -126,7 +125,7 @@
     try
     {
       /* The ReplServerStartDSMsg payload is stored in the form :
-       * <baseDn><serverId><serverURL><windowSize><sslEncryption>
+       * <baseDN><serverId><serverURL><windowSize><sslEncryption>
        * <degradedStatusThreshold><weight><connectedDSNumber>
        * <serverState>
        */
@@ -138,7 +137,7 @@
        * first calculate the length then construct the string
        */
       int length = getNextLength(in, pos);
-      baseDn = new String(in, pos, length, "UTF-8");
+      baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length +1;
 
       /*
@@ -202,10 +201,15 @@
       // the ServerState to be the last. This should be changed and we want to
       // have more than one ServerState field.
       serverState = new ServerState(in, pos, in.length - 1);
-    } catch (UnsupportedEncodingException e)
+    }
+    catch (UnsupportedEncodingException e)
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
@@ -231,9 +235,9 @@
    *
    * @return the base DN from this ReplServerStartDSMsg.
    */
-  public String getBaseDn()
+  public DN getBaseDN()
   {
-    return baseDn;
+    return baseDN;
   }
 
   /**
@@ -253,11 +257,11 @@
      throws UnsupportedEncodingException
   {
     /* The ReplServerStartDSMsg is stored in the form :
-     * <operation type><baseDn><serverId><serverURL><windowSize><sslEncryption>
+     * <operation type><baseDN><serverId><serverURL><windowSize><sslEncryption>
      * <degradedStatusThreshold><weight><connectedDSNumber>
      * <serverState>
      */
-    byte[] byteDn = baseDn.getBytes("UTF-8");
+    byte[] byteDn = baseDN.toString().getBytes("UTF-8");
     byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8");
     byte[] byteServerUrl = serverURL.getBytes("UTF-8");
     byte[] byteServerState = serverState.getBytes();
@@ -362,7 +366,7 @@
     return "ReplServerStartDSMsg content: " +
       "\nprotocolVersion: " + protocolVersion +
       "\ngenerationId: " + generationId +
-      "\nbaseDn: " + baseDn +
+      "\nbaseDN: " + baseDN +
       "\ngroupId: " + groupId +
       "\nserverId: " + serverId +
       "\nserverState: " + serverState +
diff --git a/opends/src/server/org/opends/server/replication/protocol/ReplServerStartMsg.java b/opends/src/server/org/opends/server/replication/protocol/ReplServerStartMsg.java
index faa68cd..4547a9b 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ReplServerStartMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ReplServerStartMsg.java
@@ -31,6 +31,8 @@
 import java.util.zip.DataFormatException;
 
 import org.opends.server.replication.common.ServerState;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
 
 /**
  * Message sent by a replication server to another replication server
@@ -40,7 +42,7 @@
 {
   private Integer serverId;
   private String serverURL;
-  private String baseDn = null;
+  private DN baseDN;
   private int windowSize;
   private ServerState serverState;
 
@@ -70,16 +72,16 @@
    *
    * @param serverId replication server id
    * @param serverURL replication server URL
-   * @param baseDn base DN for which the ReplServerStartMsg is created.
+   * @param baseDN base DN for which the ReplServerStartMsg is created.
    * @param windowSize The window size.
-   * @param serverState our ServerState for this baseDn.
+   * @param serverState our ServerState for this baseDN.
    * @param generationId The generationId for this server.
    * @param sslEncryption Whether to continue using SSL to encrypt messages
    *                      after the start messages have been exchanged.
    * @param groupId The group id of the RS
    * @param degradedStatusThreshold The degraded status threshold
    */
-  public ReplServerStartMsg(int serverId, String serverURL, String baseDn,
+  public ReplServerStartMsg(int serverId, String serverURL, DN baseDN,
                                int windowSize,
                                ServerState serverState,
                                long generationId,
@@ -90,10 +92,7 @@
     super((short) -1 /* version set when sending */, generationId);
     this.serverId = serverId;
     this.serverURL = serverURL;
-    if (baseDn != null)
-      this.baseDn = baseDn;
-    else
-      this.baseDn = null;
+    this.baseDN = baseDN;
     this.windowSize = windowSize;
     this.serverState = serverState;
     this.sslEncryption = sslEncryption;
@@ -127,7 +126,7 @@
     try
     {
       /* The ReplServerStartMsg payload is stored in the form :
-       * <baseDn><serverId><serverURL><windowSize><sslEncryption>
+       * <baseDN><serverId><serverURL><windowSize><sslEncryption>
        * <degradedStatusThreshold><serverState>
        */
 
@@ -138,7 +137,7 @@
        * first calculate the length then construct the string
        */
       int length = getNextLength(in, pos);
-      baseDn = new String(in, pos, length, "UTF-8");
+      baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length +1;
 
       /*
@@ -186,10 +185,15 @@
       // the ServerState to be the last. This should be changed and we want to
       // have more than one ServerState field.
       serverState = new ServerState(in, pos, in.length - 1);
-    } catch (UnsupportedEncodingException e)
+    }
+    catch (UnsupportedEncodingException e)
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
@@ -206,7 +210,7 @@
     try
     {
       /* The ReplServerStartMsg payload is stored in the form :
-       * <baseDn><serverId><serverURL><windowSize><sslEncryption>
+       * <baseDN><serverId><serverURL><windowSize><sslEncryption>
        * <serverState>
        */
 
@@ -214,7 +218,7 @@
        * first calculate the length then construct the string
        */
       int length = getNextLength(in, pos);
-      baseDn = new String(in, pos, length, "UTF-8");
+      baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length +1;
 
       /*
@@ -254,10 +258,15 @@
       // the ServerState to be the last. This should be changed and we want to
       // have more than one ServerState field.
       serverState = new ServerState(in, pos, in.length - 1);
-    } catch (UnsupportedEncodingException e)
+    }
+    catch (UnsupportedEncodingException e)
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
@@ -283,9 +292,9 @@
    *
    * @return the base DN from this ReplServerStartMsg.
    */
-  public String getBaseDn()
+  public DN getBaseDN()
   {
-    return baseDn;
+    return baseDN;
   }
 
   /**
@@ -312,11 +321,11 @@
     }
 
     /* The ReplServerStartMsg is stored in the form :
-     * <operation type><baseDn><serverId><serverURL><windowSize><sslEncryption>
+     * <operation type><baseDN><serverId><serverURL><windowSize><sslEncryption>
      * <degradedStatusThreshold><serverState>
      */
 
-    byte[] byteDn = baseDn.getBytes("UTF-8");
+    byte[] byteDn = baseDN.toString().getBytes("UTF-8");
     byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8");
     byte[] byteServerUrl = serverURL.getBytes("UTF-8");
     byte[] byteServerState = serverState.getBytes();
@@ -411,7 +420,7 @@
     return "ReplServerStartMsg content: " +
       "\nprotocolVersion: " + protocolVersion +
       "\ngenerationId: " + generationId +
-      "\nbaseDn: " + baseDn +
+      "\nbaseDN: " + baseDN +
       "\ngroupId: " + groupId +
       "\nserverId: " + serverId +
       "\nserverState: " + serverState +
@@ -437,7 +446,7 @@
      * <operation type><basedn><serverid><serverURL><windowsize><serverState>
      */
     try {
-      byte[] byteDn = baseDn.getBytes("UTF-8");
+      byte[] byteDn = baseDN.toString().getBytes("UTF-8");
       byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8");
       byte[] byteServerUrl = serverURL.getBytes("UTF-8");
       byte[] byteServerState = serverState.getBytes();
diff --git a/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java b/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
index c2a0da1..40388d7 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
@@ -31,6 +31,8 @@
 import java.util.zip.DataFormatException;
 
 import org.opends.server.replication.common.ServerState;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
 
 /**
  * This message is used by LDAP server when they first connect.
@@ -41,7 +43,7 @@
 {
   private int serverId; // Id of the LDAP server that sent this message
   private String serverURL;
-  private String baseDn;
+  private DN baseDN;
   private int maxReceiveQueue;
   private int maxSendQueue;
   private int maxReceiveDelay;
@@ -69,7 +71,7 @@
    * @param serverId2 The serverId of the server for which the ServerStartMsg
    *                 is created.
    * @param serverURL directory server URL
-   * @param baseDn   The base DN.
+   * @param baseDN   The base DN.
    * @param windowSize   The window size used by this server.
    * @param heartbeatInterval The requested heartbeat interval.
    * @param serverState  The state of this server.
@@ -78,7 +80,7 @@
    *                      after the start messages have been exchanged.
    * @param groupId The group id of the DS for this DN
    */
-  public ServerStartMsg(int serverId2, String serverURL, String baseDn,
+  public ServerStartMsg(int serverId2, String serverURL, DN baseDN,
       int windowSize, long heartbeatInterval, ServerState serverState,
       long generationId, boolean sslEncryption,
       byte groupId)
@@ -87,7 +89,7 @@
 
     this.serverId = serverId2;
     this.serverURL = serverURL;
-    this.baseDn = baseDn;
+    this.baseDN = baseDN;
     this.maxReceiveDelay = 0;
     this.maxReceiveQueue = 0;
     this.maxSendDelay = 0;
@@ -123,7 +125,7 @@
        * first calculate the length then construct the string
        */
       int length = getNextLength(in, pos);
-      baseDn = new String(in, pos, length, "UTF-8");
+      baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
       pos += length +1;
 
       /*
@@ -199,10 +201,15 @@
       // have more than one ServerState field.
       serverState = new ServerState(in, pos, in.length - 1);
 
-    } catch (UnsupportedEncodingException e)
+    }
+    catch (UnsupportedEncodingException e)
     {
       throw new DataFormatException("UTF-8 is not supported by this jvm.");
     }
+    catch (DirectoryException e)
+    {
+      throw new DataFormatException(e.getLocalizedMessage());
+    }
   }
 
   /**
@@ -224,12 +231,13 @@
   }
 
   /**
-   * Get the baseDn.
-   * @return Returns the baseDn.
+   * Get the baseDN.
+   *
+   * @return Returns the baseDN.
    */
-  public String getBaseDn()
+  public DN getBaseDN()
   {
-    return baseDn;
+    return baseDN;
   }
 
   /**
@@ -284,7 +292,7 @@
   public byte[] getBytes(short sessionProtocolVersion)
   {
     try {
-      byte[] byteDn = baseDn.getBytes("UTF-8");
+      byte[] byteDn = baseDN.toString().getBytes("UTF-8");
       byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8");
       byte[] byteServerUrl = serverURL.getBytes("UTF-8");
       byte[] byteMaxRecvDelay =
@@ -393,7 +401,7 @@
       "\nprotocolVersion: " + protocolVersion +
       "\ngenerationId: " + generationId +
       "\ngroupId: " + groupId +
-      "\nbaseDn: " + baseDn +
+      "\nbaseDN: " + baseDN +
       "\nheartbeatInterval: " + heartbeatInterval +
       "\nmaxReceiveDelay: " + maxReceiveDelay +
       "\nmaxReceiveQueue: " + maxReceiveQueue +
@@ -405,4 +413,4 @@
       "\nsslEncryption: " + sslEncryption +
       "\nwindowSize: " + windowSize;
   }
-  }
+}
diff --git a/opends/src/server/org/opends/server/replication/server/DataServerHandler.java b/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
index c9f4b7d..d56f0cb 100644
--- a/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
@@ -105,7 +105,7 @@
       // gen status)
       Message message = NOTE_BAD_GEN_ID_IN_FULL_UPDATE.get(
               Integer.toString(replicationServer.getServerId()),
-              getBaseDN(),
+              getBaseDNString(),
               Integer.toString(serverId),
               Long.toString(generationId),
               Long.toString(newGenId));
@@ -136,7 +136,7 @@
       if (debugEnabled())
       {
         TRACER.debugInfo("In RS " + replicationServer.getServerId()
-            + ", DS " + getServerId() + " for baseDN=" + getBaseDN()
+            + ", DS " + getServerId() + " for baseDN=" + getBaseDNString()
             + " has already generation id " + newGenId
             + " so no ChangeStatusMsg sent to him.");
       }
@@ -151,7 +151,7 @@
     {
       TRACER.debugInfo("In RS " + replicationServer.getServerId()
           + ", closing connection to DS " + getServerId() + " for baseDN="
-          + getBaseDN() + " to force reconnection as new local"
+          + getBaseDNString() + " to force reconnection as new local"
           + " generationId and remote one match and DS is in bad gen id: "
           + newGenId);
     }
@@ -203,7 +203,7 @@
     ServerStatus newStatus = StatusMachine.computeNewStatus(status, event);
     if (newStatus == ServerStatus.INVALID_STATUS)
     {
-      Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDN(),
+      Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDNString(),
           Integer.toString(serverId), status.toString(), event.toString());
       logError(msg);
       // Only change allowed is from NORMAL_STATUS to DEGRADED_STATUS and vice
@@ -220,7 +220,7 @@
     {
       TRACER.debugInfo("In RS " + replicationServer.getServerId()
           + " Sending change status " + origin + " to " + getServerId()
-          + " for baseDN=" + getBaseDN() + ":\n" + csMsg);
+          + " for baseDN=" + getBaseDNString() + ":\n" + csMsg);
     }
 
     session.publish(csMsg);
@@ -323,7 +323,7 @@
     if (event == StatusMachineEvent.INVALID_EVENT)
     {
       Message msg = ERR_RS_INVALID_NEW_STATUS.get(reqStatus.toString(),
-          getBaseDN(), Integer.toString(serverId));
+          getBaseDNString(), Integer.toString(serverId));
       logError(msg);
       return ServerStatus.INVALID_STATUS;
     }
@@ -332,7 +332,7 @@
     ServerStatus newStatus = StatusMachine.computeNewStatus(status, event);
     if (newStatus == ServerStatus.INVALID_STATUS)
     {
-      Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDN(),
+      Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDNString(),
           Integer.toString(serverId), status.toString(), event.toString());
       logError(msg);
       return ServerStatus.INVALID_STATUS;
@@ -361,8 +361,7 @@
     heartbeatInterval = serverStartMsg.getHeartbeatInterval();
 
     // generic stuff
-    DN baseDN = DN.decode(serverStartMsg.getBaseDn());
-    setBaseDNAndDomain(baseDN, true);
+    setBaseDNAndDomain(serverStartMsg.getBaseDN(), true);
     setInitialServerState(serverStartMsg.getServerState());
     setSendWindowSize(serverStartMsg.getWindowSize());
 
@@ -590,7 +589,7 @@
     {
       Message message = ERR_RS_INVALID_INIT_STATUS.get(
           this.status.toString(),
-          getBaseDN(),
+          getBaseDNString(),
           Integer.toString(serverId));
       throw new DirectoryException(ResultCode.OTHER, message);
     }
@@ -619,7 +618,7 @@
       {
         Message message = WARN_BAD_GENERATION_ID_FROM_DS.get(
             serverId, session.getReadableRemoteAddress(),
-            generationId, getBaseDN(),
+            generationId, getBaseDNString(),
             getReplicationServerId(), localGenerationId);
         logError(message);
       }
@@ -633,7 +632,7 @@
         // it is not expected to connect to an empty RS
         Message message = WARN_BAD_GENERATION_ID_FROM_DS.get(
             serverId, session.getReadableRemoteAddress(),
-            generationId, getBaseDN(),
+            generationId, getBaseDNString(),
             getReplicationServerId(), localGenerationId);
         logError(message);
       }
diff --git a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
index 6f0943d..bc16461 100644
--- a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -190,7 +190,7 @@
     private void getNextEligibleMessageForDomain(String opid)
     {
       if (debugEnabled())
-        TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() +
+        TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDNString() +
           " getNextEligibleMessageForDomain(" + opid+ ") "
           + "ctxt=" + toString());
 
@@ -207,8 +207,9 @@
                 <= eligibleCSN.getTime());
 
           if (debugEnabled())
-            TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() +
-                " getNextEligibleMessageForDomain(" + opid+ ") "
+            TRACER.debugInfo(" In ECLServerHandler, for "
+              + mh.getBaseDNString()
+              + " getNextEligibleMessageForDomain(" + opid + ") "
               + " stored nonEligibleMsg " + nextNonEligibleMsg
               + " has now become eligible regarding "
               + " the eligibleCSN ("+ eligibleCSN
@@ -237,10 +238,11 @@
               (newMsg.getCSN().getTime() < domainLatestTrimDate));
 
           if (debugEnabled())
-            TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() +
-                " getNextEligibleMessageForDomain(" + opid+ ") "
+            TRACER.debugInfo(" In ECLServerHandler, for "
+                + mh.getBaseDNString()
+                + " getNextEligibleMessageForDomain(" + opid + ") "
                 + " got new message : "
-                +  " baseDN=[" + mh.getBaseDN()
+                +  " baseDN=[" + mh.getBaseDNString()
                 + "] [newMsg=" + newMsg + "]" + dumpState());
 
           // in non blocking mode, return null when no more msg
@@ -250,7 +252,8 @@
                 <= eligibleCSN.getTime());
 
           if (debugEnabled())
-              TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN()
+              TRACER.debugInfo(" In ECLServerHandler, for "
+                + mh.getBaseDNString()
                 + " getNextEligibleMessageForDomain(" + opid+ ") "
                 + "newMsg isEligible=" + isEligible + " since "
                 + "newMsg=[" + newMsg.getCSN()
@@ -965,8 +968,8 @@
     final String eclServer = "External changelog Server ";
     if (this.serverId != 0)
     {
-      return eclServer + serverId + " " + serverURL + " " + getBaseDN() + " "
-          + operationId;
+      return eclServer + serverId + " " + serverURL + " "
+          + getBaseDNString() + " " + operationId;
     }
     return eclServer + getClass().getCanonicalName() + " " + operationId;
   }
@@ -1235,7 +1238,7 @@
         final ECLUpdateMsg change = new ECLUpdateMsg(
             (LDAPUpdateMsg) oldestContext.nextMsg,
             null, // cookie will be set later
-            oldestContext.rsd.getBaseDN().toNormalizedString(),
+            oldestContext.rsd.getBaseDN(),
             0); // changeNumber may be set later
         oldestContext.nextMsg = null;
 
@@ -1287,7 +1290,7 @@
           final ECLUpdateMsg change = new ECLUpdateMsg(
               (LDAPUpdateMsg) oldestContext.nextMsg,
               null, // set later
-              oldestContext.rsd.getBaseDN().toNormalizedString(),
+              oldestContext.rsd.getBaseDN(),
               0);
           oldestContext.nextMsg = null; // clean
 
@@ -1318,7 +1321,7 @@
         TRACER.debugInfo("getNextECLUpdate updates previousCookie:" + csn);
 
       // Update the current state
-      previousCookie.update(DN.decode(oldestChange.getBaseDN()), csn);
+      previousCookie.update(oldestChange.getBaseDN(), csn);
 
       // Set the current value of global state in the returned message
       oldestChange.setCookie(previousCookie);
@@ -1357,7 +1360,7 @@
 
     // replogCSN : the oldest change from the changelog db
     CSN csnFromChangelogDb = oldestChange.getUpdateMsg().getCSN();
-    DN dnFromChangelogDb = DN.decode(oldestChange.getBaseDN());
+    DN dnFromChangelogDb = oldestChange.getBaseDN();
 
     while (true)
     {
@@ -1458,7 +1461,7 @@
     replicationServer.getChangeNumberIndexDB().addRecord(new CNIndexRecord(
         change.getChangeNumber(),
         previousCookie.toString(),
-        DN.decode(change.getBaseDN()),
+        change.getBaseDN(),
         change.getUpdateMsg().getCSN()));
   }
 
diff --git a/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java b/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java
index e8c9c95..d7ab1ee 100644
--- a/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java
+++ b/opends/src/server/org/opends/server/replication/server/ECLServerWriter.java
@@ -176,7 +176,7 @@
               handler.getReplicationServerId(),
               handler.getServerId(),
               session.getReadableRemoteAddress(),
-              handler.getBaseDN());
+              handler.getBaseDNString());
         }
         else
         {
@@ -184,7 +184,7 @@
               handler.getReplicationServerId(),
               handler.getServerId(),
               session.getReadableRemoteAddress(),
-              handler.getBaseDN());
+              handler.getBaseDNString());
         }
         logError(errMessage);
       }
diff --git a/opends/src/server/org/opends/server/replication/server/MessageHandler.java b/opends/src/server/org/opends/server/replication/server/MessageHandler.java
index 45ba05f..06070f1 100644
--- a/opends/src/server/org/opends/server/replication/server/MessageHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/MessageHandler.java
@@ -559,9 +559,19 @@
   /**
    * Get the baseDN for this handler.
    *
+   * @return The baseDN.
+   */
+  protected DN getBaseDN()
+  {
+    return baseDN;
+  }
+
+  /**
+   * Get the baseDN for this handler as a String.
+   *
    * @return The name of the baseDN.
    */
-  protected String getBaseDN()
+  protected String getBaseDNString()
   {
     return baseDN.toNormalizedString();
   }
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java b/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
index 13487a9..c5ec6bd 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -781,7 +781,7 @@
 
           dn = DN.decode("puid=" + addMsg.getParentEntryUUID() + "+" +
               CHANGE_NUMBER + "=" + msg.getCSN() + "+" +
-              msg.getDn() + "," + BASE_DN);
+              msg.getDN() + "," + BASE_DN);
 
           Map<AttributeType,List<Attribute>> attrs =
             new HashMap<AttributeType,List<Attribute>>();
@@ -904,7 +904,7 @@
   private DN computeDN(LDAPUpdateMsg msg) throws DirectoryException
   {
     return DN.decode("uuid=" + msg.getEntryUUID() + "," + CHANGE_NUMBER + "="
-        + msg.getCSN() + "," + msg.getDn() + "," + BASE_DN);
+        + msg.getCSN() + "," + msg.getDN() + "," + BASE_DN);
   }
 
   private Entry writeChangeRecord(LDIFWriter ldifWriter,
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java b/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
index 6d0a6fd..54ab91c 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
@@ -83,8 +83,7 @@
       serverId = inReplServerStartMsg.getServerId();
       serverURL = inReplServerStartMsg.getServerURL();
       serverAddressURL = toServerAddressURL(serverURL);
-      DN baseDN = DN.decode(inReplServerStartMsg.getBaseDn());
-      setBaseDNAndDomain(baseDN, false);
+      setBaseDNAndDomain(inReplServerStartMsg.getBaseDN(), false);
       setInitialServerState(inReplServerStartMsg.getServerState());
       setSendWindowSize(inReplServerStartMsg.getWindowSize());
       if (protocolVersion > ProtocolVersion.REPLICATION_PROTOCOL_V1)
@@ -541,7 +540,7 @@
        */
       Message message = WARN_BAD_GENERATION_ID_FROM_RS.get(
           serverId, session.getReadableRemoteAddress(), generationId,
-          getBaseDN(), getReplicationServerId(), localGenerationId);
+          getBaseDNString(), getReplicationServerId(), localGenerationId);
       logError(message);
     }
   }
diff --git a/opends/src/server/org/opends/server/replication/server/ServerHandler.java b/opends/src/server/org/opends/server/replication/server/ServerHandler.java
index 55279ab..8557f48 100644
--- a/opends/src/server/org/opends/server/replication/server/ServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ServerHandler.java
@@ -533,7 +533,7 @@
     List<Attribute> attributes = super.getMonitorData();
 
     attributes.add(Attributes.create("server-id", String.valueOf(serverId)));
-    attributes.add(Attributes.create("domain-name", getBaseDN()));
+    attributes.add(Attributes.create("domain-name", getBaseDNString()));
 
     // Deprecated
     attributes.add(Attributes.create("max-waiting-changes", String
@@ -835,7 +835,7 @@
     if (!lockAcquired)
     {
       Message message = WARN_TIMEOUT_WHEN_CROSS_CONNECTION.get(
-          getBaseDN(),
+          getBaseDNString(),
           serverId,
           session.getReadableRemoteAddress(),
           getReplicationServerId());
diff --git a/opends/src/server/org/opends/server/replication/server/ServerReader.java b/opends/src/server/org/opends/server/replication/server/ServerReader.java
index ae7f9db..2881036 100644
--- a/opends/src/server/org/opends/server/replication/server/ServerReader.java
+++ b/opends/src/server/org/opends/server/replication/server/ServerReader.java
@@ -143,7 +143,7 @@
                   logError(WARN_IGNORING_UPDATE_FROM_DS_BADGENID.get(
                       handler.getReplicationServerId(),
                       updateMsg.getCSN().toString(),
-                      handler.getBaseDN(), handler.getServerId(),
+                      handler.getBaseDNString(), handler.getServerId(),
                       session.getReadableRemoteAddress(),
                       handler.getGenerationId(),
                       referenceGenerationId));
@@ -151,7 +151,7 @@
                   logError(WARN_IGNORING_UPDATE_FROM_DS_FULLUP.get(
                       handler.getReplicationServerId(),
                       updateMsg.getCSN().toString(),
-                      handler.getBaseDN(), handler.getServerId(),
+                      handler.getBaseDNString(), handler.getServerId(),
                       session.getReadableRemoteAddress()));
                 filtered = true;
               }
@@ -169,7 +169,7 @@
                     WARN_IGNORING_UPDATE_FROM_RS.get(
                         handler.getReplicationServerId(),
                         updateMsg.getCSN().toString(),
-                        handler.getBaseDN(),
+                        handler.getBaseDNString(),
                         handler.getServerId(),
                         session.getReadableRemoteAddress(),
                         handler.getGenerationId(),
@@ -210,7 +210,7 @@
             {
               errMessage =
                 ERR_RECEIVED_CHANGE_STATUS_NOT_FROM_DS.get(
-                    handler.getBaseDN(),
+                    handler.getBaseDNString(),
                     Integer.toString(handler.getServerId()),
                     csMsg.toString());
               logError(errMessage);
@@ -262,13 +262,13 @@
         {
           errMessage = ERR_DS_BADLY_DISCONNECTED.get(
               handler.getReplicationServerId(), handler.getServerId(),
-              remoteAddress, handler.getBaseDN());
+              remoteAddress, handler.getBaseDNString());
         }
         else
         {
           errMessage = ERR_RS_BADLY_DISCONNECTED.get(
               handler.getReplicationServerId(), handler.getServerId(),
-              remoteAddress, handler.getBaseDN());
+              remoteAddress, handler.getBaseDNString());
         }
         logError(errMessage);
       }
diff --git a/opends/src/server/org/opends/server/replication/server/ServerWriter.java b/opends/src/server/org/opends/server/replication/server/ServerWriter.java
index ff5002b..d3efec9 100644
--- a/opends/src/server/org/opends/server/replication/server/ServerWriter.java
+++ b/opends/src/server/org/opends/server/replication/server/ServerWriter.java
@@ -138,7 +138,7 @@
               logError(WARN_IGNORING_UPDATE_TO_DS_BADGENID.get(
                   handler.getReplicationServerId(),
                   update.getCSN().toString(),
-                  handler.getBaseDN(), handler.getServerId(),
+                  handler.getBaseDNString(), handler.getServerId(),
                   session.getReadableRemoteAddress(),
                   handler.getGenerationId(),
                   referenceGenerationId));
@@ -146,7 +146,7 @@
               logError(WARN_IGNORING_UPDATE_TO_DS_FULLUP.get(
                   handler.getReplicationServerId(),
                   update.getCSN().toString(),
-                  handler.getBaseDN(), handler.getServerId(),
+                  handler.getBaseDNString(), handler.getServerId(),
                   session.getReadableRemoteAddress()));
             continue;
           }
@@ -165,7 +165,7 @@
                 WARN_IGNORING_UPDATE_TO_RS.get(
                     handler.getReplicationServerId(),
                     update.getCSN().toString(),
-                    handler.getBaseDN(),
+                    handler.getBaseDNString(),
                     handler.getServerId(),
                     session.getReadableRemoteAddress(),
                     handler.getGenerationId(),
@@ -204,13 +204,13 @@
       {
         errMessage = ERR_DS_BADLY_DISCONNECTED.get(
             handler.getReplicationServerId(), handler.getServerId(),
-            session.getReadableRemoteAddress(), handler.getBaseDN());
+            session.getReadableRemoteAddress(), handler.getBaseDNString());
       }
       else
       {
         errMessage = ERR_RS_BADLY_DISCONNECTED.get(
             handler.getReplicationServerId(), handler.getServerId(),
-            session.getReadableRemoteAddress(), handler.getBaseDN());
+            session.getReadableRemoteAddress(), handler.getBaseDNString());
       }
 
       logError(errMessage);
@@ -225,13 +225,13 @@
       {
         errMessage = ERR_DS_BADLY_DISCONNECTED.get(
             handler.getReplicationServerId(), handler.getServerId(),
-            session.getReadableRemoteAddress(), handler.getBaseDN());
+            session.getReadableRemoteAddress(), handler.getBaseDNString());
       }
       else
       {
         errMessage = ERR_RS_BADLY_DISCONNECTED.get(
             handler.getReplicationServerId(), handler.getServerId(),
-            session.getReadableRemoteAddress(), handler.getBaseDN());
+            session.getReadableRemoteAddress(), handler.getBaseDNString());
       }
       logError(errMessage);
     }
diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index dba65da..8062c2e 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -405,16 +405,16 @@
     private int serverId;
     /** Received server URL. */
     private String serverURL;
-    private String baseDn = null;
+    private DN baseDN;
     private int windowSize;
-    private ServerState serverState = null;
+    private ServerState serverState;
     private boolean sslEncryption;
     private int degradedStatusThreshold = -1;
     /** Keeps the 1 value if created with a ReplServerStartMsg. */
     private int weight = 1;
     /** Keeps the 0 value if created with a ReplServerStartMsg. */
     private int connectedDSNumber = 0;
-    private List<Integer> connectedDSs = null;
+    private List<Integer> connectedDSs;
     /**
      * Is this RS locally configured? (the RS is recognized as a usable server).
      */
@@ -479,7 +479,7 @@
       this.groupId = replServerStartMsg.getGroupId();
       this.serverId = replServerStartMsg.getServerId();
       this.serverURL = replServerStartMsg.getServerURL();
-      this.baseDn = replServerStartMsg.getBaseDn();
+      this.baseDN = replServerStartMsg.getBaseDN();
       this.windowSize = replServerStartMsg.getWindowSize();
       this.serverState = replServerStartMsg.getServerState();
       this.sslEncryption = replServerStartMsg.getSSLEncryption();
@@ -501,7 +501,7 @@
       this.groupId = replServerStartDSMsg.getGroupId();
       this.serverId = replServerStartDSMsg.getServerId();
       this.serverURL = replServerStartDSMsg.getServerURL();
-      this.baseDn = replServerStartDSMsg.getBaseDn();
+      this.baseDN = replServerStartDSMsg.getBaseDN();
       this.windowSize = replServerStartDSMsg.getWindowSize();
       this.serverState = replServerStartDSMsg.getServerState();
       this.sslEncryption = replServerStartDSMsg.getSSLEncryption();
@@ -566,12 +566,13 @@
     }
 
     /**
-     * Get the base dn.
-     * @return the baseDn
+     * Get the base DN.
+     *
+     * @return the base DN
      */
-    public String getBaseDn()
+    public DN getBaseDN()
     {
-      return baseDn;
+      return baseDN;
     }
 
     /**
@@ -1144,8 +1145,6 @@
   private ReplicationServerInfo performPhaseOneHandshake(
       String server, boolean keepConnection, boolean isECL)
   {
-    final String baseDn = this.baseDN.toNormalizedString();
-
     Session localSession = null;
     Socket socket = null;
     boolean hasConnected = false;
@@ -1169,7 +1168,7 @@
       if (!isECL)
       {
         serverStartMsg = new ServerStartMsg(serverId, url,
-            baseDN.toNormalizedString(), maxRcvWindow, heartbeatInterval, state,
+            baseDN, maxRcvWindow, heartbeatInterval, state,
             getGenerationID(), isSslEncryption, groupId);
       }
       else
@@ -1194,10 +1193,11 @@
           .newInstance(msg, server);
 
       // Sanity check
-      String repDn = replServerInfo.getBaseDn();
-      if (!baseDn.equals(repDn))
+      DN repDN = replServerInfo.getBaseDN();
+      if (!baseDN.equals(repDN))
       {
-        errorMessage = ERR_DS_DN_DOES_NOT_MATCH.get(repDn, baseDn);
+        errorMessage = ERR_DS_DN_DOES_NOT_MATCH.get(
+            repDN.toNormalizedString(), baseDN.toNormalizedString());
         return null;
       }
 
@@ -1233,19 +1233,19 @@
     catch (ConnectException e)
     {
       errorMessage = WARN_NO_CHANGELOG_SERVER_LISTENING.get(serverId,
-          server, baseDn);
+          server, baseDN.toNormalizedString());
       return null;
     }
     catch (SocketTimeoutException e)
     {
       errorMessage = WARN_TIMEOUT_CONNECTING_TO_RS.get(serverId,
-          server, baseDn);
+          server, baseDN.toNormalizedString());
       return null;
     }
     catch (Exception e)
     {
       errorMessage = WARN_EXCEPTION_STARTING_SESSION_PHASE.get(serverId,
-          server, baseDn, stackTraceToSingleLineString(e));
+          server, baseDN.toNormalizedString(), stackTraceToSingleLineString(e));
       return null;
     }
     finally
diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java b/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
index 577c766..38bd31d 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -1444,7 +1444,7 @@
 
         // Send start message to the peer
         InitializeTargetMsg initTargetMsg = new InitializeTargetMsg(
-            getBaseDNString(), serverID, serverToInitialize,
+            getBaseDN(), serverID, serverToInitialize,
             serverRunningTheTask, ieContext.entryCount, initWindow);
 
         broker.publish(initTargetMsg);
@@ -2209,7 +2209,7 @@
       ieContext.initializeTask = initTask;
       ieContext.attemptCnt = 0;
       ieContext.initReqMsgSent = new InitializeRequestMsg(
-          getBaseDNString(), serverID, source, this.initWindow);
+          getBaseDN(), serverID, source, this.initWindow);
 
       // Publish Init request msg
       broker.publish(ieContext.initReqMsgSent);
diff --git a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
index 8956353..23720e1 100644
--- a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -667,17 +667,17 @@
 
   /**
    * Build an ECL entry from a provided ECL msg and return it.
-   * @param eclmsg The provided ECL msg.
+   * @param eclMsg The provided ECL msg.
    * @return  <CODE>true</CODE> if the caller should continue processing the
    *          search request and sending additional entries and references, or
    *          <CODE>false</CODE> if not for some reason (e.g., the size limit
    *          has been reached or the search has been abandoned).
    * @throws DirectoryException When an errors occurs.
    */
-  private boolean buildAndReturnEntry(ECLUpdateMsg eclmsg)
+  private boolean buildAndReturnEntry(ECLUpdateMsg eclMsg)
       throws DirectoryException
   {
-    final Entry entry = createEntryFromMsg(eclmsg);
+    final Entry entry = createEntryFromMsg(eclMsg);
     if (matchScopeAndFilter(entry))
     {
       List<Control> controls = null;
@@ -687,7 +687,7 @@
 
         EntryChangelogNotificationControl clrc =
             new EntryChangelogNotificationControl(
-                true, eclmsg.getCookie().toString());
+                true, eclMsg.getCookie().toString());
         controls.add(clrc);
       }
       return returnEntry(entry, controls);
@@ -718,19 +718,19 @@
   /**
    * Create an ECL entry from a provided ECL msg.
    *
-   * @param eclmsg
+   * @param eclMsg
    *          the provided ECL msg.
    * @return the created ECL entry.
    * @throws DirectoryException
    *           When an error occurs.
    */
-  public static Entry createEntryFromMsg(ECLUpdateMsg eclmsg)
+  public static Entry createEntryFromMsg(ECLUpdateMsg eclMsg)
       throws DirectoryException
   {
     Entry clEntry = null;
 
     // Get the meat from the ecl msg
-    UpdateMsg msg = eclmsg.getUpdateMsg();
+    UpdateMsg msg = eclMsg.getUpdateMsg();
 
     if (msg instanceof AddMsg)
     {
@@ -774,20 +774,19 @@
             Severity.MILD_ERROR,
             "An exception was encountered while try to encode a "
                 + "replication add message for entry \""
-                + addMsg.getDn()
+                + addMsg.getDN()
                 + "\" into an External Change Log entry: "
                 + e.getMessage()));
       }
 
       List<RawAttribute> eclAttributes = addMsg.getEclIncludes();
 
-      clEntry = createChangelogEntry(eclmsg.getBaseDN(), eclmsg
-          .getCookie().toString(), DN.decode(addMsg.getDn()),
-          addMsg.getCSN(), ldifChanges, // entry as created (in LDIF
-                                                 // format)
+      clEntry = createChangelogEntry(eclMsg.getBaseDN(),
+          eclMsg.getCookie().toString(), addMsg.getDN(),
+          addMsg.getCSN(), ldifChanges, // entry as created (in LDIF format)
           addMsg.getEntryUUID(),
           eclAttributes, // entry attributes
-          eclmsg.getChangeNumber(), "add", changeInitiatorsName);
+          eclMsg.getChangeNumber(), "add", changeInitiatorsName);
     }
     else if (msg instanceof ModifyCommonMsg)
     {
@@ -840,7 +839,7 @@
             Severity.MILD_ERROR,
             "An exception was encountered while try to encode a "
                 + "replication modify message for entry \""
-                + modifyMsg.getDn()
+                + modifyMsg.getDN()
                 + "\" into an External Change Log entry: "
                 + e.getMessage()));
       }
@@ -848,12 +847,12 @@
       String changeType = (modifyMsg instanceof ModifyDNMsg) ? "modrdn"
           : "modify";
 
-      clEntry = createChangelogEntry(eclmsg.getBaseDN(), eclmsg
-          .getCookie().toString(), DN.decode(modifyMsg.getDn()),
+      clEntry = createChangelogEntry(eclMsg.getBaseDN(),
+          eclMsg.getCookie().toString(), modifyMsg.getDN(),
           modifyMsg.getCSN(), ldifChanges,
           modifyMsg.getEntryUUID(),
           modifyMsg.getEclIncludes(), // entry attributes
-          eclmsg.getChangeNumber(), changeType,
+          eclMsg.getChangeNumber(), changeType,
           changeInitiatorsName);
 
       if (modifyMsg instanceof ModifyDNMsg)
@@ -879,13 +878,13 @@
     {
       DeleteMsg delMsg = (DeleteMsg) msg;
 
-      clEntry = createChangelogEntry(eclmsg.getBaseDN(), eclmsg
-          .getCookie().toString(), DN.decode(delMsg.getDn()),
+      clEntry = createChangelogEntry(eclMsg.getBaseDN(),
+          eclMsg.getCookie().toString(), delMsg.getDN(),
           delMsg.getCSN(),
           null, // no changes
           delMsg.getEntryUUID(),
           delMsg.getEclIncludes(), // entry attributes
-          eclmsg.getChangeNumber(), "delete",
+          eclMsg.getChangeNumber(), "delete",
           delMsg.getInitiatorsName());
     }
 
@@ -992,7 +991,7 @@
    *         When any error occurs.
    */
   private static Entry createChangelogEntry(
-      String baseDN,
+      DN baseDN,
       String cookie,
       DN targetDN,
       CSN csn,
@@ -1008,8 +1007,8 @@
     if (changenumber == 0)
     {
       // Draft uncompat mode
-      dnString = "replicationCSN=" + csn + "," + baseDN + ","
-          + ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT;
+      dnString = "replicationCSN=" + csn + "," + baseDN.toNormalizedString()
+          + "," + ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT;
     }
     else
     {
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
index cb736d4..31abeda 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
@@ -48,6 +48,7 @@
 import org.opends.server.replication.server.ReplicationServer;
 import org.opends.server.replication.service.ReplicationBroker;
 import org.opends.server.types.*;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import static org.opends.server.TestCaseUtils.*;
@@ -61,6 +62,17 @@
 @SuppressWarnings("javadoc")
 public class DependencyTest extends ReplicationTestCase
 {
+
+  private final long CLEAN_DB_GENERATION_ID = 7883L;
+  private DN TEST_ROOT_DN;
+
+
+  @BeforeClass
+  public void setup() throws Exception
+  {
+     TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING);
+  }
+  
   /**
    * Check that a sequence of dependents adds and mods is correctly ordered:
    * Using a deep dit :
@@ -86,7 +98,7 @@
   {
     ReplicationServer replServer = null;
     LDAPReplicationDomain domain = null;
-    DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    DN baseDN = TEST_ROOT_DN;
     int brokerId = 2;
     int serverId = 1;
     int replServerId = 81;
@@ -125,13 +137,13 @@
       replServer = new ReplicationServer(conf);
 
       ReplicationBroker broker =
-        openReplicationSession(baseDn, brokerId, 1000, replServerPort, 1000,
+        openReplicationSession(baseDN, brokerId, 1000, replServerPort, 1000,
                                false, CLEAN_DB_GENERATION_ID);
 
       Thread.sleep(2000);
       // send a sequence of add operation
 
-      String addDn = TEST_ROOT_DN_STRING;
+      DN addDN = TEST_ROOT_DN;
       CSNGenerator gen = new CSNGenerator(brokerId, 0L);
 
       int sequence;
@@ -140,16 +152,16 @@
         entry.removeAttribute(uidType);
         entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                            new LinkedList<AttributeValue>());
-        addDn = "dc=dependency" + sequence + "," + addDn;
+        addDN = DN.decode("dc=dependency" + sequence + "," + addDN);
         AddMsg addMsg =
-          new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1),
+          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1),
                      stringUID(sequence),
                      entry.getObjectClassAttribute(),
                      entry.getAttributes(), null );
         broker.publish(addMsg);
 
         ModifyMsg modifyMsg =
-          new ModifyMsg(gen.newCSN(), DN.decode(addDn),
+          new ModifyMsg(gen.newCSN(), addDN,
                         generatemods("description", "test"),
                         stringUID(sequence+1));
         broker.publish(modifyMsg);
@@ -158,32 +170,26 @@
       // configure and start replication of TEST_ROOT_DN_STRING on the server
       SortedSet<String> replServers = new TreeSet<String>();
       replServers.add("localhost:"+replServerPort);
-      DomainFakeCfg domainConf =
-        new DomainFakeCfg(baseDn, serverId, replServers);
+      DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers);
       domainConf.setHeartbeatInterval(100000);
 
       domain = MultimasterReplication.createNewDomain(domainConf);
       domain.start();
 
       // check that last entry in sequence got added.
-      Entry lastEntry = getEntry(DN.decode(addDn), 30000, true);
+      Entry lastEntry = getEntry(addDN, 30000, true);
       assertNotNull(lastEntry,
                     "The last entry of the ADD sequence was not added.");
 
       // Check that all the modify have been replayed
       // (all the entries should have a description).
-      addDn = TEST_ROOT_DN_STRING;
+      addDN = TEST_ROOT_DN;
       for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
       {
-        addDn = "dc=dependency" + sequence + "," + addDn;
+        addDN = DN.decode("dc=dependency" + sequence + "," + addDN);
 
-        boolean found =
-          checkEntryHasAttribute(DN.decode(addDn), "description", "test",
-                                 10000, true);
-        if (!found)
-        {
-          fail("The modification was not replayed on entry " + addDn);
-        }
+        boolean found = checkEntryHasAttribute(addDN, "description", "test", 10000, true);
+        assertTrue(found, "The modification was not replayed on entry " + addDN);
       }
 
       /*
@@ -201,12 +207,10 @@
       Thread.sleep(2000);  // necesary because disable does not wait
                            // for full termination of all threads. (issue 1571)
 
-      DN deleteDN = DN.decode(addDn);
+      DN deleteDN = addDN;
       while (sequence-->1)
       {
-        DeleteMsg delMsg = new DeleteMsg(deleteDN.toString(),
-                                         gen.newCSN(),
-                                         stringUID(sequence + 1));
+        DeleteMsg delMsg = new DeleteMsg(deleteDN, gen.newCSN(), stringUID(sequence + 1));
         broker.publish(delMsg);
         deleteDN = deleteDN.getParent();
       }
@@ -225,7 +229,7 @@
     {
       remove(replServer);
       if (domain != null)
-        MultimasterReplication.deleteDomain(baseDn);
+        MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -239,7 +243,7 @@
   {
     ReplicationServer replServer = null;
     LDAPReplicationDomain domain = null;
-    DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    DN baseDN = TEST_ROOT_DN;
     int brokerId = 2;
     int serverId = 1;
     int replServerId = 82;
@@ -272,8 +276,7 @@
       // configure and start replication of TEST_ROOT_DN_STRING on the server
       SortedSet<String> replServers = new TreeSet<String>();
       replServers.add("localhost:"+replServerPort);
-      DomainFakeCfg domainConf =
-        new DomainFakeCfg(baseDn, serverId, replServers);
+      DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers);
       domainConf.setHeartbeatInterval(100000);
 
       Thread.sleep(2000);
@@ -281,7 +284,7 @@
       domain.start();
 
       ReplicationBroker broker =
-        openReplicationSession(baseDn, brokerId, 1000, replServerPort, 1000,
+        openReplicationSession(baseDN, brokerId, 1000, replServerPort, 1000,
                                false, CLEAN_DB_GENERATION_ID);
 
       // add an entry to play with.
@@ -289,9 +292,9 @@
       entry.addAttribute(Attributes.create("entryuuid",
                          stringUID(renamedEntryUuid)),
                          new LinkedList<AttributeValue>());
-      String addDn = "dc=moddndel" + "," + TEST_ROOT_DN_STRING;
+      DN addDN = DN.decode("dc=moddndel" + "," + TEST_ROOT_DN_STRING);
       AddMsg addMsg =
-        new AddMsg(gen.newCSN(), addDn, stringUID(renamedEntryUuid),
+          new AddMsg(gen.newCSN(), addDN, stringUID(renamedEntryUuid),
                    stringUID(1),
                    entry.getObjectClassAttribute(),
                    entry.getAttributes(), null );
@@ -299,11 +302,7 @@
       broker.publish(addMsg);
 
       // check that the entry was correctly added
-      boolean found =
-        checkEntryHasAttribute(DN.decode(addDn), "entryuuid",
-                               stringUID(renamedEntryUuid),
-                               30000, true);
-
+      boolean found = checkEntryHasAttribute(addDN, "entryuuid", stringUID(renamedEntryUuid), 30000, true);
       assertTrue(found, "The initial entry add failed");
 
 
@@ -313,12 +312,12 @@
 
       // rename and delete the entry.
       ModifyDNMsg moddnMsg =
-        new ModifyDNMsg(addDn, gen.newCSN(),
+          new ModifyDNMsg(addDN, gen.newCSN(),
                         stringUID(renamedEntryUuid),
                         stringUID(1), true, null, "dc=new_name");
       broker.publish(moddnMsg);
       DeleteMsg delMsg =
-        new DeleteMsg("dc=new_name" + "," + TEST_ROOT_DN_STRING,
+        new DeleteMsg(DN.decode("dc=new_name" + "," + TEST_ROOT_DN_STRING),
                       gen.newCSN(), stringUID(renamedEntryUuid));
       broker.publish(delMsg);
 
@@ -338,12 +337,10 @@
     {
       remove(replServer);
       if (domain != null)
-        MultimasterReplication.deleteDomain(baseDn);
+        MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
-
-  private final long CLEAN_DB_GENERATION_ID =  7883L;
   /**
    * Clean the database and replace with a single entry.
    *
@@ -384,7 +381,7 @@
   {
     ReplicationServer replServer = null;
     LDAPReplicationDomain domain = null;
-    DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    DN baseDN = TEST_ROOT_DN;
     int brokerId = 2;
     int serverId = 1;
     int replServerId = 83;
@@ -410,7 +407,7 @@
       replServer = new ReplicationServer(conf);
 
       ReplicationBroker broker =
-        openReplicationSession(baseDn, brokerId, 100, replServerPort, 1000,
+        openReplicationSession(baseDN, brokerId, 100, replServerPort, 1000,
                                false, CLEAN_DB_GENERATION_ID);
 
       // send a sequence of add/del/add operations
@@ -423,16 +420,16 @@
         entry.removeAttribute(uidType);
         entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                            new LinkedList<AttributeValue>());
-        String addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
+        DN addDN = DN.decode("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
         AddMsg addMsg =
-          new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1),
+          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1),
                      stringUID(1),
                      entry.getObjectClassAttribute(),
                      entry.getAttributes(), null );
         broker.publish(addMsg);
 
         // delete the entry
-        DeleteMsg delMsg = new DeleteMsg(addDn, gen.newCSN(),
+        DeleteMsg delMsg = new DeleteMsg(addDN, gen.newCSN(),
                                          stringUID(sequence+1));
         broker.publish(delMsg);
 
@@ -441,7 +438,7 @@
         entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1025)),
                            new LinkedList<AttributeValue>());
         addMsg =
-          new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1025),
+          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1025),
                      stringUID(1),
                      entry.getObjectClassAttribute(),
                      entry.getAttributes(), null );
@@ -451,9 +448,7 @@
       // configure and start replication of TEST_ROOT_DN_STRING on the server
       SortedSet<String> replServers = new TreeSet<String>();
       replServers.add("localhost:"+replServerPort);
-      DomainFakeCfg domainConf =
-        new DomainFakeCfg(baseDn, serverId, replServers);
-
+      DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers);
       domain = MultimasterReplication.createNewDomain(domainConf);
       domain.start();
 
@@ -475,7 +470,7 @@
 
       for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
       {
-        String deleteDN = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
+        DN deleteDN = DN.decode("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
         DeleteMsg delMsg = new DeleteMsg(deleteDN,
                                          gen.newCSN(),
                                          stringUID(sequence + 1025));
@@ -492,7 +487,7 @@
     {
       remove(replServer);
       if (domain != null)
-        MultimasterReplication.deleteDomain(baseDn);
+        MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -505,7 +500,7 @@
   {
     ReplicationServer replServer = null;
     LDAPReplicationDomain domain = null;
-    DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    DN baseDN = TEST_ROOT_DN;
     int brokerId = 2;
     int serverId = 1;
     int replServerId = 84;
@@ -532,11 +527,11 @@
       replServer = new ReplicationServer(conf);
 
       ReplicationBroker broker =
-        openReplicationSession(baseDn, brokerId, 100, replServerPort, 1000,
+        openReplicationSession(baseDN, brokerId, 100, replServerPort, 1000,
                                false, CLEAN_DB_GENERATION_ID);
 
 
-      String addDn = TEST_ROOT_DN_STRING;
+      DN addDN = TEST_ROOT_DN;
       CSNGenerator gen = new CSNGenerator(brokerId, 0L);
 
       // send a sequence of add/modrdn operations
@@ -547,9 +542,9 @@
         entry.removeAttribute(uidType);
         entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                            new LinkedList<AttributeValue>());
-        addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
+        addDN = DN.decode("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
         AddMsg addMsg =
-          new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1),
+          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1),
                      stringUID(1),
                      entry.getObjectClassAttribute(),
                      entry.getAttributes(), null );
@@ -557,7 +552,7 @@
 
         // rename the entry
         ModifyDNMsg moddnMsg =
-          new ModifyDNMsg(addDn, gen.newCSN(), stringUID(sequence+1),
+          new ModifyDNMsg(addDN, gen.newCSN(), stringUID(sequence+1),
                           stringUID(1), true, null, "dc=new_dep" + sequence);
         broker.publish(moddnMsg);
       }
@@ -565,29 +560,24 @@
       // configure and start replication of TEST_ROOT_DN_STRING on the server
       SortedSet<String> replServers = new TreeSet<String>();
       replServers.add("localhost:"+replServerPort);
-      DomainFakeCfg domainConf =
-        new DomainFakeCfg(baseDn, serverId, replServers);
-
+      DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers);
       domain = MultimasterReplication.createNewDomain(domainConf);
       domain.start();
 
       // check that all entries have been renamed
       for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
       {
-        addDn = "dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING;
-
-        Entry baseEntry = getEntry(DN.decode(addDn), 30000, true);
+        addDN = DN.decode("dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING);
+        Entry baseEntry = getEntry(addDN, 30000, true);
         assertNotNull(baseEntry,
-          "The rename was not applied correctly on :" + addDn);
+          "The rename was not applied correctly on :" + addDN);
       }
 
       // delete the entries to clean the database.
       for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
       {
-        addDn = "dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING;
-        DeleteMsg delMsg = new DeleteMsg(addDn.toString(),
-                                         gen.newCSN(),
-                                         stringUID(sequence + 1));
+        addDN = DN.decode("dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING);
+        DeleteMsg delMsg = new DeleteMsg(addDN, gen.newCSN(), stringUID(sequence + 1));
         broker.publish(delMsg);
       }
     }
@@ -595,7 +585,7 @@
     {
       remove(replServer);
       if (domain != null)
-        MultimasterReplication.deleteDomain(baseDn);
+        MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
index cecdf6c..4d670e6 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -580,7 +580,7 @@
 
     // Create and publish an update message to add an entry.
     return new AddMsg(gen.newCSN(),
-        personWithUUIDEntry.getDN().toString(),
+        personWithUUIDEntry.getDN(),
         user1entryUUID,
         baseUUID,
         personWithUUIDEntry.getObjectClassAttribute(),
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
index 17f61b3..d4512bc 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
@@ -433,7 +433,7 @@
       int senderID, int destinationServerID, int requestorID)
   {
     RoutableMsg initTargetMessage =
-        new InitializeTargetMsg(EXAMPLE_DN, server2ID, destinationServerID,
+        new InitializeTargetMsg(baseDN, server2ID, destinationServerID,
             requestorID, updatedEntries.length, initWindow);
     broker.publish(initTargetMessage);
 
@@ -715,8 +715,7 @@
       // checks for session establishment ?
       // Thread.sleep(3000);
 
-      InitializeRequestMsg initMsg = new InitializeRequestMsg(EXAMPLE_DN,
-        server2ID, server1ID, 100);
+      InitializeRequestMsg initMsg = new InitializeRequestMsg(baseDN, server2ID, server1ID, 100);
       server2.publish(initMsg);
 
       // Signal RS we just entered the full update status
@@ -1211,8 +1210,7 @@
 
       // S3 sends init request
       log(testCase + " server 3 Will send reqinit to " + server1ID);
-      InitializeRequestMsg initMsg =
-        new InitializeRequestMsg(EXAMPLE_DN, server3ID, server1ID, 100);
+      InitializeRequestMsg initMsg = new InitializeRequestMsg(baseDN, server3ID, server1ID, 100);
       server3.publish(initMsg);
 
       // S3 should receive target, entries & done
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
index d2a2a46..3b0b6db 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
@@ -27,10 +27,6 @@
  */
 package org.opends.server.replication;
 
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.loggers.ErrorLogger.*;
-import static org.testng.Assert.*;
-
 import java.net.SocketTimeoutException;
 import java.util.Iterator;
 import java.util.List;
@@ -57,6 +53,10 @@
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.loggers.ErrorLogger.*;
+import static org.testng.Assert.*;
+
 /**
  * Test the constructors, encoders and decoders of the Replication AckMsg,
  * ModifyMsg, ModifyDnMsg, AddMsg and Delete MSG
@@ -75,7 +75,7 @@
 
 
   /** the base DN used for this test */
-  private DN baseDn;
+  private DN baseDN;
   private ReplicationServer replicationServer;
 
   /**
@@ -114,7 +114,7 @@
           "Unable to add the synchronized server");
     configEntryList.add(repDomainEntry.getDN());
 
-    ReplicationBroker broker = openReplicationSession(baseDn, 12,
+    ReplicationBroker broker = openReplicationSession(baseDN, 12,
         WINDOW_SIZE, replServerPort, 1000, true);
 
     try {
@@ -150,7 +150,7 @@
       assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
         "The received Replication message is not an ADD msg");
 
-      assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
+      assertEquals(addMsg.getDN(), personEntry.getDN(),
         "The received ADD Replication message is not for the excepted DN");
 
       // send (2 * window + replicationServer queue) modify operations
@@ -291,7 +291,7 @@
     // This test suite depends on having the schema available.
     super.setUp();
 
-    baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     replServerPort = TestCaseUtils.findFreePort();
 
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index 03fa0d8..cedcebc 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -1087,10 +1087,15 @@
   /**
    * Utility method : removes a domain deleting the passed config entry
    */
-  protected void removeDomain(Entry domainCfgEntry)
+  protected void removeDomain(Entry... domainCfgEntries)
   {
-    DN dn = domainCfgEntry.getDN();
-    deleteEntry(dn);
+    for (Entry entry : domainCfgEntries)
+    {
+      if (entry != null)
+      {
+        deleteEntry(entry.getDN());
+      }
+    }
   }
 
   /**
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
index 28e5971..ff51088 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
@@ -121,10 +121,10 @@
 
     cleanUpReplicationServersDB();
 
-    final DN baseDn = DN.decode("cn=schema");
+    final DN baseDN = DN.decode("cn=schema");
 
     ReplicationBroker broker =
-      openReplicationSession(baseDn,  2, 100, replServerPort, 5000, true);
+      openReplicationSession(baseDN, 2, 100, replServerPort, 5000, true);
 
     try
     {
@@ -136,7 +136,7 @@
       mods.add(mod);
       ModifyOperationBasis modOp = new ModifyOperationBasis(connection,
           InternalClientConnection.nextOperationID(), InternalClientConnection
-          .nextMessageID(), null, baseDn, mods);
+          .nextMessageID(), null, baseDN, mods);
       modOp.setInternalOperation(true);
       modOp.run();
 
@@ -152,7 +152,7 @@
       ModifyMsg modMsg = (ModifyMsg) msg;
 
       Operation receivedOp = modMsg.createOperation(connection);
-      assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0,
+      assertEquals(modMsg.getDN(), baseDN,
                  "The received message is not for cn=schema");
 
       assertTrue(receivedOp instanceof ModifyOperation,
@@ -179,7 +179,7 @@
       mods.add(mod);
       modOp = new ModifyOperationBasis(connection,
           InternalClientConnection.nextOperationID(), InternalClientConnection
-          .nextMessageID(), null, baseDn, mods);
+          .nextMessageID(), null, baseDN, mods);
       modOp.setInternalOperation(true);
       modOp.run();
 
@@ -211,20 +211,20 @@
 
     cleanUpReplicationServersDB();
 
-    final DN baseDn = DN.decode("cn=schema");
+    final DN baseDN = DN.decode("cn=schema");
 
     ReplicationBroker broker =
-      openReplicationSession(baseDn,  2, 100, replServerPort, 5000, true);
+      openReplicationSession(baseDN,  2, 100, replServerPort, 5000, true);
 
     try
     {
       CSNGenerator gen = new CSNGenerator( 2, 0);
 
-      ModifyMsg modMsg = new ModifyMsg(gen.newCSN(), baseDn, rcvdMods,
-          EntryHistorical.getEntryUUID(DirectoryServer.getEntry(baseDn)));
+      ModifyMsg modMsg = new ModifyMsg(gen.newCSN(), baseDN, rcvdMods,
+          EntryHistorical.getEntryUUID(DirectoryServer.getEntry(baseDN)));
       broker.publish(modMsg);
 
-      boolean found = checkEntryHasAttribute(baseDn, "attributetypes",
+      boolean found = checkEntryHasAttribute(baseDN, "attributetypes",
         "( 2.5.44.77.33 NAME 'dummy' )",
         10000, true);
 
@@ -250,10 +250,10 @@
 
     cleanUpReplicationServersDB();
 
-    final DN baseDn = DN.decode("cn=schema");
+    final DN baseDN = DN.decode("cn=schema");
 
     ReplicationBroker broker =
-      openReplicationSession(baseDn,  3, 100, replServerPort, 5000, true);
+      openReplicationSession(baseDN,  3, 100, replServerPort, 5000, true);
 
     try
     {
@@ -278,7 +278,7 @@
       ModifyMsg modMsg = (ModifyMsg) msg;
 
       Operation receivedOp = modMsg.createOperation(connection);
-      assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0,
+      assertEquals(modMsg.getDN(), baseDN,
         "The received message is not for cn=schema");
 
       assertTrue(receivedOp instanceof ModifyOperation,
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java
index 62a90bf..e84cbcc 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java
@@ -27,10 +27,6 @@
  */
 package org.opends.server.replication;
 
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.loggers.ErrorLogger.*;
-import static org.testng.Assert.*;
-
 import java.util.LinkedList;
 import java.util.List;
 
@@ -52,6 +48,10 @@
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.loggers.ErrorLogger.*;
+import static org.testng.Assert.*;
+
 /**
  * Stress test for the synchronization code using the ReplicationBroker API.
  */
@@ -80,11 +80,11 @@
     logError(Message.raw(Category.SYNC, Severity.NOTICE,
         "Starting replication StressTest : fromServertoBroker"));
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
     final int TOTAL_MESSAGES = 1000;
 
     ReplicationBroker broker =
-      openReplicationSession(baseDn, 18, 100, replServerPort, 5000, true);
+      openReplicationSession(baseDN, 18, 100, replServerPort, 5000, true);
     Monitor monitor = new Monitor();
     DirectoryServer.registerMonitorProvider(monitor);
 
@@ -117,7 +117,7 @@
         assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
         "The received replication message is not an ADD msg");
 
-        assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
+        assertEquals(addMsg.getDN(), personEntry.getDN(),
         "The received ADD replication message is not for the excepted DN");
       }
 
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
index 23abf96..1536cbc 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -71,12 +71,12 @@
   private Entry personWithSecondUniqueID;
 
   private Entry  user3Entry;
-  private String user3dn;
+  private DN user3dn;
   private String user3UUID;
 
   private String baseUUID;
 
-  private String user1dn;
+  private DN user1dn;
   private String user1entrysecondUUID;
   private String user1entryUUID;
 
@@ -88,9 +88,9 @@
   private String domain1uid;
   private String domain2uid;
   private String domain3uid;
-  private String domain1dn;
-  private String domain2dn;
-  private String domain3dn;
+  private DN domain1dn;
+  private DN domain2dn;
+  private DN domain3dn;
   private Entry domain1;
   private Entry domain2;
   private Entry domain3;
@@ -167,7 +167,7 @@
      */
     user1entryUUID = "33333333-3333-3333-3333-333333333333";
     user1entrysecondUUID = "22222222-2222-2222-2222-222222222222";
-    user1dn = "uid=user1,ou=People," + TEST_ROOT_DN_STRING;
+    user1dn = DN.decode("uid=user1,ou=People," + TEST_ROOT_DN_STRING);
     String entryWithUUIDldif = "dn: "+ user1dn + "\n"
       + "objectClass: top\n" + "objectClass: person\n"
       + "objectClass: organizationalPerson\n"
@@ -204,7 +204,7 @@
       TestCaseUtils.entryFromLdifString(entryWithSecondUUID);
 
     user3UUID = "44444444-4444-4444-4444-444444444444";
-    user3dn = "uid=user3,ou=People," + TEST_ROOT_DN_STRING;
+    user3dn = DN.decode("uid=user3,ou=People," + TEST_ROOT_DN_STRING);
     String user3LDIFEntry = "dn: "+ user3dn + "\n"
       + "objectClass: top\n" + "objectClass: person\n"
       + "objectClass: organizationalPerson\n"
@@ -222,9 +222,9 @@
       + "entryUUID: " + user3UUID + "\n";
     user3Entry = TestCaseUtils.entryFromLdifString(user3LDIFEntry);
 
-    domain1dn = "dc=domain1,ou=People," + TEST_ROOT_DN_STRING;
-    domain2dn = "dc=domain2,dc=domain1,ou=People," + TEST_ROOT_DN_STRING;
-    domain3dn = "dc=domain3,dc=domain1,ou=People," + TEST_ROOT_DN_STRING;
+    domain1dn = DN.decode("dc=domain1,ou=People," + TEST_ROOT_DN_STRING);
+    domain2dn = DN.decode("dc=domain2,dc=domain1,ou=People," + TEST_ROOT_DN_STRING);
+    domain3dn = DN.decode("dc=domain3,dc=domain1,ou=People," + TEST_ROOT_DN_STRING);
     domain1 = TestCaseUtils.entryFromLdifString(
         "dn:" + domain1dn + "\n"
         + "objectClass:domain\n"
@@ -284,15 +284,14 @@
     // Clean replication server database from previous run
     cleanUpReplicationServersDB();
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
 
     /*
      * Open a session to the replicationServer using the broker API.
      * This must use a different serverId to that of the directory server.
      */
     ReplicationBroker broker =
-      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
-
+      openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true);
 
     try
     {
@@ -304,12 +303,12 @@
 
 
       // Disable the directory server receive status.
-      setReceiveStatus(synchroServerEntry.getDN().toString(), false);
+      setReceiveStatus(synchroServerEntry.getDN(), false);
 
 
       // Create and publish an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-          personWithUUIDEntry.getDN().toString(),
+          personWithUUIDEntry.getDN(),
           user1entryUUID,
           baseUUID,
           personWithUUIDEntry.getObjectClassAttribute(),
@@ -325,11 +324,11 @@
           + "receive status was disabled");
 
       // Enable the directory server receive status.
-      setReceiveStatus(synchroServerEntry.getDN().toString(), true);
+      setReceiveStatus(synchroServerEntry.getDN(), true);
 
       // Create and publish another update message to add an entry.
       addMsg = new AddMsg(gen.newCSN(),
-          personWithUUIDEntry.getDN().toString(),
+          personWithUUIDEntry.getDN(),
           user1entryUUID,
           baseUUID,
           personWithUUIDEntry.getObjectClassAttribute(),
@@ -344,7 +343,7 @@
 
       // Delete the entries to clean the database.
       DeleteMsg delMsg =
-          new DeleteMsg(personWithUUIDEntry.getDN().toString(),
+          new DeleteMsg(personWithUUIDEntry.getDN(),
           gen.newCSN(), user1entryUUID);
       broker.publish(delMsg);
       resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false);
@@ -372,14 +371,14 @@
     // Clean replication server database from previous run
     cleanUpReplicationServersDB();
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
 
     /*
      * Open a session to the replicationServer using the broker API.
      * This must use a different serverId to that of the directory server.
      */
     ReplicationBroker broker =
-      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
+      openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true);
 
     try
     {
@@ -392,7 +391,7 @@
 
       // Create and publish an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-          personWithUUIDEntry.getDN().toString(),
+          personWithUUIDEntry.getDN(),
           user1entryUUID,
           baseUUID,
           personWithUUIDEntry.getObjectClassAttribute(),
@@ -443,9 +442,7 @@
       }
 
       // Delete the entries to clean the database.
-      DeleteMsg delMsg =
-          new DeleteMsg(personWithUUIDEntry.getDN().toString(),
-          gen.newCSN(), user1entryUUID);
+      DeleteMsg delMsg = new DeleteMsg(personWithUUIDEntry.getDN(), gen.newCSN(), user1entryUUID);
       broker.publish(delMsg);
       resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false);
 
@@ -473,8 +470,8 @@
   public void modifyConflicts()
        throws Exception
   {
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
-    final DN dn1 = DN.decode("cn=test1," + baseDn.toString());
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN dn1 = DN.decode("cn=test1," + baseDN.toString());
     final AttributeType attrType =
          DirectoryServer.getAttributeType("displayname");
     final AttributeType entryuuidType =
@@ -489,13 +486,13 @@
      * This must use a different serverId to that of the directory server.
      */
     ReplicationBroker broker =
-        openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
+        openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true);
 
     try
     {
       // Add the first test entry.
       TestCaseUtils.addEntry(
-          "dn: cn=test1," + baseDn.toString(),
+          "dn: cn=test1," + baseDN.toString(),
           "displayname: Test1",
           "objectClass: top",
           "objectClass: person",
@@ -519,7 +516,7 @@
       CSN t2 = new CSN(changeTime, 0, 4);
 
       // Simulate the ordering t2:replace:B followed by t1:add:A that
-      updateMonitorCount(baseDn, monitorAttr);
+      updateMonitorCount(baseDN, monitorAttr);
 
       // Replay a replace of a value B at time t2 on a second server.
       Attribute attr = Attributes.create(attrType, "B");
@@ -562,7 +559,7 @@
       t2 = new CSN(changeTime, 0, 4);
 
       // Simulate the ordering t2:delete:displayname followed by t1:replace:A
-      updateMonitorCount(baseDn, monitorAttr);
+      updateMonitorCount(baseDN, monitorAttr);
 
       // Replay an delete of attribute displayname at time t2 on a second server.
       attr = Attributes.empty(attrType);
@@ -615,7 +612,7 @@
     logError(Message.raw(Category.SYNC, Severity.INFORMATION,
         "Starting replication test : namingConflicts"));
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
     String resolvedMonitorAttr = "resolved-naming-conflicts";
     String unresolvedMonitorAttr = "unresolved-naming-conflicts";
 
@@ -627,7 +624,7 @@
      * This must use a serverId different from the LDAP server ID
      */
     ReplicationBroker broker =
-      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
+      openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true);
 
     try
     {
@@ -646,7 +643,7 @@
      */
     // create the entry with a given DN
     AddMsg addMsg = new AddMsg(gen.newCSN(),
-        personWithUUIDEntry.getDN().toString(),
+        personWithUUIDEntry.getDN(),
         user1entryUUID,
         baseUUID,
         personWithUUIDEntry.getObjectClassAttribute(),
@@ -663,7 +660,7 @@
     ModifyMsg modMsg = new ModifyMsg(gen.newCSN(),
         DN.decode("cn=something,ou=People," + TEST_ROOT_DN_STRING), mods,
         user1entryUUID);
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     int AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modMsg);
 
@@ -692,7 +689,7 @@
         personWithUUIDEntry.getDN(), mods,
         user1entryUUID);
 
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modMsg);
 
@@ -716,7 +713,7 @@
 
     //  create the entry with a given DN and unique ID
     addMsg = new AddMsg(gen.newCSN(),
-        personWithUUIDEntry.getDN().toString(),
+        personWithUUIDEntry.getDN(),
         user1entryUUID, baseUUID,
         personWithUUIDEntry.getObjectClassAttribute(),
         personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
@@ -730,8 +727,8 @@
     // send a modify operation with a wrong unique ID but the same DN
     mods = generatemods("telephonenumber", "02 01 03 05");
     modMsg = new ModifyMsg(gen.newCSN(),
-        DN.decode(user1dn), mods, "10000000-9abc-def0-1234-1234567890ab");
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+        user1dn, mods, "10000000-9abc-def0-1234-1234567890ab");
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modMsg);
 
@@ -759,10 +756,9 @@
      */
     // send a delete operation with a wrong dn but the unique ID of the entry
     // used above
-    DeleteMsg delMsg =
-      new DeleteMsg("cn=anotherdn,ou=People," + TEST_ROOT_DN_STRING,
-          gen.newCSN(), user1entryUUID);
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    DN delDN = DN.decode("cn=anotherdn,ou=People," + TEST_ROOT_DN_STRING);
+    DeleteMsg delMsg = new DeleteMsg(delDN, gen.newCSN(), user1entryUUID);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(delMsg);
 
@@ -784,7 +780,7 @@
 
     //  create an entry with a given DN and unique ID
     addMsg = new AddMsg(gen.newCSN(),
-        personWithUUIDEntry.getDN().toString(),
+        personWithUUIDEntry.getDN(),
         user1entryUUID, baseUUID,
         personWithUUIDEntry.getObjectClassAttribute(),
         personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
@@ -797,11 +793,11 @@
 
     //  create an entry with the same DN and another unique ID
     addMsg = new AddMsg(gen.newCSN(),
-        personWithSecondUniqueID.getDN().toString(),
+        personWithSecondUniqueID.getDN(),
         user1entrysecondUUID, baseUUID,
         personWithSecondUniqueID.getObjectClassAttribute(),
         personWithSecondUniqueID.getAttributes(), new ArrayList<Attribute>());
-    updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    updateMonitorCount(baseDN, unresolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(addMsg);
 
@@ -820,13 +816,9 @@
 
 
     //  delete the entries to clean the database.
-    delMsg =
-      new DeleteMsg(personWithUUIDEntry.getDN().toString(),
-          gen.newCSN(), user1entryUUID);
+    delMsg = new DeleteMsg(personWithUUIDEntry.getDN(), gen.newCSN(), user1entryUUID);
     broker.publish(delMsg);
-    delMsg =
-      new DeleteMsg(personWithSecondUniqueID.getDN().toString(),
-          gen.newCSN(), user1entrysecondUUID);
+    delMsg = new DeleteMsg(personWithSecondUniqueID.getDN(), gen.newCSN(), user1entrysecondUUID);
     broker.publish(delMsg);
     resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false);
     resultEntry = getEntry(personWithSecondUniqueID.getDN(), 10000, false);
@@ -841,19 +833,20 @@
      * Simulate this by trying to add an entry below a DN that does not
      * exist but with a parent ID that exist.
      */
+    String addDN = "uid=new person,o=nothere,o=below,ou=People," + TEST_ROOT_DN_STRING;
     addMsg = new AddMsg(gen.newCSN(),
-        "uid=new person,o=nothere,o=below,ou=People," + TEST_ROOT_DN_STRING,
+        DN.decode(addDN),
         user1entryUUID,
         baseUUID,
         personWithUUIDEntry.getObjectClassAttribute(),
         personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(addMsg);
 
     //  Check that the entry has been created in the local DS.
-    resultEntry = getEntry(
-        DN.decode("uid=new person,ou=People," + TEST_ROOT_DN_STRING), 10000, true);
+    DN newPersonDN = DN.decode("uid=new person,ou=People," + TEST_ROOT_DN_STRING);
+    resultEntry = getEntry(newPersonDN, 10000, true);
     assertNotNull(resultEntry,
         "The ADD replication message was not applied");
     assertEquals(getMonitorDelta(), 1);
@@ -871,15 +864,11 @@
      * To achieve this send a delete operation with a correct DN
      * but a wrong unique ID.
      */
-
-    delMsg =
-      new DeleteMsg("uid=new person,ou=People," + TEST_ROOT_DN_STRING,
-          gen.newCSN(), "11111111-9abc-def0-1234-1234567890ab");
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    delMsg = new DeleteMsg(newPersonDN, gen.newCSN(), "11111111-9abc-def0-1234-1234567890ab");
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(delMsg);
-    resultEntry = getEntry(
-          DN.decode("uid=new person,ou=People," + TEST_ROOT_DN_STRING), 10000, true);
+    resultEntry = getEntry(newPersonDN, 10000, true);
 
     // check that the delete operation has not been applied
     assertNotNull(resultEntry,
@@ -902,11 +891,11 @@
      */
 
     ModifyDNMsg  modDnMsg = new ModifyDNMsg(
-        "uid=new person,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(),
+        newPersonDN, gen.newCSN(),
         user1entryUUID, baseUUID, false,
         "uid=wrong, ou=people," + TEST_ROOT_DN_STRING,
         "uid=newrdn");
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
 
@@ -928,15 +917,15 @@
      * same test but by giving a bad entry DN
      */
 
-     modDnMsg = new ModifyDNMsg(
-        "uid=wrong,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(),
+    DN modDN = DN.decode("uid=wrong,ou=People," + TEST_ROOT_DN_STRING);
+    modDnMsg = new ModifyDNMsg(modDN, gen.newCSN(),
         user1entryUUID, null, false, null, "uid=reallynewrdn");
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
 
-    resultEntry = getEntry(
-        DN.decode("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING), 10000, true);
+    DN reallyNewDN = DN.decode("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING);
+    resultEntry = getEntry(reallyNewDN, 10000, true);
 
     // check that the operation has been correctly relayed
     assertNotNull(resultEntry,
@@ -964,7 +953,7 @@
     broker.publish(addMsg);
 
     //  check that the second entry has been added
-    resultEntry = getEntry(DN.decode(user1dn), 10000, true);
+    resultEntry = getEntry(user1dn, 10000, true);
 
     // check that the add operation has been applied
     assertNotNull(resultEntry, "The add operation was not replayed");
@@ -972,8 +961,8 @@
     // try to rename the first entry
     modDnMsg = new ModifyDNMsg(user1dn, gen.newCSN(),
                                user1entrysecondUUID, baseUUID, false,
-                               baseDn.toString(), "uid=reallynewrdn");
-    updateMonitorCount(baseDn, unresolvedMonitorAttr);
+                               baseDN.toString(), "uid=reallynewrdn");
+    updateMonitorCount(baseDN, unresolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
 
@@ -992,27 +981,19 @@
 
 
     // delete the entries to clean the database
-    delMsg =
-      new DeleteMsg("entryUUID = " + user1entrysecondUUID + "+" +
-          DN.decode(user1dn).getRDN().toString() +
-          ",ou=People," + TEST_ROOT_DN_STRING,
-          gen.newCSN(), user1entrysecondUUID);
+    DN delDN2 = DN.decode("entryUUID = " + user1entrysecondUUID + "+"
+        + user1dn.getRDN() + ",ou=People," + TEST_ROOT_DN_STRING);
+    delMsg = new DeleteMsg(delDN2, gen.newCSN(), user1entrysecondUUID);
     broker.publish(delMsg);
-    resultEntry = getEntry(
-          DN.decode("entryUUID = " + user1entrysecondUUID + "+" +
-              DN.decode(user1dn).getRDN().toString() +
-              ",ou=People," + TEST_ROOT_DN_STRING), 10000, false);
+    resultEntry = getEntry(delDN2, 10000, false);
 
     // check that the delete operation has been applied
     assertNull(resultEntry,
         "The DELETE replication message was not replayed");
 
-    delMsg =
-      new DeleteMsg("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING,
-          gen.newCSN(), user1entryUUID);
+    delMsg = new DeleteMsg(reallyNewDN, gen.newCSN(), user1entryUUID);
     broker.publish(delMsg);
-    resultEntry = getEntry(
-        DN.decode("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING), 10000, false);
+    resultEntry = getEntry(reallyNewDN, 10000, false);
 
     //  check that the delete operation has been applied
     assertNull(resultEntry,
@@ -1036,14 +1017,13 @@
      */
 
     // - create parent entry 1 with baseDn1
-    String[] topEntries = new String[1];
-    topEntries[0] = "dn: ou=baseDn1,"+baseDn+"\n" + "objectClass: top\n"
+    String[] topEntries = new String[]{
+    "dn: ou=baseDn1,"+baseDN+"\n" + "objectClass: top\n"
     + "objectClass: organizationalUnit\n"
-    + "entryUUID: 55555555-5555-5555-5555-555555555555\n";
-    Entry entry;
+    + "entryUUID: 55555555-5555-5555-5555-555555555555\n"};
     for (String entryStr : topEntries)
     {
-      entry = TestCaseUtils.entryFromLdifString(entryStr);
+      Entry entry = TestCaseUtils.entryFromLdifString(entryStr);
       AddOperationBasis addOp = new AddOperationBasis(connection,
           InternalClientConnection.nextOperationID(), InternalClientConnection
           .nextMessageID(), null, entry.getDN(), entry.getObjectClasses(),
@@ -1051,16 +1031,15 @@
       addOp.setInternalOperation(true);
       addOp.run();
     }
-    resultEntry = getEntry(
-        DN.decode("ou=baseDn1,"+baseDn), 10000, true);
-    assertNotNull(resultEntry,
-        "Entry not added: ou=baseDn1,"+baseDn);
+    resultEntry = getEntry(DN.decode("ou=baseDn1," + baseDN), 10000, true);
+    assertNotNull(resultEntry, "Entry not added: ou=baseDn1," + baseDN);
 
     // - create Add Msg for user1 with parent entry 1 UUID
+    DN newPersonDN2 = DN.decode("uid=new person,ou=baseDn1," + baseDN);
     addMsg = new AddMsg(gen.newCSN(),
-        "uid=new person,ou=baseDn1,"+baseDn,
+        newPersonDN2,
         user1entryUUID,
-        getEntryUUID(DN.decode("ou=baseDn1,"+baseDn)),
+        getEntryUUID(DN.decode("ou=baseDn1," + baseDN)),
         personWithUUIDEntry.getObjectClassAttribute(),
         personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
 
@@ -1068,21 +1047,20 @@
     ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection,
         InternalClientConnection.nextOperationID(), InternalClientConnection
         .nextMessageID(), null,
-        DN.decode("ou=baseDn1,"+baseDn),
+        DN.decode("ou=baseDN1," + baseDN),
         RDN.decode("ou=baseDn2"), true,
-        baseDn);
+        baseDN);
     modDNOp.run();
 
-    resultEntry = getEntry(
-        DN.decode("ou=baseDn2,"+baseDn), 10000, true);
+    resultEntry = getEntry(DN.decode("ou=baseDn2," + baseDN), 10000, true);
     assertNotNull(resultEntry,
-        "Entry not moved from ou=baseDn1,"+baseDn+" to ou=baseDn2,"+baseDn);
+        "Entry not moved from ou=baseDn1,"+baseDN+" to ou=baseDn2,"+baseDN);
 
     // - add new parent entry 2 with baseDn1
-    String p2 = "dn: ou=baseDn1,"+baseDn+"\n" + "objectClass: top\n"
+    String p2 = "dn: ou=baseDn1,"+baseDN+"\n" + "objectClass: top\n"
          + "objectClass: organizationalUnit\n"
          + "entryUUID: 66666666-6666-6666-6666-666666666666\n";
-    entry = TestCaseUtils.entryFromLdifString(p2);
+    Entry entry = TestCaseUtils.entryFromLdifString(p2);
     AddOperationBasis addOp = new AddOperationBasis(connection,
         InternalClientConnection.nextOperationID(), InternalClientConnection
         .nextMessageID(), null, entry.getDN(), entry.getObjectClasses(),
@@ -1092,20 +1070,16 @@
 
 
     // - publish msg
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(addMsg);
 
     // - check that the DN has been changed to baseDn2
-    resultEntry = getEntry(
-        DN.decode("uid=new person,ou=baseDn1,"+baseDn), 10000, false);
-    assertNull(resultEntry,
-        "The ADD replication message was applied under ou=baseDn1,"+baseDn);
+    resultEntry = getEntry(newPersonDN2, 10000, false);
+    assertNull(resultEntry, "The ADD replication message was applied under ou=baseDn1," + baseDN);
 
-    resultEntry = getEntry(
-        DN.decode("uid=new person,ou=baseDn2,"+baseDn), 10000, true);
-    assertNotNull(resultEntry,
-        "The ADD replication message was NOT applied under ou=baseDn2,"+baseDn);
+    resultEntry = getEntry(DN.decode("uid=new person,ou=baseDn2," + baseDN), 10000, true);
+    assertNotNull(resultEntry, "The ADD replication message was NOT applied under ou=baseDn2," + baseDN);
     assertEquals(getMonitorDelta(), 1);
 
     // Check that there was no administrative alert generated
@@ -1124,17 +1098,17 @@
     addEntry(domain1);
     CSN olderCSN = gen.newCSN();
     Thread.sleep(1000);
-    domain1uid = getEntryUUID(DN.decode(domain1dn));
+    domain1uid = getEntryUUID(domain1dn);
     addEntry(domain2);
-    domain2uid = getEntryUUID(DN.decode(domain2dn));
+    domain2uid = getEntryUUID(domain2dn);
     addEntry(domain3);
-    domain3uid = getEntryUUID(DN.decode(domain3dn));
+    domain3uid = getEntryUUID(domain3dn);
     DN conflictDomain2dn = DN.decode(
         "entryUUID = " + domain2uid + "+dc=domain2,ou=people," + TEST_ROOT_DN_STRING);
     DN conflictDomain3dn = DN.decode(
         "entryUUID = " + domain3uid + "+dc=domain3,ou=people," + TEST_ROOT_DN_STRING);
 
-    updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    updateMonitorCount(baseDN, unresolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
 
     // delete domain1
@@ -1142,7 +1116,7 @@
     broker.publish(delMsg);
 
     // check that the domain1 has correctly been deleted
-    assertNull(getEntry(DN.decode(domain1dn), 10000, false),
+    assertNull(getEntry(domain1dn, 10000, false),
         "The DELETE replication message was not replayed");
 
     // check that domain2 and domain3 have been renamed
@@ -1153,9 +1127,9 @@
 
     // check that the 2 conflicting entries have been correctly marked
     assertTrue(checkEntryHasAttribute(conflictDomain2dn,
-        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn, 1000, true));
+        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn.toString(), 1000, true));
     assertTrue(checkEntryHasAttribute(conflictDomain3dn,
-        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain3dn, 1000, true));
+        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain3dn.toString(), 1000, true));
 
     // check that unresolved conflict count has been incremented
     assertEquals(getMonitorDelta(), 1);
@@ -1177,14 +1151,14 @@
     //
     // add domain1 entry with 2 children : domain2 and domain3
     addEntry(domain1);
-    domain1uid = getEntryUUID(DN.decode(domain1dn));
+    domain1uid = getEntryUUID(domain1dn);
     addEntry(domain2);
-    domain2uid = getEntryUUID(DN.decode(domain2dn));
+    domain2uid = getEntryUUID(domain2dn);
     CSN addCSN = addEntry(domain3);
     gen.adjust(addCSN);
-    domain3uid = getEntryUUID(DN.decode(domain3dn));
+    domain3uid = getEntryUUID(domain3dn);
 
-    updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    updateMonitorCount(baseDN, unresolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
 
     // delete domain1
@@ -1192,7 +1166,7 @@
     broker.publish(delMsg);
 
     // check that the domain1 has correctly been deleted
-    assertNull(getEntry(DN.decode(domain1dn), 10000, false),
+    assertNull(getEntry(domain1dn, 10000, false),
         "The DELETE replication message was not replayed");
 
     // check that domain2 and domain3 have been renamed as conflicting
@@ -1225,7 +1199,7 @@
 
     // check that the entry have been correctly marked as conflicting.
     assertTrue(checkEntryHasAttribute(conflictDomain2dn,
-        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn, 1000, true));
+        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn.toString(), 1000, true));
 
     // check that unresolved conflict count has been incremented
     assertEquals(getMonitorDelta(), 1);
@@ -1235,11 +1209,11 @@
     // this is correctly detected as a resolved conflict.
     // To simulate this simply try a modifyDN on a non existent uid.
     modDnMsg = new ModifyDNMsg(
-        "uid=new person,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(),
+        newPersonDN, gen.newCSN(),
         "33343333-3533-3633-3373-333333833333", baseUUID, false,
         "uid=wrong, ou=people," + TEST_ROOT_DN_STRING,
         "uid=newrdn");
-    updateMonitorCount(baseDn, resolvedMonitorAttr);
+    updateMonitorCount(baseDN, resolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
     // unfortunately it is difficult to check that the operation
@@ -1267,10 +1241,10 @@
      * Check that a conflict is detected when an entry is
      * moved below an entry that does not exist.
      */
-    updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    updateMonitorCount(baseDN, unresolvedMonitorAttr);
     AlertCount = DummyAlertHandler.getAlertCount();
     modDnMsg = new ModifyDNMsg(
-        "uid=new person,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(),
+        newPersonDN, gen.newCSN(),
         "33333333-3333-3333-3333-333333333333",
         "12343333-3533-3633-3333-333333833333" , false,
         "uid=wrong, ou=people," + TEST_ROOT_DN_STRING,
@@ -1291,7 +1265,7 @@
 
     // check that the entry have been correctly marked as conflicting.
     assertTrue(checkEntryHasAttribute(
-        DN.decode("uid=new person,ou=baseDn2,"+baseDn),
+        DN.decode("uid=new person,ou=baseDn2," + baseDN),
         LDAPReplicationDomain.DS_SYNC_CONFLICT,
         "uid=newrdn,ou=baseDn2,ou=People," + TEST_ROOT_DN_STRING, 1000, true));
     }
@@ -1346,10 +1320,10 @@
     // Cleanup from previous run
     cleanupTest();
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
 
     ReplicationBroker broker =
-      openReplicationSession(baseDn,  27, 100, replServerPort, 2000, true);
+      openReplicationSession(baseDN,  27, 100, replServerPort, 2000, true);
 
     try {
       CSNGenerator gen = new CSNGenerator( 27, 0);
@@ -1382,8 +1356,8 @@
         assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
         "The received replication message is not an ADD msg : " + addMsg);
 
-        assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
-        "The received ADD replication message is not for the excepted DN : " + addMsg);
+        assertEquals(addMsg.getDN(), personEntry.getDN(),
+            "The received ADD replication message is not for the excepted DN : " + addMsg);
       }
 
       // Modify the entry
@@ -1402,11 +1376,11 @@
       ModifyMsg modMsg = (ModifyMsg) msg;
 
       modMsg.createOperation(connection);
-      assertTrue(DN.decode(modMsg.getDn()).compareTo(personEntry.getDN()) == 0,
+      assertEquals(modMsg.getDN(), personEntry.getDN(),
       "The received MODIFY replication message is not for the excepted DN : " + modMsg);
 
       // Modify the entry DN
-      DN newDN = DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING) ;
+      DN newDN = DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING);
       ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection,
           InternalClientConnection.nextOperationID(), InternalClientConnection
           .nextMessageID(), null, personEntry.getDN(), RDN
@@ -1425,14 +1399,13 @@
       ModifyDNMsg moddnMsg = (ModifyDNMsg) msg;
       moddnMsg.createOperation(connection);
 
-      assertTrue(DN.decode(moddnMsg.getDn()).compareTo(personEntry.getDN()) == 0,
+      assertEquals(moddnMsg.getDN(), personEntry.getDN(),
       "The received MODIFY_DN message is not for the excepted DN : " + moddnMsg);
 
       // Delete the entry
       DeleteOperationBasis delOp = new DeleteOperationBasis(connection,
           InternalClientConnection.nextOperationID(), InternalClientConnection
-          .nextMessageID(), null, DN
-          .decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING));
+          .nextMessageID(), null, newDN);
       delOp.run();
       assertFalse(DirectoryServer.entryExists(newDN),
       "Unable to delete the new person Entry");
@@ -1443,8 +1416,7 @@
       "The received replication message is not a MODIFY DN msg : " + msg);
       DeleteMsg delMsg = (DeleteMsg) msg;
       delMsg.createOperation(connection);
-      assertTrue(DN.decode(delMsg.getDn()).compareTo(DN
-          .decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING)) == 0,
+      assertEquals(delMsg.getDN(), newDN,
       "The received DELETE message is not for the excepted DN : " + delMsg);
 
       /*
@@ -1454,7 +1426,7 @@
        * Start by testing the Add message reception
        */
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-          personWithUUIDEntry.getDN().toString(),
+          personWithUUIDEntry.getDN(),
           user1entryUUID, baseUUID,
           personWithUUIDEntry.getObjectClassAttribute(),
           personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
@@ -1501,7 +1473,7 @@
       /*
        * Test the Reception of Modify Dn Msg
        */
-      moddnMsg = new ModifyDNMsg(personWithUUIDEntry.getDN().toString(),
+      moddnMsg = new ModifyDNMsg(personWithUUIDEntry.getDN(),
           gen.newCSN(),
           user1entryUUID, null,
           true, null, "uid= new person");
@@ -1509,8 +1481,7 @@
         moddnMsg.setAssured(true);
       broker.publish(moddnMsg);
 
-      resultEntry = getEntry(
-          DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING), 10000, true);
+      resultEntry = getEntry(newDN, 10000, true);
 
       assertNotNull(resultEntry,
       "The modify DN replication message was not applied");
@@ -1518,13 +1489,11 @@
       /*
        * Test the Reception of Delete Msg
        */
-      delMsg = new DeleteMsg("uid= new person,ou=People," + TEST_ROOT_DN_STRING,
-          gen.newCSN(), user1entryUUID);
+      delMsg = new DeleteMsg(newDN, gen.newCSN(), user1entryUUID);
       if (assured)
         delMsg.setAssured(true);
       broker.publish(delMsg);
-      resultEntry = getEntry(
-          DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING), 10000, false);
+      resultEntry = getEntry(newDN, 10000, false);
 
       assertNull(resultEntry,
       "The DELETE replication message was not replayed");
@@ -1570,14 +1539,14 @@
     logError(Message.raw(Category.SYNC, Severity.INFORMATION,
         "Starting replication test : infiniteReplayLoop"));
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
 
     // Clean replication server database from previous run
     cleanUpReplicationServersDB();
 
     Thread.sleep(2000);
     ReplicationBroker broker =
-      openReplicationSession(baseDn,  11, 100, replServerPort, 1000, true);
+      openReplicationSession(baseDN,  11, 100, replServerPort, 1000, true);
     try
     {
       CSNGenerator gen = new CSNGenerator( 11, 0);
@@ -1609,7 +1578,7 @@
       addOp.run();
       assertEquals(addOp.getResultCode(), ResultCode.SUCCESS);
 
-      long initialCount = getMonitorAttrValue(baseDn, "replayed-updates");
+      long initialCount = getMonitorAttrValue(baseDN, "replayed-updates");
 
       // Get the UUID of the test entry.
       Entry resultEntry = getEntry(tmp.getDN(), 1, true);
@@ -1625,14 +1594,12 @@
       try
       {
         // Publish a delete message for this test entry.
-        DeleteMsg delMsg = new DeleteMsg(tmp.getDN().toString(),
-                                         gen.newCSN(),
-                                         uuid);
+        DeleteMsg delMsg = new DeleteMsg(tmp.getDN(), gen.newCSN(), uuid);
         broker.publish(delMsg);
 
         // Wait for the operation to be replayed.
         long endTime = System.currentTimeMillis() + 5000;
-        while (getMonitorAttrValue(baseDn, "replayed-updates") == initialCount &&
+        while (getMonitorAttrValue(baseDN, "replayed-updates") == initialCount &&
              System.currentTimeMillis() < endTime)
         {
           Thread.sleep(100);
@@ -1646,7 +1613,7 @@
 
       // If the replication replay loop was detected and broken then the
       // counter will still be updated even though the replay was unsuccessful.
-      if (getMonitorAttrValue(baseDn, "replayed-updates") == initialCount)
+      if (getMonitorAttrValue(baseDN, "replayed-updates") == initialCount)
       {
         fail("Operation was not replayed");
       }
@@ -1665,28 +1632,19 @@
    * @param enable Specifies whether the receive status should be enabled
    * or disabled.
    */
-  private static void setReceiveStatus(String syncConfigDN, boolean enable)
+  private static void setReceiveStatus(DN syncConfigDN, boolean enable)
   {
     ArrayList<ByteString> valueList = new ArrayList<ByteString>(1);
-    if (enable)
-    {
-      valueList.add(ByteString.valueOf("TRUE"));
-    }
-    else
-    {
-      valueList.add(ByteString.valueOf("FALSE"));
-    }
+    valueList.add(ByteString.valueOf(enable ? "TRUE" : "FALSE"));
     LDAPAttribute a = new LDAPAttribute("ds-cfg-receive-status", valueList);
 
     LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
 
-    ArrayList<RawModification> modList = new ArrayList<RawModification>(1);
+    List<RawModification> modList = new ArrayList<RawModification>(1);
     modList.add(m);
 
-    InternalClientConnection conn =
-         InternalClientConnection.getRootConnection();
-    ByteString rawEntryDN =
-         ByteString.valueOf(syncConfigDN);
+    InternalClientConnection conn = InternalClientConnection.getRootConnection();
+    ByteString rawEntryDN = ByteString.valueOf(syncConfigDN.toString());
     ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
 
     ResultCode resultCode = internalModify.getResultCode();
@@ -1712,7 +1670,7 @@
     logError(Message.raw(Category.SYNC, Severity.INFORMATION,
         "Starting synchronization test : CSNGeneratorAdjust"));
 
-    final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING);
 
     // Clean replication server database from previous run
     cleanUpReplicationServersDB();
@@ -1722,7 +1680,7 @@
      * This must use a different serverId to that of the directory server.
      */
     ReplicationBroker broker =
-      openReplicationSession(baseDn, serverId, 100, replServerPort, 1000, true);
+      openReplicationSession(baseDN, serverId, 100, replServerPort, 1000, true);
 
     try
     {
@@ -1736,7 +1694,7 @@
       // Create and publish an update message to add an entry.
       AddMsg addMsg = new AddMsg(
           gen.newCSN(),
-          user3dn.toString(),
+          user3dn,
           user3UUID,
           baseUUID,
           user3Entry.getObjectClassAttribute(),
@@ -1772,11 +1730,7 @@
           "The MOD timestamp should have been adjusted to the ADD one");
 
       // Delete the entries to clean the database.
-      DeleteMsg delMsg =
-          new DeleteMsg(
-          user3Entry.getDN().toString(),
-          gen.newCSN(),
-          user3UUID);
+      DeleteMsg delMsg = new DeleteMsg(user3Entry.getDN(), gen.newCSN(), user3UUID);
       broker.publish(delMsg);
 
       // Check that the delete operation has been applied.
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
index 4793cb8..d17efe7 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -259,7 +259,7 @@
     private final int degradedStatusThreshold = 5000;
 
     // Parameters set with received server start message
-    private String baseDn;
+    private DN baseDN;
     private long generationId = -1L;
     private ServerState serverState;
     private int windowSize = -1;
@@ -270,7 +270,7 @@
 
     /** parameters at handshake are ok */
     private boolean handshakeOk = false;
-    /** 
+    /**
      * signal that the current scenario the RS must execute reached the point
      * where the main code can perform test assertion.
      */
@@ -430,7 +430,7 @@
         // Receive server start
         ServerStartMsg serverStartMsg = (ServerStartMsg) session.receive();
 
-        baseDn = serverStartMsg.getBaseDn();
+        baseDN = serverStartMsg.getBaseDN();
         serverState = serverStartMsg.getServerState();
         generationId = serverStartMsg.getGenerationId();
         windowSize = serverStartMsg.getWindowSize();
@@ -439,8 +439,7 @@
         // Send replication server start
         String serverURL = ("localhost:" + port);
         ReplServerStartMsg replServerStartMsg = new ReplServerStartMsg(serverId,
-          serverURL, baseDn, windowSize, serverState,
-          generationId, sslEncryption,
+          serverURL, baseDN, windowSize, serverState, generationId, sslEncryption,
           groupId, degradedStatusThreshold);
         session.publish(replServerStartMsg);
 
@@ -581,7 +580,7 @@
       try
       {
         AddMsg addMsg =
-          new AddMsg(gen.newCSN(), entry.getDN().toString(), UUID.randomUUID().toString(),
+          new AddMsg(gen.newCSN(), entry.getDN(), UUID.randomUUID().toString(),
                      parentUid,
                      entry.getObjectClassAttribute(),
                      entry.getAttributes(), null );
@@ -683,7 +682,7 @@
     {
       assertEquals(updateMsg.isAssured(), isAssured,
           "msg=" + ((updateMsg instanceof AddMsg)?
-              ((AddMsg)updateMsg).getDn():updateMsg.getCSN()));
+              ((AddMsg)updateMsg).getDN():updateMsg.getCSN()));
       if (isAssured)
       {
         assertEquals(updateMsg.getAssuredMode(), assuredMode);
@@ -1148,20 +1147,7 @@
       replicationServer.shutdown();
     }
 
-    if (safeDataDomainCfgEntry != null)
-    {
-      removeDomain(safeDataDomainCfgEntry);
-    }
-
-    if (safeReadDomainCfgEntry != null)
-    {
-      removeDomain(safeReadDomainCfgEntry);
-    }
-
-    if (notAssuredDomainCfgEntry != null)
-    {
-      removeDomain(notAssuredDomainCfgEntry);
-    }
+    removeDomain(safeDataDomainCfgEntry, safeReadDomainCfgEntry, notAssuredDomainCfgEntry);
   }
 
   /**
@@ -1783,12 +1769,12 @@
    * - assured-sr-server-not-acknowledged-updates in SR mode
    * - assured-sd-server-timeout-updates in SD mode
    */
-  protected Map<Integer,Integer> getErrorsByServers(DN baseDn,
+  protected Map<Integer,Integer> getErrorsByServers(DN baseDN,
     AssuredMode assuredMode) throws Exception
   {
     // Find monitoring entry for requested base DN
     String monitorFilter =
-         "(&(cn=Directory server*)(domain-name=" + baseDn + "))";
+         "(&(cn=Directory server*)(domain-name=" + baseDN + "))";
 
     InternalSearchOperation op;
     int count = 0;
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
index 09f688e..c32a385 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -72,27 +72,26 @@
 public class FractionalReplicationTest extends ReplicationTestCase {
 
   /** The RS */
-  private ReplicationServer replicationServer = null;
+  private ReplicationServer replicationServer;
   /** RS port */
   private int replServerPort = -1;
   /** Represents the real domain to test (replays and filters) */
-  private Entry fractionalDomainCfgEntry = null;
+  private Entry fractionalDomainCfgEntry;
   /** The domain used to send updates to the real domain */
-  private FakeReplicationDomain replicationDomain = null;
+  private FakeReplicationDomain replicationDomain;
 
   /** Ids of servers */
   private static final int DS1_ID = 1; // fractional domain
   private static final int DS2_ID = 2; // fake domain
   private static final int RS_ID = 91; // replication server
 
-  private final String testName = this.getClass().getSimpleName();
+  private final String testName = getClass().getSimpleName();
 
   /** Fractional mode */
   private static final int EXCLUDE_FRAC_MODE = 0;
   private static final int INCLUDE_FRAC_MODE = 1;
 
-  int initWindow = 100;
-  private CSNGenerator gen = null;
+  private CSNGenerator gen;
 
   /** The tracer object for the debug logger */
   private static final DebugTracer TRACER = getTracer();
@@ -410,11 +409,8 @@
       replicationDomain = null;
     }
 
-    if (fractionalDomainCfgEntry != null)
-    {
-      removeDomain(fractionalDomainCfgEntry);
-      fractionalDomainCfgEntry = null;
-    }
+    removeDomain(fractionalDomainCfgEntry);
+    fractionalDomainCfgEntry = null;
 
     remove(replicationServer);
     replicationServer = null;
@@ -654,8 +650,8 @@
 
   private long readGenIdFromSuffixRootEntry(String rootDn) throws Exception
   {
-    DN baseDn = DN.decode(rootDn);
-    Entry resultEntry = getEntry(baseDn, 1000, true);
+    DN baseDN = DN.decode(rootDn);
+    Entry resultEntry = getEntry(baseDN, 1000, true);
     if (resultEntry == null)
     {
       debugInfo("Entry not found <" + rootDn + ">");
@@ -716,7 +712,7 @@
 
       // Create an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID,
         null,
         entry.getObjectClassAttribute(),
@@ -755,15 +751,12 @@
       mods.add(mod);
 
       // Add modification for the synchro attribute (added attribute)
-      attr =
-        Attributes.create(SYNCHRO_OPTIONAL_ATTR.toLowerCase(), SYNCHRO_OPTIONAL_ATTR + "Value");
+      attr = Attributes.create(SYNCHRO_OPTIONAL_ATTR.toLowerCase(), SYNCHRO_OPTIONAL_ATTR + "Value");
       mod = new Modification(ModificationType.ADD, attr);
       mods.add(mod);
 
-      DN entryDn = DN.decode((firstBackend ? ENTRY_DN : ENTRY_DN2));
-      ModifyMsg modifyMsg = new ModifyMsg(gen.newCSN(), entryDn, mods,
-        ENTRY_UUID);
-
+      DN entryDn = DN.decode(firstBackend ? ENTRY_DN : ENTRY_DN2);
+      ModifyMsg modifyMsg = new ModifyMsg(gen.newCSN(), entryDn, mods, ENTRY_UUID);
       replicationDomain.publish(modifyMsg);
   }
 
@@ -1375,7 +1368,7 @@
 
       // Create an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID,
         null,
         entry.getObjectClassAttribute(),
@@ -1411,7 +1404,7 @@
 
       // Create an update message to add an entry.
       addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID2,
         null,
         entry.getObjectClassAttribute(),
@@ -1471,7 +1464,7 @@
 
       // Create an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID,
         null,
         entry.getObjectClassAttribute(),
@@ -1509,7 +1502,7 @@
 
       // Create an update message to add an entry.
       addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID2,
         null,
         entry.getObjectClassAttribute(),
@@ -1568,7 +1561,7 @@
 
       // Create an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID,
         null,
         entry.getObjectClassAttribute(),
@@ -1593,7 +1586,7 @@
       DN newEntryDn = DN.decode(newEntryName);
 
       // Create modify dn message to modify the entry.
-      ModifyDNMsg modDnMsg = new ModifyDNMsg(entryName, gen.newCSN(),
+      ModifyDNMsg modDnMsg = new ModifyDNMsg(DN.decode(entryName), gen.newCSN(),
         ENTRY_UUID, ENTRY_UUID3, false, TEST_ROOT_DN_STRING,
         "displayName=ValueToBeKept", null);
 
@@ -1649,7 +1642,7 @@
 
       // Create an update message to add an entry.
       AddMsg addMsg = new AddMsg(gen.newCSN(),
-        entry.getDN().toString(),
+        entry.getDN(),
         ENTRY_UUID,
         null,
         entry.getObjectClassAttribute(),
@@ -1674,7 +1667,7 @@
       DN newEntryDn = DN.decode(newEntryName);
 
       // Create modify dn message to modify the entry.
-      ModifyDNMsg modDnMsg = new ModifyDNMsg(entryName, gen.newCSN(),
+      ModifyDNMsg modDnMsg = new ModifyDNMsg(DN.decode(entryName), gen.newCSN(),
         ENTRY_UUID, ENTRY_UUID3, false, TEST_ROOT_DN_STRING,
         "displayName=ValueToBeKept", null);
 
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
index d15bce3..13b00ac 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -118,7 +118,7 @@
   throws Exception
   {
     final int serverId = 123;
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
     TestCaseUtils.initializeTestBackend(true);
     ReplicationServer rs = createReplicationServer();
     // Create Replication Server and Domain
@@ -127,7 +127,7 @@
     try
     {
       long startTime = TimeThread.getTime();
-    final DN dn1 = DN.decode("cn=test1," + baseDn.toString());
+      final DN dn1 = DN.decode("cn=test1," + baseDN.toString());
     final AttributeType histType =
       DirectoryServer.getAttributeType(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
 
@@ -136,7 +136,7 @@
 
     // Add the first test entry.
     TestCaseUtils.addEntry(
-        "dn: cn=test1," + baseDn.toString(),
+        "dn: cn=test1," + baseDN.toString(),
         "displayname: Test1",
         "objectClass: top",
         "objectClass: person",
@@ -148,7 +148,7 @@
 
     // Perform a first modification to update the historical attribute
     int resultCode = TestCaseUtils.applyModifications(false,
-        "dn: cn=test1," + baseDn.toString(),
+        "dn: cn=test1," + baseDN.toString(),
         "changetype: modify",
         "add: description",
     "description: foo");
@@ -170,7 +170,7 @@
     // Perform a 2nd modification to update the hist attribute with
     // a second value
     resultCode = TestCaseUtils.applyModifications(false,
-        "dn: cn=test1," + baseDn.toString(),
+        "dn: cn=test1," + baseDN.toString(),
         "changetype: modify",
         "add: description",
     "description: bar");
@@ -214,7 +214,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
       remove(rs);
     }
   }
@@ -228,7 +228,7 @@
   public void buildAndPublishMissingChangesSeveralEntriesTest()
   throws Exception
   {
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
     TestCaseUtils.initializeTestBackend(true);
     ReplicationServer rs = createReplicationServer();
     // Create Replication Server and Domain
@@ -241,9 +241,9 @@
     "Starting replication test : changesCmpTest"));
 
     // Add 3 entries.
-    String dnTest1 = "cn=test1," + baseDn.toString();
-    String dnTest2 = "cn=test2," + baseDn.toString();
-    String dnTest3 = "cn=test3," + baseDn.toString();
+    DN dnTest1 = DN.decode("cn=test1," + baseDN.toString());
+    DN dnTest2 = DN.decode("cn=test2," + baseDN.toString());
+    DN dnTest3 = DN.decode("cn=test3," + baseDN.toString());
     TestCaseUtils.addEntry(
         "dn: " + dnTest3,
         "displayname: Test1",
@@ -264,7 +264,7 @@
         "cn: test1",
         "sn: test"
     );
-    TestCaseUtils.deleteEntry(DN.decode(dnTest3));
+    TestCaseUtils.deleteEntry(dnTest3);
     TestCaseUtils.addEntry(
         "dn: " + dnTest2,
         "displayname: Test1",
@@ -278,12 +278,12 @@
 
     // Perform modifications on the 2 entries
     int resultCode = TestCaseUtils.applyModifications(false,
-        "dn: cn=test2," + baseDn.toString(),
+        "dn: cn=test2," + baseDN,
         "changetype: modify",
         "add: description",
     "description: foo");
     resultCode = TestCaseUtils.applyModifications(false,
-        "dn: cn=test1," + baseDn.toString(),
+        "dn: cn=test1," + baseDN,
         "changetype: modify",
         "add: description",
     "description: foo");
@@ -302,23 +302,23 @@
     assertEquals(opList.size(), 5, "buildAndPublishMissingChanges should return 5 operations");
     ReplicationMsg msg = opList.removeFirst();
     assertTrue(msg.getClass().equals(AddMsg.class));
-    assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest1);
+    assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest1);
     msg = opList.removeFirst();
     assertTrue(msg.getClass().equals(DeleteMsg.class));
-    assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest3);
+    assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest3);
     msg = opList.removeFirst();
     assertTrue(msg.getClass().equals(AddMsg.class));
-    assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest2);
+    assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest2);
     msg = opList.removeFirst();
     assertTrue(msg.getClass().equals(ModifyMsg.class));
-    assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest2);
+    assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest2);
     msg = opList.removeFirst();
     assertTrue(msg.getClass().equals(ModifyMsg.class));
-    assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest1);
+    assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest1);
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
       rs.remove();
     }
   }
@@ -339,9 +339,9 @@
   private LDAPReplicationDomain createReplicationDomain(int dsId)
           throws DirectoryException, ConfigException
   {
-    DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
     DomainFakeCfg domainConf =
-      new DomainFakeCfg(baseDn, dsId, replServers, AssuredType.NOT_ASSURED,
+      new DomainFakeCfg(baseDN, dsId, replServers, AssuredType.NOT_ASSURED,
       2, 1, 0, null);
     LDAPReplicationDomain replicationDomain =
       MultimasterReplication.createNewDomain(domainConf);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java
index 936dc0d..4bd1af6 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java
@@ -27,8 +27,10 @@
  */
 package org.opends.server.replication.plugin;
 
-import static org.opends.server.TestCaseUtils.*;
-import static org.testng.Assert.*;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
 
 import org.opends.server.TestCaseUtils;
 import org.opends.server.core.DirectoryServer;
@@ -46,10 +48,8 @@
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.UUID;
+import static org.opends.server.TestCaseUtils.*;
+import static org.testng.Assert.*;
 
 /**
  * Tests the Historical class.
@@ -234,7 +234,7 @@
   {
     final DN dn1 = DN.decode("cn=test1," + TEST_ROOT_DN_STRING);
     final DN dn2 = DN.decode("cn=test2," + TEST_ROOT_DN_STRING);
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
     final AttributeType attrType =
          DirectoryServer.getAttributeType("displayname");
     final AttributeType entryuuidType =
@@ -245,7 +245,7 @@
      * This must use a different serverId to that of the directory server.
      */
     ReplicationBroker broker =
-      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
+      openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true);
 
 
     // Clear the backend and create top entrye
@@ -475,10 +475,10 @@
         FakeAddOperation addOp = (FakeAddOperation) op;
         assertTrue(addOp.getCSN() != null);
         AddMsg addmsg = addOp.generateMessage();
-        assertTrue(dn1.equals(DN.decode(addmsg.getDn())));
-        assertTrue(addmsg.getEntryUUID().equals(EntryHistorical.getEntryUUID(entry)));
+        assertEquals(dn1, addmsg.getDN());
+        assertEquals(addmsg.getEntryUUID(), EntryHistorical.getEntryUUID(entry));
         String parentId = LDAPReplicationDomain.findEntryUUID(dn1.getParent());
-        assertTrue(addmsg.getParentEntryUUID().equals(parentId));
+        assertEquals(addmsg.getParentEntryUUID(), parentId);
         addmsg.createOperation(InternalClientConnection.getRootConnection());
       }
       else if (count == 1)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java
index f2fcd61..bccf35d 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java
@@ -74,10 +74,10 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue();
-    DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>());
+    DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>());
     conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES);
 
     LDAPReplicationDomain domain =
@@ -116,7 +116,7 @@
       CSN csn2 = gen.newCSN();
 
       ModifyDNMsg  modDnMsg = new ModifyDNMsg(
-          entry.getDN().toNormalizedString(), csn2,
+          entry.getDN(), csn2,
           entryUUID, parentUUID, false,
           TEST_ROOT_DN_STRING,
       "uid=simultaneous2");
@@ -130,7 +130,7 @@
       // This MODIFY DN uses an older DN and should therefore be cancelled
       // at replay time.
       modDnMsg = new ModifyDNMsg(
-          entry.getDN().toNormalizedString(), csn1,
+          entry.getDN(), csn1,
           entryUUID, parentUUID, false,
           TEST_ROOT_DN_STRING,
       "uid=simulatneouswrong");
@@ -148,7 +148,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -163,10 +163,10 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue();
-    DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>());
+    DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>());
     conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES);
 
     LDAPReplicationDomain domain =
@@ -205,7 +205,7 @@
       // Now try to add the same entry with same DN but a different
       // unique ID though the replication
       AddMsg addMsg = new AddMsg(csn1,
-            entry.getDN().toNormalizedString(),
+            entry.getDN(),
             "c9cb8c3c-615a-4122-865d-50323aaaed48", parentUUID,
             entry.getObjectClasses(), entry.getUserAttributes(),
             null);
@@ -230,7 +230,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -247,10 +247,10 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue();
-    DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>());
+    DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>());
     conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES);
 
     LDAPReplicationDomain domain =
@@ -289,7 +289,7 @@
       // Now try to add the same entry with same DN but a different
       // unique ID though the replication
       AddMsg addMsg = new AddMsg(csn1,
-            entry.getDN().toNormalizedString(),
+            entry.getDN(),
             "c9cb8c3c-615a-4122-865d-50323aaaed48", parentUUID,
             entry.getObjectClasses(), entry.getUserAttributes(),
             null);
@@ -319,7 +319,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -352,10 +352,10 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue();
-    DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>());
+    DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>());
     conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES);
 
     LDAPReplicationDomain domain =
@@ -396,11 +396,7 @@
       String parentUUID = getEntryUUID(parentEntry.getDN());
 
       CSN csn2 = gen.newCSN();
-
-      DeleteMsg  delMsg = new DeleteMsg(
-          parentEntry.getDN().toNormalizedString(),
-          csn2,
-          parentUUID);
+      DeleteMsg  delMsg = new DeleteMsg(parentEntry.getDN(), csn2, parentUUID);
       delMsg.setSubtreeDelete(true);
 
       // Put the message in the replay queue
@@ -416,7 +412,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -425,10 +421,10 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue();
-    DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>());
+    DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>());
     conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES);
 
     LDAPReplicationDomain domain =
@@ -475,11 +471,7 @@
       String childUUID = getEntryUUID(childEntry.getDN());
 
       CSN csn2 = gen.newCSN();
-
-      DeleteMsg  delMsg = new DeleteMsg(
-          parentEntry.getDN().toNormalizedString(),
-          csn2,
-          parentUUID);
+      DeleteMsg  delMsg = new DeleteMsg(parentEntry.getDN(), csn2, parentUUID);
       // NOT SUBTREE
 
       // Put the message in the replay queue
@@ -500,7 +492,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
     }
   }
 
@@ -509,10 +501,10 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    final DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
+    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
 
     TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue();
-    DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>());
+    DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>());
     conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES);
 
     LDAPReplicationDomain domain =
@@ -558,7 +550,7 @@
       String childUUID = "44444444-4444-4444-4444-444444444444";
       AddMsg addMsg = new AddMsg(
           csn1,
-          childEntry.getDN().toString(),
+          childEntry.getDN(),
           childUUID,
           parentUUID,
           childEntry.getObjectClassAttribute(),
@@ -583,7 +575,7 @@
     }
     finally
     {
-      MultimasterReplication.deleteDomain(baseDn);
+      MultimasterReplication.deleteDomain(baseDN);
     }
   }
 }
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
index 84fad9b..3a62970 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
@@ -785,12 +785,8 @@
       this.nEntries = nEntries;
 
       // Send init msg to warn dest server it is going do be initialized
-      RoutableMsg initTargetMsg = null;
-
-      initTargetMsg =
-          new InitializeTargetMsg(EXAMPLE_DN, serverId, destId,
-          serverId, nEntries, initWindow);
-
+      RoutableMsg initTargetMsg = new InitializeTargetMsg(
+          EXAMPLE_DN_, serverId, destId, serverId, nEntries, initWindow);
       rb.publish(initTargetMsg);
 
       // Send top entry for the domain
@@ -1103,7 +1099,7 @@
 
       // Create an update message to add an entry.
       return new AddMsg(gen.newCSN(),
-        personWithUUIDEntry.getDN().toString(),
+        personWithUUIDEntry.getDN(),
         userEntryUUID,
         null,
         personWithUUIDEntry.getObjectClassAttribute(),
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
index 7847c17..02b771b 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
@@ -49,10 +49,10 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+import static org.opends.messages.ReplicationMessages.*;
 import static org.opends.server.replication.protocol.OperationContext.*;
 import static org.opends.server.replication.protocol.ProtocolVersion.*;
 import static org.opends.server.util.StaticUtils.*;
-import static org.opends.messages.ReplicationMessages.*;
 import static org.testng.Assert.*;
 
 /**
@@ -91,12 +91,12 @@
   @DataProvider(name="createReplServerStartData")
   public Object [][] createReplServerStartData() throws Exception
   {
-    String baseDN = "o=test";
+    DN baseDN = DN.decode("o=test");
     ServerState state = new ServerState();
     state.update(new CSN(0, 0,0));
     Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0};
 
-    baseDN = "dc=example,dc=com";
+    baseDN = DN.decode("dc=example,dc=com");
     state = new ServerState();
     state.update(new CSN(75, 5,263));
     Object[] set2 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456};
@@ -109,14 +109,14 @@
    * using protocol VLAST and V2 are working.
    */
   @Test(dataProvider="createReplServerStartData")
-  public void replServerStartMsgTestVLASTV2(int serverId, String baseDN, int window,
+  public void replServerStartMsgTestVLASTV2(int serverId, DN baseDN, int window,
          String url, ServerState state, long genId, byte groupId, int degTh) throws Exception
   {
     // TODO: replServerStartMsgTestV3V2 as soon as V3 will have any incompatibility with V2
   }
 
   @Test(dataProvider="createReplServerStartData")
-  public void replServerStartMsgTestVLASTV1(int serverId, String baseDN, int window,
+  public void replServerStartMsgTestVLASTV1(int serverId, DN baseDN, int window,
         String url, ServerState state, long genId, byte groupId, int degTh) throws Exception
   {
     // Create message with no version.
@@ -136,7 +136,7 @@
     assertEquals(msg.getGenerationId(), newMsg.getGenerationId());
     assertEquals(msg.getServerId(), newMsg.getServerId());
     assertEquals(msg.getServerURL(), newMsg.getServerURL());
-    assertEquals(msg.getBaseDn(), newMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
     assertEquals(msg.getWindowSize(), newMsg.getWindowSize());
     assertEquals(msg.getServerState().getCSN(1), newMsg.getServerState().getCSN(1));
     assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption());
@@ -159,7 +159,7 @@
     assertEquals(msg.getGenerationId(), vlastMsg.getGenerationId());
     assertEquals(msg.getServerId(), vlastMsg.getServerId());
     assertEquals(msg.getServerURL(), vlastMsg.getServerURL());
-    assertEquals(msg.getBaseDn(), vlastMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), vlastMsg.getBaseDN());
     assertEquals(msg.getWindowSize(), vlastMsg.getWindowSize());
     assertEquals(msg.getServerState().getCSN(1), vlastMsg.getServerState().getCSN(1));
     assertEquals(msg.getSSLEncryption(), vlastMsg.getSSLEncryption());
@@ -196,6 +196,8 @@
     byte safeDataLevel, List<Attribute> entryAttrList)
   throws Exception
   {
+    final DN dn = DN.decode(rawDN);
+
     // Create VLAST message
     Attribute objectClass = Attributes.create(DirectoryServer
         .getObjectClassAttributeType(), "organization");
@@ -219,7 +221,7 @@
 
     CSN csn = new CSN(TimeThread.getTime(), 123, 45);
 
-    AddMsg msg = new AddMsg(csn, rawDN, "thisIsaUniqueID", "parentUniqueId",
+    AddMsg msg = new AddMsg(csn, dn, "thisIsaUniqueID", "parentUniqueId",
                             objectClass, userAttributes,
                             operationalAttributes);
 
@@ -247,14 +249,14 @@
 
     // Check fields common to both versions
     assertEquals(newMsg.getEntryUUID(), msg.getEntryUUID());
-    assertEquals(newMsg.getDn(), msg.getDn());
+    assertEquals(newMsg.getDN(), msg.getDN());
     assertEquals(newMsg.getCSN(), msg.getCSN());
     assertEquals(newMsg.isAssured(), msg.isAssured());
     assertEquals(newMsg.getParentEntryUUID(), msg.getParentEntryUUID());
 
     // Create an add operation from each message to compare attributes (kept encoded in messages)
-    Operation op = msg.createOperation(connection, rawDN);
-    Operation generatedOperation = newMsg.createOperation(connection, rawDN);
+    Operation op = msg.createOperation(connection, dn);
+    Operation generatedOperation = newMsg.createOperation(connection, dn);
 
     assertEquals(op.getClass(), AddOperationBasis.class);
     assertEquals(generatedOperation.getClass(), AddOperationBasis.class);
@@ -290,7 +292,7 @@
 
     // Check we retrieve original VLAST message (VLAST fields)
     assertEquals(msg.getEntryUUID(), vlastMsg.getEntryUUID());
-    assertEquals(msg.getDn(), vlastMsg.getDn());
+    assertEquals(msg.getDN(), vlastMsg.getDN());
     assertEquals(msg.getCSN(), vlastMsg.getCSN());
     assertEquals(msg.getParentEntryUUID(), vlastMsg.getParentEntryUUID());
     assertEquals(msg.isAssured(), vlastMsg.isAssured());
@@ -315,8 +317,8 @@
     }
 
     //        Create an add operation from each message to compare attributes (kept encoded in messages)
-    op = msg.createOperation(connection, rawDN);
-    generatedOperation = vlastMsg.createOperation(connection, rawDN);
+    op = msg.createOperation(connection, dn);
+    generatedOperation = vlastMsg.createOperation(connection, dn);
 
     assertEquals(op.getClass(), AddOperationBasis.class);
     assertEquals(generatedOperation.getClass(), AddOperationBasis.class);
@@ -371,8 +373,10 @@
     byte safeDataLevel, List<Attribute> entryAttrList)
   throws Exception
   {
+    final DN dn = DN.decode(rawDN);
+
     CSN csn = new CSN(TimeThread.getTime(), 123, 45);
-    DeleteMsg msg = new DeleteMsg(rawDN, csn, "thisIsaUniqueID");
+    DeleteMsg msg = new DeleteMsg(dn, csn, "thisIsaUniqueID");
 
     msg.setAssured(isAssured);
     msg.setAssuredMode(assuredMode);
@@ -399,7 +403,7 @@
 
     // Check fields common to both versions
     assertEquals(newMsg.getEntryUUID(), msg.getEntryUUID());
-    assertEquals(newMsg.getDn(), msg.getDn());
+    assertEquals(newMsg.getDN(), msg.getDN());
     assertEquals(newMsg.getCSN(), msg.getCSN());
     assertEquals(newMsg.isAssured(), msg.isAssured());
 
@@ -426,7 +430,7 @@
 
     // Check we retrieve original VLAST message (VLAST fields)
     assertEquals(msg.getEntryUUID(), vlastMsg.getEntryUUID());
-    assertEquals(msg.getDn(), vlastMsg.getDn());
+    assertEquals(msg.getDN(), vlastMsg.getDN());
     assertEquals(msg.getCSN(), vlastMsg.getCSN());
     assertEquals(msg.isAssured(), vlastMsg.isAssured());
     assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
@@ -570,7 +574,7 @@
 
     // Check fields common to both versions
     assertEquals(newv1Msg.getEntryUUID(), origVlastMsg.getEntryUUID());
-    assertEquals(newv1Msg.getDn(), origVlastMsg.getDn());
+    assertEquals(newv1Msg.getDN(), origVlastMsg.getDN());
     assertEquals(newv1Msg.getCSN(), origVlastMsg.getCSN());
     assertEquals(newv1Msg.isAssured(), origVlastMsg.isAssured());
 
@@ -613,7 +617,7 @@
 
     // Check we retrieve original VLAST message (VLAST fields)
     assertEquals(origVlastMsg.getEntryUUID(), generatedVlastMsg.getEntryUUID());
-    assertEquals(origVlastMsg.getDn(), generatedVlastMsg.getDn());
+    assertEquals(origVlastMsg.getDN(), generatedVlastMsg.getDN());
     assertEquals(origVlastMsg.getCSN(), generatedVlastMsg.getCSN());
     assertEquals(origVlastMsg.isAssured(), generatedVlastMsg.isAssured());
     assertEquals(origVlastMsg.getAssuredMode(), generatedVlastMsg.getAssuredMode());
@@ -731,9 +735,11 @@
                                    List<Attribute> entryAttrList)
          throws Exception
   {
+    final DN dn = DN.decode(rawDN);
+
     // Create VLAST message
     CSN csn = new CSN(TimeThread.getTime(), 596, 13);
-    ModifyDNMsg msg = new ModifyDNMsg(rawDN, csn, uid,
+    ModifyDNMsg msg = new ModifyDNMsg(dn, csn, uid,
                      newParentUid, deleteOldRdn,
                      newSuperior, newRdn, mods);
 
@@ -762,7 +768,7 @@
 
     // Check fields common to both versions
     assertEquals(newMsg.getEntryUUID(), msg.getEntryUUID());
-    assertEquals(newMsg.getDn(), msg.getDn());
+    assertEquals(newMsg.getDN(), msg.getDN());
     assertEquals(newMsg.getCSN(), msg.getCSN());
     assertEquals(newMsg.isAssured(), msg.isAssured());
     assertEquals(newMsg.getNewRDN(), msg.getNewRDN());
@@ -808,7 +814,7 @@
 
     // Check we retrieve original VLAST message (VLAST fields)
     assertEquals(msg.getEntryUUID(), vlastMsg.getEntryUUID());
-    assertEquals(msg.getDn(), vlastMsg.getDn());
+    assertEquals(msg.getDN(), vlastMsg.getDN());
     assertEquals(msg.getCSN(), vlastMsg.getCSN());
     assertEquals(msg.isAssured(), vlastMsg.isAssured());
     assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode());
@@ -913,7 +919,7 @@
   {
     LDAPUpdateMsg msg = (LDAPUpdateMsg) ReplicationMsg.generateMsg(
         hexStringToByteArray(encodedString), ProtocolVersion.REPLICATION_PROTOCOL_V3);
-    assertEquals(msg.getDn(), dn);
+    assertEquals(msg.getDN(), DN.decode(dn));
     assertEquals(msg.getCSN(), csn);
     assertEquals(msg.getClass(), msgType);
     BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3));
@@ -940,7 +946,7 @@
     // parameters
     ServerStartMsg msg = new ServerStartMsg(hexStringToByteArray(oldPdu));
     assertEquals(msg.getServerId(), serverId);
-    assertEquals(msg.getBaseDn(), dn);
+    assertEquals(msg.getBaseDN(), DN.decode(dn));
     assertEquals(msg.getGroupId(), groupId);
     BigInteger bi = new BigInteger(msg.getBytes(getCurrentVersion()));
     assertEquals(bi.toString(16), oldPdu);
@@ -960,13 +966,13 @@
   public void oldReplServerStartPDUs(
       String oldPdu, int serverId, String dn, byte groupId) throws Exception
   {
-    // This is a ServerStartMSg with ServerId=16, baseDn=o=test and groupID=31
+    // This is a ServerStartMSg with ServerId=16, baseDN=o=test and groupID=31
     // For now this test only checks those parameters.
     // It would be nice to complete it with checks for ServerState and other
     // parameters.
     ReplServerStartMsg msg = new ReplServerStartMsg(hexStringToByteArray(oldPdu));
     assertEquals(msg.getServerId(), serverId);
-    assertEquals(msg.getBaseDn(), dn);
+    assertEquals(msg.getBaseDN(), DN.decode(dn));
     assertEquals(msg.getGroupId(), groupId);
     BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3));
     assertEquals(bi.toString(16), oldPdu);
@@ -1226,9 +1232,9 @@
   {
     int sender = 1;
     int dest = 2;
-    String baseDn = "dc=whatever";
+    DN baseDN = DN.decode("dc=whatever");
     int initWindow = 22;
-    Object[] set1 = new Object[] {sender, dest, baseDn, initWindow };
+    Object[] set1 = new Object[] { sender, dest, baseDN, initWindow };
     return new Object [][] { set1};
   }
 
@@ -1238,11 +1244,10 @@
    */
   @Test(enabled=true, dataProvider="createInitializationRequestMsgData")
   public void initializationRequestMsgTestVLASTV3(int sender, int dest,
-      String baseDn, int initWindow)
-  throws Exception
+      DN baseDN, int initWindow) throws Exception
   {
     // Create VLAST message
-    InitializeRequestMsg msg = new InitializeRequestMsg(baseDn, sender, dest, initWindow);
+    InitializeRequestMsg msg = new InitializeRequestMsg(baseDN, sender, dest, initWindow);
 
     // Serialize in V3
     byte[] v3MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3);
@@ -1253,7 +1258,7 @@
     // Check fields common to both versions
     assertEquals(msg.getSenderID(), newMsg.getSenderID());
     assertEquals(msg.getDestination(), newMsg.getDestination());
-    assertEquals(msg.getBaseDn(), newMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
 
     // Check default value for only post V3 fields
     assertEquals(newMsg.getInitWindow(), 0);
@@ -1268,7 +1273,7 @@
     // Check we retrieve original VLAST message (VLAST fields)
     assertEquals(msg.getSenderID(), vlastMsg.getSenderID());
     assertEquals(msg.getDestination(), vlastMsg.getDestination());
-    assertEquals(msg.getBaseDn(), vlastMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), vlastMsg.getBaseDN());
     assertEquals(msg.getInitWindow(), vlastMsg.getInitWindow());
   }
 
@@ -1278,11 +1283,10 @@
     int sender = 1;
     int dest = 2;
     int initiator = 3;
-    String baseDn = "dc=whatever";
+    DN baseDN = DN.decode("dc=whatever");
     int entryCount = 56;
     int initWindow = 22;
-    Object[] set1 = new Object[] {sender, dest, initiator, baseDn,
-        entryCount, initWindow };
+    Object[] set1 = new Object[] {sender, dest, initiator, baseDN, entryCount, initWindow };
     return new Object [][] { set1};
   }
 
@@ -1292,11 +1296,11 @@
    */
   @Test(enabled=true, dataProvider="createInitializeTargetMsgData")
   public void initializeTargetMsgTestVLASTV3(int sender, int dest,
-      int initiator, String baseDn, int entryCount, int initWindow)
+      int initiator, DN baseDN, int entryCount, int initWindow)
   throws Exception
   {
     // Create VLAST message
-    InitializeTargetMsg msg = new InitializeTargetMsg(baseDn, sender, dest,
+    InitializeTargetMsg msg = new InitializeTargetMsg(baseDN, sender, dest,
         initiator, entryCount, initWindow);
 
     // Serialize in V3
@@ -1410,6 +1414,6 @@
         ProtocolVersion.REPLICATION_PROTOCOL_V3);
     assertEquals(msg.getDestination(), dest);
     assertEquals(msg.getSenderID(), sender);
-    assertEquals(msg.getBaseDn().toString(), baseDN);
+    assertEquals(msg.getBaseDN().toString(), baseDN);
   }
 }
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
index 8e8ec6e..1a3ae3d 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -30,6 +30,7 @@
 import java.util.*;
 import java.util.zip.DataFormatException;
 
+import org.assertj.core.api.Assertions;
 import org.opends.messages.Message;
 import org.opends.server.controls.SubtreeDeleteControl;
 import org.opends.server.core.*;
@@ -58,6 +59,9 @@
 @SuppressWarnings("javadoc")
 public class SynchronizationMsgTest extends ReplicationTestCase
 {
+
+  private DN TEST_ROOT_DN;
+
   /**
    * Set up the environment for performing the tests in this Class.
    *
@@ -69,6 +73,7 @@
   public void setUp() throws Exception
   {
     super.setUp();
+    TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING);
   }
 
   /**
@@ -169,18 +174,12 @@
     // Get ECL entry attributes
     assertAttributesEqual(entryAttrList, generatedMsg.getEclIncludes());
 
-    Operation op = msg.createOperation(connection);
-    Operation generatedOperation = generatedMsg.createOperation(connection);
-
-    assertEquals(op.getClass(), ModifyOperationBasis.class);
-    assertEquals(generatedOperation.getClass(), ModifyOperationBasis.class);
-
-    ModifyOperation mod1 = (ModifyOperation) op;
-    ModifyOperation mod2 = (ModifyOperation) generatedOperation;
+    ModifyOperation mod1 = (ModifyOperation) msg.createOperation(connection);
+    ModifyOperation mod2 = (ModifyOperation) generatedMsg.createOperation(connection);
 
     assertEquals(mod1.getRawEntryDN(), mod2.getRawEntryDN());
-    assertEquals( mod1.getAttachment(SYNCHROCONTEXT),
-                  mod2.getAttachment(SYNCHROCONTEXT));
+    assertEquals(mod1.getAttachment(SYNCHROCONTEXT),
+                 mod2.getAttachment(SYNCHROCONTEXT));
     assertEquals(mod1.getModifications(), mod2.getModifications());
   }
 
@@ -223,7 +222,7 @@
     assertFalse(msg.equals(new Object()));
 
     // Check CSN
-    assertTrue(msg.equals(generatedMsg));
+    assertEquals(msg, generatedMsg);
 
     // Check hashCode
     assertEquals(msg.hashCode(), generatedMsg.hashCode());
@@ -232,11 +231,11 @@
     assertEquals(msg.compareTo(generatedMsg), 0);
 
     // Check Get / Set DN
-    assertTrue(DN.decode(msg.getDn()).equals(DN.decode(generatedMsg.getDn())));
+    assertEquals(msg.getDN(), generatedMsg.getDN());
 
-    String fakeDN = "cn=fake cn";
-    msg.setDn(fakeDN) ;
-    assertEquals(msg.getDn(), fakeDN) ;
+    DN fakeDN = DN.decode("cn=fake cn");
+    msg.setDN(fakeDN) ;
+    assertEquals(msg.getDN(), fakeDN) ;
 
     // Check uuid
     assertEquals(msg.getEntryUUID(), generatedMsg.getEntryUUID());
@@ -312,14 +311,8 @@
     // Get ECL entry attributes
     assertAttributesEqual(entryAttrList, generatedMsg.getEclIncludes());
 
-    Operation generatedOperation = generatedMsg.createOperation(connection);
-
-    assertEquals(generatedOperation.getClass(), DeleteOperationBasis.class);
-    assertTrue(
-        (subtree?(generatedOperation.getRequestControl(SubtreeDeleteControl.DECODER)!=null):
-          (generatedOperation.getRequestControl(SubtreeDeleteControl.DECODER)==null)));
-
-    DeleteOperation mod2 = (DeleteOperationBasis) generatedOperation;
+    DeleteOperation mod2 = (DeleteOperation) generatedMsg.createOperation(connection);
+    assertEquals(mod2.getRequestControl(SubtreeDeleteControl.DECODER) != null, subtree);
     assertEquals(op.getRawEntryDN(), mod2.getRawEntryDN());
 
     // Create an update message from this op
@@ -414,14 +407,8 @@
     // Get ECL entry attributes
     assertAttributesEqual(entryAttrList, generatedMsg.getEclIncludes());
 
-    Operation oriOp = msg.createOperation(connection);
-    Operation generatedOperation = generatedMsg.createOperation(connection);
-
-    assertEquals(oriOp.getClass(), ModifyDNOperationBasis.class);
-    assertEquals(generatedOperation.getClass(), ModifyDNOperationBasis.class);
-
-    ModifyDNOperation moddn1 = (ModifyDNOperation) oriOp;
-    ModifyDNOperation moddn2 = (ModifyDNOperation) generatedOperation;
+    ModifyDNOperation moddn1 = (ModifyDNOperation) msg.createOperation(connection);
+    ModifyDNOperation moddn2 = (ModifyDNOperation) generatedMsg.createOperation(connection);
 
     assertEquals(msg.getCSN(), generatedMsg.getCSN());
     assertEquals(moddn1.getRawEntryDN(), moddn2.getRawEntryDN());
@@ -450,6 +437,8 @@
     byte safeDataLevel, List<Attribute> entryAttrList)
          throws Exception
   {
+    final DN dn = DN.decode(rawDN);
+
     Attribute objectClass = Attributes.create(DirectoryServer
         .getObjectClassAttributeType(), "organization");
     Map<ObjectClass, String> objectClassList =
@@ -472,7 +461,7 @@
 
     CSN csn = new CSN(TimeThread.getTime(), 123,  45);
 
-    AddMsg msg = new AddMsg(csn, rawDN, "thisIsaUniqueID", "parentUniqueId",
+    AddMsg msg = new AddMsg(csn, dn, "thisIsaUniqueID", "parentUniqueId",
                             objectClass, userAttributes,
                             operationalAttributes);
 
@@ -503,14 +492,8 @@
     // Create an new Add Operation from the current addMsg
     InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
-    Operation op = msg.createOperation(connection, rawDN);
-    Operation generatedOperation = generatedMsg.createOperation(connection, rawDN);
-
-    assertEquals(op.getClass(), AddOperationBasis.class);
-    assertEquals(generatedOperation.getClass(), AddOperationBasis.class);
-
-    AddOperation addOp = (AddOperation) op;
-    AddOperation genAddOp = (AddOperation) generatedOperation;
+    AddOperation addOp = msg.createOperation(connection, dn);
+    AddOperation genAddOp = generatedMsg.createOperation(connection, dn);
 
     assertEquals(addOp.getRawEntryDN(), genAddOp.getRawEntryDN());
     assertEquals(addOp.getAttachment(SYNCHROCONTEXT), genAddOp.getAttachment(SYNCHROCONTEXT));
@@ -522,8 +505,6 @@
     assertEquals(msg.toString(), generatedMsg.toString());
 
     //Create an Add operation and generate and Add msg from it
-    DN dn = DN.decode(rawDN);
-
     AddOperation addOpB = new AddOperationBasis(connection,
         1, 1, null, dn, objectClassList, userAttList, opList);
     LocalBackendAddOperation localAddOp = new LocalBackendAddOperation(addOpB);
@@ -668,7 +649,7 @@
     DeleteMsg delmsg = new DeleteMsg(op);
     long changeNumber = 21;
 
-    String baseDN = "dc=example,dc=com";
+    DN baseDN = DN.decode("dc=example,dc=com");
 
     // create a cookie
     MultiDomainServerState cookie =
@@ -679,7 +660,7 @@
     // Constructor test
     ECLUpdateMsg msg1 = new ECLUpdateMsg(delmsg, cookie, baseDN, changeNumber);
     assertTrue(msg1.getCookie().equalsTo(cookie));
-    assertTrue(msg1.getBaseDN().equalsIgnoreCase(baseDN));
+    assertEquals(msg1.getBaseDN(), baseDN);
     assertEquals(msg1.getChangeNumber(), changeNumber);
     DeleteMsg delmsg2 = (DeleteMsg)msg1.getUpdateMsg();
     assertEquals(delmsg.compareTo(delmsg2), 0);
@@ -688,8 +669,8 @@
     ECLUpdateMsg msg2 = new ECLUpdateMsg(msg1.getBytes(getCurrentVersion()));
     assertTrue(msg2.getCookie().equalsTo(msg2.getCookie()));
     assertTrue(msg2.getCookie().equalsTo(cookie));
-    assertTrue(msg2.getBaseDN().equalsIgnoreCase(msg1.getBaseDN()));
-    assertTrue(msg2.getBaseDN().equalsIgnoreCase(baseDN));
+    assertEquals(msg2.getBaseDN(), msg1.getBaseDN());
+    assertEquals(msg2.getBaseDN(), baseDN);
     assertEquals(msg2.getChangeNumber(), msg1.getChangeNumber());
     assertEquals(msg2.getChangeNumber(), changeNumber);
 
@@ -702,7 +683,7 @@
   @DataProvider(name="createServerStartData")
   public Object [][] createServerStartData() throws Exception
   {
-    String baseDN = TEST_ROOT_DN_STRING;
+    DN baseDN = TEST_ROOT_DN;
     ServerState state = new ServerState();
     state.update(new CSN(0, 0,0));
     Object[] set1 = new Object[] {1, baseDN, 0, state, 0L, false, (byte)0};
@@ -723,7 +704,7 @@
    * by checking that : msg == new ServerStartMsg(msg.getBytes()).
    */
   @Test(enabled=true,dataProvider="createServerStartData")
-  public void serverStartMsgTest(int serverId, String baseDN, int window,
+  public void serverStartMsgTest(int serverId, DN baseDN, int window,
          ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception
   {
     ServerStartMsg msg = new ServerStartMsg(
@@ -732,7 +713,7 @@
     ServerStartMsg newMsg = new ServerStartMsg(msg.getBytes(getCurrentVersion()));
     assertEquals(msg.getServerId(), newMsg.getServerId());
     assertEquals(msg.getServerURL(), newMsg.getServerURL());
-    assertEquals(msg.getBaseDn(), newMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
     assertEquals(msg.getWindowSize(), newMsg.getWindowSize());
     assertEquals(msg.getHeartbeatInterval(), newMsg.getHeartbeatInterval());
     assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption());
@@ -746,7 +727,7 @@
   @DataProvider(name="createReplServerStartData")
   public Object [][] createReplServerStartData() throws Exception
   {
-    String baseDN = TEST_ROOT_DN_STRING;
+    DN baseDN = TEST_ROOT_DN;
     ServerState state = new ServerState();
     state.update(new CSN(0, 0,0));
     Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0};
@@ -767,16 +748,15 @@
    * by checking that : msg == new ReplServerStartMsg(msg.getBytes()).
    */
   @Test(enabled=true,dataProvider="createReplServerStartData")
-  public void replServerStartMsgTest(int serverId, String baseDN, int window,
+  public void replServerStartMsgTest(int serverId, DN baseDN, int window,
          String url, ServerState state, long genId, byte groupId, int degTh) throws Exception
   {
     ReplServerStartMsg msg = new ReplServerStartMsg(serverId,
-        url, baseDN, window, state, genId,
-        true, groupId, degTh);
+        url, baseDN, window, state, genId, true, groupId, degTh);
     ReplServerStartMsg newMsg = new ReplServerStartMsg(msg.getBytes(getCurrentVersion()));
     assertEquals(msg.getServerId(), newMsg.getServerId());
     assertEquals(msg.getServerURL(), newMsg.getServerURL());
-    assertEquals(msg.getBaseDn(), newMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
     assertEquals(msg.getWindowSize(), newMsg.getWindowSize());
     assertEquals(msg.getServerState().getCSN(1),
         newMsg.getServerState().getCSN(1));
@@ -791,7 +771,7 @@
   @DataProvider(name="createReplServerStartDSData")
   public Object [][] createReplServerStartDSData() throws Exception
   {
-    String baseDN = TEST_ROOT_DN_STRING;
+    DN baseDN = TEST_ROOT_DN;
     ServerState state = new ServerState();
     state.update(new CSN(0, 0, 0));
     Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0, 0, 0};
@@ -812,7 +792,7 @@
    * by checking that : msg == new ReplServerStartMsg(msg.getBytes()).
    */
   @Test(dataProvider="createReplServerStartDSData")
-  public void replServerStartDSMsgTest(int serverId, String baseDN, int window,
+  public void replServerStartDSMsgTest(int serverId, DN baseDN, int window,
          String url, ServerState state, long genId, byte groupId, int degTh,
          int weight, int connectedDSNumber) throws Exception
   {
@@ -822,7 +802,7 @@
     ReplServerStartDSMsg newMsg = new ReplServerStartDSMsg(msg.getBytes(getCurrentVersion()));
     assertEquals(msg.getServerId(), newMsg.getServerId());
     assertEquals(msg.getServerURL(), newMsg.getServerURL());
-    assertEquals(msg.getBaseDn(), newMsg.getBaseDn());
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
     assertEquals(msg.getWindowSize(), newMsg.getWindowSize());
     assertEquals(msg.getServerState().getCSN(1),
         newMsg.getServerState().getCSN(1));
@@ -874,20 +854,15 @@
   @DataProvider(name="createTopologyData")
   public Object [][] createTopologyData() throws Exception
   {
-    List<String> urls1 = new ArrayList<String>();
-    urls1.add("ldap://ldap.iplanet.com/" + TEST_ROOT_DN_STRING + "??sub?(sn=Jensen)");
-    urls1.add("ldaps://ldap.iplanet.com:4041/uid=bjensen,ou=People," +
-      TEST_ROOT_DN_STRING + "?cn,mail,telephoneNumber");
-
-    List<String> urls2 = new ArrayList<String>();
-
-    List<String> urls3 = new ArrayList<String>();
-    urls3.add("ldaps://host:port/dc=foo??sub?(sn=One Entry)");
-
-    List<String> urls4 = new ArrayList<String>();
-    urls4.add("ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)");
-    urls4.add("ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)");
-
+    List<String> urls1 = newList(
+        "ldap://ldap.iplanet.com/" + TEST_ROOT_DN_STRING + "??sub?(sn=Jensen)",
+        "ldaps://ldap.iplanet.com:4041/uid=bjensen,ou=People,"
+            + TEST_ROOT_DN_STRING + "?cn,mail,telephoneNumber");
+    List<String> urls2 = newList();
+    List<String> urls3 = newList("ldaps://host:port/dc=foo??sub?(sn=One Entry)");
+    List<String> urls4 = newList(
+        "ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)",
+        "ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)");
 
     Set<String> a1 = newSet();
     Set<String> a2 = newSet("dc");
@@ -896,17 +871,14 @@
 
     DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, 154631, ServerStatus.FULL_UPDATE_STATUS,
       false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1, a1, (short)1);
-
     DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, -227896, ServerStatus.DEGRADED_STATUS,
       true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2, a2, (short)2);
-
     DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, 0, ServerStatus.NORMAL_STATUS,
       false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3, a3, (short)3);
     DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, 0, ServerStatus.BAD_GEN_ID_STATUS,
       true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4, a4, (short)4);
-
     DSInfo dsInfo5 = new DSInfo(452436, "dsHost5:555", 45591, 0, ServerStatus.NORMAL_STATUS,
-        false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5);
+      false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5);
 
     List<DSInfo> dsList1 = newList(dsInfo1);
     List<DSInfo> dsList2 = newList();
@@ -1021,8 +993,8 @@
     assertEquals(msg.getAssuredMode(), newMsg.getAssuredMode());
     assertEquals(msg.getSafeDataLevel(), newMsg.getSafeDataLevel());
     assertEquals(msg.getReferralsURLs(), newMsg.getReferralsURLs());
-    assertTrue(attrs.equals(newMsg.getEclIncludes()));
-    assertTrue(attrs.equals(newMsg.getEclIncludesForDeletes()));
+    Assertions.assertThat(attrs).isEqualTo(newMsg.getEclIncludes());
+    Assertions.assertThat(attrs).isEqualTo(newMsg.getEclIncludesForDeletes());
   }
 
   /**
@@ -1210,11 +1182,11 @@
     int sender = 1;
     int target = 56789;
     InitializeRequestMsg msg = new InitializeRequestMsg(
-        TEST_ROOT_DN_STRING, sender, target, 100);
+        TEST_ROOT_DN, sender, target, 100);
     InitializeRequestMsg newMsg = new InitializeRequestMsg(msg.getBytes(getCurrentVersion()),getCurrentVersion());
     assertEquals(msg.getSenderID(), newMsg.getSenderID());
     assertEquals(msg.getDestination(), newMsg.getDestination());
-    assertTrue(msg.getBaseDn().equals(newMsg.getBaseDn()));
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
   }
 
   /**
@@ -1230,20 +1202,19 @@
     int initWindow = 100;
 
     InitializeTargetMsg msg = new InitializeTargetMsg(
-        TEST_ROOT_DN_STRING, senderID, targetID, requestorID, entryCount, initWindow);
+        TEST_ROOT_DN, senderID, targetID, requestorID, entryCount, initWindow);
     InitializeTargetMsg newMsg = new InitializeTargetMsg(msg.getBytes(getCurrentVersion()),getCurrentVersion());
     assertEquals(msg.getSenderID(), newMsg.getSenderID());
     assertEquals(msg.getDestination(), newMsg.getDestination());
     assertEquals(msg.getInitiatorID(), newMsg.getInitiatorID());
     assertEquals(msg.getEntryCount(), newMsg.getEntryCount());
-    assertTrue(msg.getBaseDN().equals(newMsg.getBaseDN())) ;
+    assertEquals(msg.getBaseDN(), newMsg.getBaseDN());
 
     assertEquals(senderID, newMsg.getSenderID());
     assertEquals(targetID, newMsg.getDestination());
     assertEquals(requestorID, newMsg.getInitiatorID());
     assertEquals(entryCount, newMsg.getEntryCount());
-    assertTrue(TEST_ROOT_DN_STRING.equals(newMsg.getBaseDN())) ;
-
+    assertEquals(TEST_ROOT_DN, newMsg.getBaseDN());
   }
 
   /**
@@ -1290,7 +1261,7 @@
    * by checking that : msg == new ServerStartMsg(msg.getBytes()).
    */
   @Test(enabled=true,dataProvider="createServerStartData")
-  public void startECLMsgTest(int serverId, String baseDN, int window,
+  public void startECLMsgTest(int serverId, DN baseDN, int window,
          ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception
   {
     ServerStartECLMsg msg = new ServerStartECLMsg(
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java
index 93c1a8f..8305b7b 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java
@@ -329,7 +329,7 @@
 
       FakeReplicationServer fakeReplicationServer = new FakeReplicationServer(
         rsPort, serverId, assured, assuredMode, (byte)safeDataLevel, (byte)groupId,
-        TEST_ROOT_DN_STRING, generationId);
+        DN.decode(TEST_ROOT_DN_STRING), generationId);
 
       // Connect fake RS to the real RS
       fakeReplicationServer.connect(serverState);
@@ -596,9 +596,7 @@
     public void sendNewFakeUpdate(boolean useAssured) throws TimeoutException
     {
       // Create a new delete update message (the simplest to create)
-      DeleteMsg delMsg =
-          new DeleteMsg(getBaseDNString(), gen.newCSN(),
-        UUID.randomUUID().toString());
+      DeleteMsg delMsg = new DeleteMsg(getBaseDN(), gen.newCSN(), UUID.randomUUID().toString());
 
       // Send it (this uses the defined assured conf at constructor time)
       if (useAssured)
@@ -622,22 +620,22 @@
   {
 
     private boolean shutdown = false;
-    private Session session = null;
+    private Session session;
 
     /** Parameters given at constructor time */
     private int port;
     private int serverId = -1;
-    boolean isAssured = false; // Default value for config
-    AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config
-    byte safeDataLevel = (byte) 1; // Default value for config
-    private String baseDn = null;
+    private boolean isAssured = false; // Default value for config
+    private AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config
+    private byte safeDataLevel = 1; // Default value for config
+    private DN baseDN;
     private long generationId = -1L;
-    private byte groupId = (byte) -1;
+    private byte groupId = -1;
     private boolean sslEncryption = false;
     /** The scenario this RS is expecting */
     private int scenario = -1;
 
-    private CSNGenerator gen = null;
+    private CSNGenerator gen;
 
     /** False if a received update had assured parameters not as expected */
     private boolean everyUpdatesAreOk = true;
@@ -658,16 +656,16 @@
      * @param assuredMode the expected assured mode of the incoming updates (also used for outgoing updates)
      * @param safeDataLevel the expected safe data level of the incoming updates (also used for outgoing updates)
      * @param groupId our group id
-     * @param baseDn the basedn we connect with, to the real RS
+     * @param baseDN the basedn we connect with, to the real RS
      * @param generationId the generation id we use at connection to real RS
      */
     public FakeReplicationServer(int port, int serverId, boolean assured,
       AssuredMode assuredMode, int safeDataLevel,
-      byte groupId, String baseDn, long generationId)
+      byte groupId, DN baseDN, long generationId)
     {
       this.port = port;
       this.serverId = serverId;
-      this.baseDn = baseDn;
+      this.baseDN = baseDN;
       this.generationId = generationId;
       this.groupId = groupId;
       this.isAssured = assured;
@@ -684,7 +682,7 @@
     public AckMsg sendNewFakeUpdate() throws Exception
     {
         // Create a new delete update message (the simplest to create)
-        DeleteMsg delMsg = new DeleteMsg(baseDn, gen.newCSN(),
+        DeleteMsg delMsg = new DeleteMsg(baseDN, gen.newCSN(),
         UUID.randomUUID().toString());
 
         // Send del message in assured mode
@@ -725,9 +723,8 @@
 
         // Send our repl server start msg
         ReplServerStartMsg replServerStartMsg = new ReplServerStartMsg(serverId,
-          fakeUrl, baseDn, 100, serverState,
-          generationId, sslEncryption,
-          groupId, 5000);
+          fakeUrl, baseDN, 100, serverState,
+          generationId, sslEncryption, groupId, 5000);
         session.publish(replServerStartMsg);
 
         // Read repl server start msg
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
index 3968de9..a3c3552 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
@@ -483,16 +483,12 @@
       long time = TimeThread.getTime();
       int ts = 1;
       CSN csn1 = new CSN(time, ts++, SERVER_ID_1);
-      DeleteMsg delMsg1 =
-          new DeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1,
-              "ECLBasicMsg1uid");
+      DeleteMsg delMsg1 = newDeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, "ECLBasicMsg1uid");
       server01.publish(delMsg1);
       debugInfo(tn, "publishes:" + delMsg1);
 
       CSN csn2 = new CSN(time, ts++, SERVER_ID_2);
-      DeleteMsg delMsg2 =
-          new DeleteMsg("o=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2,
-              "ECLBasicMsg2uid");
+      DeleteMsg delMsg2 = newDeleteMsg("o=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2, "ECLBasicMsg2uid");
       server02.publish(delMsg2);
       debugInfo(tn, "publishes:" + delMsg2);
 
@@ -614,7 +610,7 @@
       long time = TimeThread.getTime();
 
       CSN csn1 = new CSN(time, 1, SERVER_ID_1);
-      DeleteMsg delMsg1 = new DeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, "ECLBasicMsg1uid");
+      DeleteMsg delMsg1 = newDeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, "ECLBasicMsg1uid");
       server01.publish(delMsg1);
       debugInfo(tn, "publishes:" + delMsg1);
 
@@ -876,26 +872,31 @@
   }
 
   private void publishDeleteMsgInOTest(ReplicationBroker broker, CSN csn,
-      String tn, int i)
+      String tn, int i) throws DirectoryException
   {
     publishDeleteMsg(broker, csn, tn, i, TEST_ROOT_DN_STRING);
   }
 
   private void publishDeleteMsgInOTest2(ReplicationBroker broker, CSN csn,
-      String tn, int i)
+      String tn, int i) throws DirectoryException
   {
     publishDeleteMsg(broker, csn, tn, i, TEST_ROOT_DN_STRING2);
   }
 
   private void publishDeleteMsg(ReplicationBroker broker, CSN csn, String tn,
-      int i, String baseDn)
+      int i, String baseDn) throws DirectoryException
   {
     String dn = "uid=" + tn + i + "," + baseDn;
-    DeleteMsg delMsg = new DeleteMsg(dn, csn, tn + "uuid" + i);
+    DeleteMsg delMsg = newDeleteMsg(dn, csn, tn + "uuid" + i);
     broker.publish(delMsg);
     debugInfo(tn, " publishes " + delMsg.getCSN());
   }
 
+  private DeleteMsg newDeleteMsg(String dn, CSN csn, String entryUUID) throws DirectoryException
+  {
+    return new DeleteMsg(DN.decode(dn), csn, entryUUID);
+  }
+
   private InternalSearchOperation searchOnCookieChangelog(String filterString,
       String cookie, String testName, ResultCode expectedResultCode)
       throws Exception
@@ -1100,7 +1101,7 @@
       Entry entry = TestCaseUtils.entryFromLdifString(lentry);
       AddMsg addMsg = new AddMsg(
           csns[csnCounter],
-          "uid="+tn+"2," + TEST_ROOT_DN_STRING,
+          DN.decode("uid="+tn+"2," + TEST_ROOT_DN_STRING),
           user1entryUUID,
           baseUUID,
           entry.getObjectClassAttribute(),
@@ -1370,7 +1371,7 @@
 
       // Produce update on this suffix
       DeleteMsg delMsg =
-          new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0],
+          newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0],
             "11111111-1112-1113-1114-111111111114");
       debugInfo(tn, " publishing " + delMsg.getCSN());
       server01.publish(delMsg);
@@ -1464,7 +1465,7 @@
       // Produces change 2
       final CSN csn = csns[1];
       String expectedDn = "uid=" + tn + "2," +  TEST_ROOT_DN_STRING;
-      delMsg = new DeleteMsg(expectedDn, csn,
+      delMsg = newDeleteMsg(expectedDn, csn,
          "11111111-1112-1113-1114-111111111115");
       debugInfo(tn, " publishing " + delMsg.getCSN());
       server01.publish(delMsg);
@@ -1644,7 +1645,7 @@
       // Produce update 1
       CSN csn1 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_1);
       DeleteMsg delMsg1 =
-        new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1,
+        newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1,
             "11111111-1111-1111-1111-111111111111");
       debugInfo(tn, " publishing " + delMsg1);
       server01.publish(delMsg1);
@@ -1653,7 +1654,7 @@
       // Produce update 2
       CSN csn2 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_2);
       DeleteMsg delMsg2 =
-        new DeleteMsg("uid=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2,
+        newDeleteMsg("uid=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2,
             "22222222-2222-2222-2222-222222222222");
       debugInfo(tn, " publishing " + delMsg2);
       server02.publish(delMsg2);
@@ -1662,7 +1663,7 @@
       // Produce update 3
       CSN csn3 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_2);
       DeleteMsg delMsg3 =
-        new DeleteMsg("uid=" + tn + "3," + TEST_ROOT_DN_STRING2, csn3,
+        newDeleteMsg("uid=" + tn + "3," + TEST_ROOT_DN_STRING2, csn3,
             "33333333-3333-3333-3333-333333333333");
       debugInfo(tn, " publishing " + delMsg3);
       server02.publish(delMsg3);
@@ -1854,7 +1855,7 @@
       // Produces additional change
       CSN csn11 = new CSN(TimeThread.getTime(), 11, SERVER_ID_1);
       String expectedDn11 = "uid=" + tn + "11," +  TEST_ROOT_DN_STRING;
-      DeleteMsg delMsg11 = new DeleteMsg(expectedDn11, csn11,
+      DeleteMsg delMsg11 = newDeleteMsg(expectedDn11, csn11,
          "44444444-4444-4444-4444-444444444444");
       debugInfo(tn, " publishing " + delMsg11);
       server01.publish(delMsg11);
@@ -1864,7 +1865,7 @@
       // Produces additional change
       CSN csn12 = new CSN(TimeThread.getTime(), 12, SERVER_ID_2);
       String expectedDn12 = "uid=" + tn + "12," +  TEST_ROOT_DN_STRING2;
-      DeleteMsg delMsg12 = new DeleteMsg(expectedDn12, csn12,
+      DeleteMsg delMsg12 = newDeleteMsg(expectedDn12, csn12,
          "55555555-5555-5555-5555-555555555555");
       debugInfo(tn, " publishing " + delMsg12 );
       server02.publish(delMsg12);
@@ -1874,7 +1875,7 @@
       // Produces additional change
       CSN csn13 = new CSN(TimeThread.getTime(), 13, SERVER_ID_2);
       String expectedDn13 = "uid=" + tn + "13," +  TEST_ROOT_DN_STRING2;
-      DeleteMsg delMsg13 = new DeleteMsg(expectedDn13, csn13,
+      DeleteMsg delMsg13 = newDeleteMsg(expectedDn13, csn13,
          "66666666-6666-6666-6666-666666666666");
       debugInfo(tn, " publishing " + delMsg13);
       server02.publish(delMsg13);
@@ -2285,9 +2286,7 @@
       gblCSN = csns[1];
 
       // Publish DEL
-      DeleteMsg delMsg =
-          new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0],
-            user1entryUUID);
+      DeleteMsg delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0], user1entryUUID);
       server01.publish(delMsg);
       debugInfo(tn, " publishes " + delMsg.getCSN());
 
@@ -2300,7 +2299,7 @@
       Entry entry = TestCaseUtils.entryFromLdifString(lentry);
       AddMsg addMsg = new AddMsg(
           gblCSN,
-          "uid="+tn+"2," + TEST_ROOT_DN_STRING,
+          DN.decode("uid="+tn+"2," + TEST_ROOT_DN_STRING),
           user1entryUUID,
           baseUUID,
           entry.getObjectClassAttribute(),
@@ -2746,7 +2745,7 @@
 
     // Publish DEL
     CSN csn1 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_1);
-    DeleteMsg delMsg = new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING,
+    DeleteMsg delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING,
         csn1, user1entryUUID);
     server01.publish(delMsg);
     debugInfo(tn, " publishes " + delMsg.getCSN());
@@ -2782,8 +2781,7 @@
         1000, replicationServerPort, brokerSessionTimeout, true);
 
     // Publish one first message
-    DeleteMsg delMsg = new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1,
-            user1entryUUID);
+    DeleteMsg delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, user1entryUUID);
     server01.publish(delMsg);
     debugInfo(tn, " publishes " + delMsg.getCSN());
     sleep(300);
@@ -2792,7 +2790,7 @@
     assertEquals(rsdtest.getEligibleCount(fromStart, now()), 1);
 
     // Publish one second message
-    delMsg = new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn2, user1entryUUID);
+    delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn2, user1entryUUID);
     server01.publish(delMsg);
     debugInfo(tn, " publishes " + delMsg.getCSN());
     sleep(300);
@@ -2819,7 +2817,7 @@
     assertEquals(rsdtest.getEligibleCount(fromStateBeforeCSN2, now()), 0);
 
     // Publish one third message
-    delMsg = new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, csn3, user1entryUUID);
+    delMsg = newDeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, csn3, user1entryUUID);
     server01.publish(delMsg);
     debugInfo(tn, " publishes " + delMsg.getCSN());
     sleep(300);
@@ -2842,7 +2840,7 @@
       for (int i=4; i<=maxMsg; i++)
       {
         CSN csnx = new CSN(TimeThread.getTime(), i, SERVER_ID_1);
-        delMsg = new DeleteMsg("uid="+tn+i+"," + TEST_ROOT_DN_STRING, csnx, user1entryUUID);
+        delMsg = newDeleteMsg("uid="+tn+i+"," + TEST_ROOT_DN_STRING, csnx, user1entryUUID);
         server01.publish(delMsg);
       }
       sleep(1000);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
index b746cc4..770cde0 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
@@ -54,7 +54,6 @@
 import static org.opends.server.TestCaseUtils.*;
 import static org.opends.server.loggers.ErrorLogger.*;
 import static org.opends.server.loggers.debug.DebugLogger.*;
-import static org.opends.server.util.StaticUtils.*;
 import static org.testng.Assert.*;
 
 /**
@@ -78,15 +77,14 @@
   private static final int changelog2ID = 22;
   private static final int changelog3ID = 23;
 
-  private DN baseDn;
-  private ReplicationBroker broker2 = null;
-  private ReplicationBroker broker3 = null;
-  private ReplicationBroker broker4 = null;
-  private ReplicationServer replServer1 = null;
-  private ReplicationServer replServer2 = null;
-  private ReplicationServer replServer3 = null;
-  private LDAPReplicationDomain replDomain = null;
-  private String[] updatedEntries;
+  private DN baseDN;
+  private ReplicationBroker broker2;
+  private ReplicationBroker broker3;
+  private ReplicationBroker broker4;
+  private ReplicationServer replServer1;
+  private ReplicationServer replServer2;
+  private ReplicationServer replServer3;
+  private LDAPReplicationDomain replDomain;
 
   private static int[] replServerPort = new int[30];
 
@@ -99,11 +97,6 @@
     }
   }
 
-  private void debugInfo(String message, Exception e)
-  {
-    debugInfo(message + stackTraceToSingleLineString(e));
-  }
-
   /**
    * Set up the environment for performing the tests in this Class.
    *
@@ -116,9 +109,7 @@
   {
     super.setUp();
 
-    baseDn = DN.decode(baseDnStr);
-
-    updatedEntries = newLDIFEntries();
+    baseDN = DN.decode(baseDnStr);
   }
 
   /**
@@ -127,17 +118,17 @@
   private String[] newLDIFEntries()
   {
     return new String[]{
-        "dn: " + baseDn + "\n"
+        "dn: " + baseDN + "\n"
             + "objectClass: top\n"
             + "objectClass: organization\n"
             + "entryUUID: 21111111-1111-1111-1111-111111111111\n"
             + "\n",
-        "dn: ou=People," + baseDn + "\n"
+        "dn: ou=People," + baseDN + "\n"
             + "objectClass: top\n"
             + "objectClass: organizationalUnit\n"
             + "entryUUID: 21111111-1111-1111-1111-111111111112\n"
             + "\n",
-        "dn: cn=Fiona Jensen,ou=people," + baseDn + "\n"
+        "dn: cn=Fiona Jensen,ou=people," + baseDN + "\n"
             + "objectclass: top\n"
             + "objectclass: person\n"
             + "objectclass: organizationalPerson\n"
@@ -148,7 +139,7 @@
             + "telephonenumber: +1 408 555 1212\n"
             + "entryUUID: 21111111-1111-1111-1111-111111111113\n"
             + "\n",
-        "dn: cn=Robert Langman,ou=people," + baseDn + "\n"
+        "dn: cn=Robert Langman,ou=people," + baseDN + "\n"
             + "objectclass: top\n"
             + "objectclass: person\n"
             + "objectclass: organizationalPerson\n"
@@ -170,33 +161,25 @@
    * @return The new created replication server.
    */
   private ReplicationServer createReplicationServer(int changelogId,
-      boolean all, String suffix)
+      boolean all, String suffix) throws Exception
   {
     SortedSet<String> servers = new TreeSet<String>();
-    try
+    if (all)
     {
-      if (all)
-      {
-        if (changelogId != changelog1ID)
-          servers.add("localhost:" + getChangelogPort(changelog1ID));
-        if (changelogId != changelog2ID)
-          servers.add("localhost:" + getChangelogPort(changelog2ID));
-      }
-      int chPort = getChangelogPort(changelogId);
-      String chDir = "monitorTest"+changelogId+suffix+"Db";
-      ReplServerFakeConfiguration conf =
+      if (changelogId != changelog1ID)
+        servers.add("localhost:" + getChangelogPort(changelog1ID));
+      if (changelogId != changelog2ID)
+        servers.add("localhost:" + getChangelogPort(changelog2ID));
+    }
+    int chPort = getChangelogPort(changelogId);
+    String chDir = "monitorTest" + changelogId + suffix + "Db";
+    ReplServerFakeConfiguration conf =
         new ReplServerFakeConfiguration(chPort, chDir, 0, changelogId, 0, 100,
             servers);
-      ReplicationServer replicationServer = new ReplicationServer(conf);
-      Thread.sleep(1000);
+    ReplicationServer replicationServer = new ReplicationServer(conf);
+    Thread.sleep(1000);
 
-      return replicationServer;
-    }
-    catch (Exception e)
-    {
-      fail("createChangelog" + stackTraceToSingleLineString(e));
-    }
-    return null;
+    return replicationServer;
   }
 
   /**
@@ -204,10 +187,9 @@
    * replication Server ID.
    * @param changelogID the replication server ID.
    */
-  private void connectServer1ToChangelog(int changelogID)
+  private void connectServer1ToChangelog(int changelogID) throws Exception
   {
     // Connect DS to the replicationServer
-    try
     {
       // suffix synchronized
       String synchroServerLdif =
@@ -228,7 +210,7 @@
         "Unable to add the synchronized server");
       configEntryList.add(synchroServerEntry.getDN());
 
-      replDomain = LDAPReplicationDomain.retrievesReplicationDomain(baseDn);
+      replDomain = LDAPReplicationDomain.retrievesReplicationDomain(baseDN);
 
       if (replDomain != null)
       {
@@ -236,11 +218,6 @@
           replDomain.ieRunning());
       }
     }
-    catch(Exception e)
-    {
-      debugInfo("connectToReplServer", e);
-      fail("connectToReplServer: " + e.getMessage() + " : " + e.getStackTrace(), e);
-    }
   }
 
   /**
@@ -287,7 +264,7 @@
         + "userPassword: password\n" + "initials: AA\n";
   }
 
-  static private ReplicationMsg createAddMsg(CSN csn)
+  static private ReplicationMsg createAddMsg(CSN csn) throws Exception
   {
     Entry personWithUUIDEntry = null;
     String user1entryUUID;
@@ -312,18 +289,11 @@
     + "userPassword: password\n" + "initials: AA\n"
     + "entryUUID: " + user1entryUUID + "\n";
 
-    try
-    {
-      personWithUUIDEntry = TestCaseUtils.entryFromLdifString(entryWithUUIDldif);
-    }
-    catch(Exception e)
-    {
-      fail(e.getMessage());
-    }
+    personWithUUIDEntry = TestCaseUtils.entryFromLdifString(entryWithUUIDldif);
 
     // Create and publish an update message to add an entry.
     return new AddMsg(csn,
-        personWithUUIDEntry.getDN().toString(),
+        personWithUUIDEntry.getDN(),
         user1entryUUID,
         baseUUID,
         personWithUUIDEntry.getObjectClassAttribute(),
@@ -353,7 +323,7 @@
       try
       {
         debugInfo("Connecting broker2 to replServer1");
-        broker2 = openReplicationSession(baseDn,
+        broker2 = openReplicationSession(baseDN,
           server2ID, 100, getChangelogPort(changelog1ID),
           1000, !emptyOldChanges);
         Thread.sleep(1000);
@@ -365,7 +335,7 @@
       try
       {
         debugInfo("Connecting broker3 to replServer2");
-        broker3 = openReplicationSession(baseDn,
+        broker3 = openReplicationSession(baseDN,
           server3ID, 100, getChangelogPort(changelog2ID),
           1000, !emptyOldChanges);
         Thread.sleep(1000);
@@ -377,7 +347,7 @@
       try
       {
         debugInfo("Connecting broker4 to replServer2");
-        broker4 = openReplicationSession(baseDn,
+        broker4 = openReplicationSession(baseDN,
           server4ID, 100, getChangelogPort(changelog2ID),
           1000, !emptyOldChanges);
         Thread.sleep(1000);
@@ -387,16 +357,14 @@
       }
 
       // Do a bunch of change
-      updatedEntries = newLDIFEntries();
-      this.addTestEntriesToDB(updatedEntries);
+      addTestEntriesToDB(newLDIFEntries());
 
       for (int i = 0; i < 200; i++)
       {
-        String ent1[] =
-        {
+        String ent1[] = {
           createEntry(UUID.randomUUID())
         };
-        this.addTestEntriesToDB(ent1);
+        addTestEntriesToDB(ent1);
       }
 
       /*
@@ -427,7 +395,7 @@
   /**
    * Disconnect broker and remove entries from the local DB
    */
-  private void postTest()
+  private void postTest() throws Exception
   {
     debugInfo("Post test cleaning.");
 
@@ -439,12 +407,7 @@
     super.cleanRealEntries();
 
     Arrays.fill(replServerPort, 0);
-
-    try
-    {
-      TestCaseUtils.initializeTestBackend(false);
-    }
-    catch (Exception e) {}
+    TestCaseUtils.initializeTestBackend(false);
   }
 
   private static final ByteArrayOutputStream oStream =
@@ -473,17 +436,7 @@
       LDAPSearch.mainSearch(args3, false, oStream, eStream);
     String entries = oStream.toString();
     debugInfo("Entries:" + entries);
-    try
-    {
-      assertEquals(retVal, 0, "Returned error: " + eStream);
-      assertTrue(!entries.equalsIgnoreCase(""), "Returned entries: " + entries);
-    }
-    catch(Exception e)
-    {
-      if (debugEnabled())
-        TRACER.debugInfo(
-          stackTraceToSingleLineString(new Exception()));
-      fail(e.getMessage());
-    }
+    assertEquals(retVal, 0, "Returned error: " + eStream);
+    assertTrue(!entries.equalsIgnoreCase(""), "Returned entries: " + entries);
   }
 }
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
index 0821bd4..36a4d91 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -81,9 +81,9 @@
 {
   /** The tracer object for the debug logger */
   private static final DebugTracer TRACER = getTracer();
-  /**
-   * The replicationServer that will be used in this test.
-   */
+  private DN TEST_ROOT_DN;
+  private DN EXAMPLE_DN;
+  /** The replicationServer that will be used in this test. */
   private ReplicationServer replicationServer;
 
   /**
@@ -113,6 +113,8 @@
   public void setUp() throws Exception
   {
     super.setUp();
+    TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING);
+    EXAMPLE_DN = DN.decode("o=example," + TEST_ROOT_DN_STRING);
 
     // This test suite depends on having the schema available.
     configure();
@@ -216,12 +218,10 @@
       /*
        * Open a sender session and a receiver session to the replicationServer
        */
-      server1 = openReplicationSession(
-          DN.decode(TEST_ROOT_DN_STRING),  1, 100, replicationServerPort,
-          1000, false);
-      server2 = openReplicationSession(
-          DN.decode(TEST_ROOT_DN_STRING),  2, 100, replicationServerPort,
-          1000, false);
+      server1 = openReplicationSession(TEST_ROOT_DN,
+          1, 100, replicationServerPort, 1000, false);
+      server2 = openReplicationSession(TEST_ROOT_DN,
+          2, 100, replicationServerPort, 1000, false);
 
       assertTrue(server1.isConnected());
       assertTrue(server2.isConnected());
@@ -253,9 +253,7 @@
       /*
        * Send and receive a Delete Msg from server 1 to server 2
        */
-      DeleteMsg msg =
-          new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, firstCSNServer1,
-                      "uid");
+      DeleteMsg msg = new DeleteMsg(EXAMPLE_DN, firstCSNServer1, "uid");
       server1.publish(msg);
       ReplicationMsg msg2 = server2.receive();
       server2.updateWindowAfterReplay();
@@ -264,7 +262,7 @@
       /*
        * Send and receive a second Delete Msg
        */
-      msg = new DeleteMsg(TEST_ROOT_DN_STRING, secondCSNServer1, "uid");
+      msg = new DeleteMsg(TEST_ROOT_DN, secondCSNServer1, "uid");
       server1.publish(msg);
       msg2 = server2.receive();
       server2.updateWindowAfterReplay();
@@ -273,9 +271,7 @@
       /*
        * Send and receive a Delete Msg from server 2 to server 1
        */
-      msg =
-          new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, firstCSNServer2,
-                      "other-uid");
+      msg = new DeleteMsg(EXAMPLE_DN, firstCSNServer2, "other-uid");
       server2.publish(msg);
       msg2 = server1.receive();
       server1.updateWindowAfterReplay();
@@ -284,7 +280,7 @@
       /*
        * Send and receive a second Delete Msg
        */
-      msg = new DeleteMsg(TEST_ROOT_DN_STRING, secondCSNServer2, "uid");
+      msg = new DeleteMsg(TEST_ROOT_DN, secondCSNServer2, "uid");
       server2.publish(msg);
       msg2 = server1.receive();
       server1.updateWindowAfterReplay();
@@ -318,10 +314,8 @@
     ReplicationBroker broker = null;
 
     try {
-      broker =
-        openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),  3,
-                             100, replicationServerPort, 1000, false);
-
+      broker = openReplicationSession(TEST_ROOT_DN,
+          3, 100, replicationServerPort, 1000, false);
       assertTrue(broker.isConnected());
 
       ReplicationMsg msg2 = broker.receive();
@@ -347,9 +341,8 @@
 
     // Connect to the replicationServer using the state created above.
     try {
-      broker =
-        openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),  3,
-                             100, replicationServerPort, 5000, state);
+      broker = openReplicationSession(TEST_ROOT_DN,
+          3, 100, replicationServerPort, 5000, state);
 
       ReplicationMsg msg2 = broker.receive();
       broker.updateWindowAfterReplay();
@@ -516,10 +509,8 @@
       /*
        * Open a sender session
        */
-      server = openReplicationSession(
-          DN.decode(TEST_ROOT_DN_STRING),  5, 100, replicationServerPort,
-          100000, 1000, 0, false);
-
+      server = openReplicationSession(TEST_ROOT_DN,
+          5, 100, replicationServerPort, 100000, 1000, 0, false);
       assertTrue(server.isConnected());
 
       reader = new BrokerReader(server, TOTAL_MSG);
@@ -529,9 +520,8 @@
        */
       for (int i =0; i< CLIENT_THREADS; i++)
       {
-        clientBroker[i] = openReplicationSession(
-            DN.decode(TEST_ROOT_DN_STRING),  (100+i), 100, replicationServerPort,
-            1000, true);
+        clientBroker[i] = openReplicationSession(TEST_ROOT_DN,
+            (100+i), 100, replicationServerPort, 1000, true);
         assertTrue(clientBroker[i].isConnected());
         client[i] = new BrokerReader(clientBroker[i], TOTAL_MSG);
       }
@@ -548,10 +538,7 @@
        */
       for (int i = 0; i< TOTAL_MSG; i++)
       {
-        DeleteMsg msg =
-          new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, gen.newCSN(),
-          "uid");
-        server.publish(msg);
+        server.publish(new DeleteMsg(EXAMPLE_DN, gen.newCSN(), "uid"));
       }
       debugInfo("Ending oneWriterMultipleReader");
     }
@@ -607,10 +594,8 @@
       {
         int serverId = 10 + i;
         CSNGenerator gen = new CSNGenerator(serverId , 0);
-        broker[i] =
-          openReplicationSession( DN.decode(TEST_ROOT_DN_STRING), serverId,
-              100, replicationServerPort, 3000, 1000, 0, true);
-
+        broker[i] = openReplicationSession(TEST_ROOT_DN,
+            serverId, 100, replicationServerPort, 3000, 1000, 0, true);
         assertTrue(broker[i].isConnected());
 
         producer[i] = new BrokerWriter(broker[i], gen, TOTAL_MSG/THREADS);
@@ -694,19 +679,11 @@
 
       // - Create 2 connected replicationServer
       ReplicationServer[] changelogs = new ReplicationServer[2];
-      int[] changelogPorts = new int[2];
-      int[] changelogIds = new int[2];
-      int[] brokerIds = new int[2];
+      int[] changelogPorts = TestCaseUtils.findFreePorts(2);
+      int[] changelogIds = new int[] { 80, 81 };
+      int[] brokerIds = new int[] { 100, 101 };
 
-      // Find 2 free ports
-      for (int i = 0; i <= 1; i++)
-      {
-        changelogPorts[i] = TestCaseUtils.findFreePort();
-        changelogIds[i] = i + 80;
-        brokerIds[i] = 100 + i;
-      }
-
-      for (int i = 0; i <= ((itest == 0) ? 1 : 0); i++)
+      for (int i = 0; i < ((itest == 0) ? 2 : 1); i++)
       {
         changelogs[i] = null;
 
@@ -730,14 +707,13 @@
         //              and client2 to changelog2
         // For itest=1, only create and connect client1 to changelog1
         //              client2 will be created later
-        broker1 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
+        broker1 = openReplicationSession(TEST_ROOT_DN,
              brokerIds[0], 100, changelogPorts[0], 1000, !emptyOldChanges);
-
         assertTrue(broker1.isConnected());
 
         if (itest == 0)
         {
-          broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
+          broker2 = openReplicationSession(TEST_ROOT_DN,
              brokerIds[1], 100, changelogPorts[0], 1000, !emptyOldChanges);
           assertTrue(broker2.isConnected());
         }
@@ -749,7 +725,8 @@
         int ts = 1;
         CSN csn = new CSN(time, ts++, brokerIds[0]);
 
-        DeleteMsg delMsg = new DeleteMsg("o=example" + itest + "," + TEST_ROOT_DN_STRING, csn, "uid");
+        DN dn = DN.decode("o=example" + itest + "," + TEST_ROOT_DN_STRING);
+        DeleteMsg delMsg = new DeleteMsg(dn, csn, "uid");
         broker1.publish(delMsg);
 
         String user1entryUUID = "33333333-3333-3333-3333-333333333333";
@@ -761,9 +738,9 @@
             + "entryUUID: 11111111-1111-1111-1111-111111111111\n";
         Entry entry = TestCaseUtils.entryFromLdifString(lentry);
         csn = new CSN(time, ts++, brokerIds[0]);
-        AddMsg addMsg = new AddMsg(csn, "o=example," + TEST_ROOT_DN_STRING,
-            user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry
-            .getAttributes(), new ArrayList<Attribute>());
+        AddMsg addMsg = new AddMsg(csn, EXAMPLE_DN,
+            user1entryUUID, baseUUID, entry.getObjectClassAttribute(),
+            entry.getAttributes(), new ArrayList<Attribute>());
         broker1.publish(addMsg);
 
         // - Modify
@@ -772,15 +749,13 @@
         List<Modification> mods = new ArrayList<Modification>();
         mods.add(mod1);
         csn = new CSN(time, ts++, brokerIds[0]);
-        ModifyMsg modMsg = new ModifyMsg(csn, DN
-            .decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid");
+        ModifyMsg modMsg = new ModifyMsg(csn, EXAMPLE_DN, mods, "fakeuniqueid");
         broker1.publish(modMsg);
 
         // - ModifyDN
         csn = new CSN(time, ts++, brokerIds[0]);
-        ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, DN
-            .decode("o=example," + TEST_ROOT_DN_STRING), RDN.decode("o=example2"), true,
-            null);
+        ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null,
+            EXAMPLE_DN, RDN.decode("o=example2"), true, null);
         op.setAttachment(SYNCHROCONTEXT, new ModifyDnContext(csn, "uniqueid",
         "newparentId"));
         LocalBackendModifyDNOperation localOp =
@@ -798,7 +773,7 @@
           changelogs[1] = new ReplicationServer(conf);
 
           // Connect broker 2 to changelog2
-          broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
+          broker2 = openReplicationSession(TEST_ROOT_DN,
               brokerIds[1], 100, changelogPorts[1], 2000, !emptyOldChanges);
           assertTrue(broker2.isConnected());
         }
@@ -822,26 +797,22 @@
 
           if (msg2 instanceof DeleteMsg)
           {
-            DeleteMsg delMsg2 = (DeleteMsg) msg2;
-            if (delMsg2.toString().equals(delMsg.toString()))
+            if (delMsg.equals(msg2))
               ts--;
           }
           else if (msg2 instanceof AddMsg)
           {
-            AddMsg addMsg2 = (AddMsg) msg2;
-            if (addMsg2.toString().equals(addMsg.toString()))
+            if (addMsg.equals(msg2))
               ts--;
           }
           else if (msg2 instanceof ModifyMsg)
           {
-            ModifyMsg modMsg2 = (ModifyMsg) msg2;
-            if (modMsg.equals(modMsg2))
+            if (modMsg.equals(msg2))
               ts--;
           }
           else if (msg2 instanceof ModifyDNMsg)
           {
-            ModifyDNMsg modDNMsg2 = (ModifyDNMsg) msg2;
-            if (modDNMsg.equals(modDNMsg2))
+            if (modDNMsg.equals(msg2))
               ts--;
           }
           else if (msg2 instanceof TopologyMsg)
@@ -905,29 +876,23 @@
     int timeoutMS = MultimasterReplication.getConnectionTimeoutMS();
     socket.connect(ServerAddr, timeoutMS);
     ReplSessionSecurity replSessionSecurity = getReplSessionSecurity();
-    Session session = replSessionSecurity.createClientSession(socket,
-        timeoutMS);
+    Session session = replSessionSecurity.createClientSession(socket, timeoutMS);
 
-    boolean sslEncryption =
-         DirectoryConfig.getCryptoManager().isSslEncryption();
+    boolean sslEncryption = DirectoryConfig.getCryptoManager().isSslEncryption();
 
     try
     {
       // send a ServerStartMsg with an empty ServerState.
       String url = socket.getLocalAddress().getCanonicalHostName() + ":"
           + socket.getLocalPort();
-      ServerStartMsg msg =
-        new ServerStartMsg( 1723, url, TEST_ROOT_DN_STRING,
-            WINDOW, 5000, new ServerState(),
-            0, sslEncryption, (byte)-1);
+      ServerStartMsg msg = new ServerStartMsg(1723, url, TEST_ROOT_DN,
+            WINDOW, 5000, new ServerState(), 0, sslEncryption, (byte)-1);
       session.publish(msg);
 
       // Read the Replication Server state from the ReplServerStartDSMsg that
       // comes back.
-      ReplServerStartDSMsg replStartDSMsg =
-        (ReplServerStartDSMsg) session.receive();
+      ReplServerStartDSMsg replStartDSMsg = (ReplServerStartDSMsg) session.receive();
       int serverwindow = replStartDSMsg.getWindowSize();
-
       if (!sslEncryption)
       {
         session.stopEncryption();
@@ -1006,8 +971,8 @@
     private ReplicationBroker broker;
     private int numMsgRcv = 0;
     private final int numMsgExpected;
-    public Exception exc;
-    public String errDetails = null;
+    private Exception exc;
+    private String errDetails;
 
     /**
      * Creates a new Stress Test Reader
@@ -1071,12 +1036,11 @@
    */
   private class BrokerWriter extends Thread
   {
-    int count;
+    private int count;
     private ReplicationBroker broker;
-    CSNGenerator gen;
+    private CSNGenerator gen;
 
-    public BrokerWriter(ReplicationBroker broker, CSNGenerator gen,
-        int count)
+    public BrokerWriter(ReplicationBroker broker, CSNGenerator gen, int count)
     {
       this.broker = broker;
       this.count = count;
@@ -1099,9 +1063,7 @@
       {
         count--;
 
-        DeleteMsg msg =
-          new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, gen.newCSN(),
-              "uid");
+        DeleteMsg msg = new DeleteMsg(EXAMPLE_DN, gen.newCSN(), "uid");
         broker.publish(msg);
 
         if ((count % 10) == 0)
@@ -1111,9 +1073,8 @@
     }
   }
 
-
-  /*
-   * Test backup and restore of the Replication server backend
+  /**
+   * Test backup and restore of the Replication server backend.
    */
    private void backupRestore() throws Exception
    {
@@ -1147,29 +1108,17 @@
 
       try
       {
-        server1 = openReplicationSession(
-          DN.decode(TEST_ROOT_DN_STRING),  1, 100,
-          replicationServerPort,
-          1000, true);
-        server2 = openReplicationSession(
-          DN.decode("dc=domain2,dc=com"),  2, 100,
-          replicationServerPort,
-          1000, true);
+        server1 = openReplicationSession(TEST_ROOT_DN,
+            1, 100, replicationServerPort, 1000, true);
+        server2 = openReplicationSession(DN.decode("dc=domain2,dc=com"),
+            2, 100, replicationServerPort, 1000, true);
 
         assertTrue(server1.isConnected());
         assertTrue(server2.isConnected());
 
         debugInfo("Publish changes");
-        List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING,  1);
-        for (UpdateMsg msg : msgs)
-        {
-          server1.publish(msg);
-        }
-        List<UpdateMsg> msgs2 = createChanges("dc=domain2,dc=com",  2);
-        for (UpdateMsg msg : msgs2)
-        {
-          server2.publish(msg);
-        }
+        publishAll(server1, createChanges(TEST_ROOT_DN_STRING,  1));
+        publishAll(server2, createChanges("dc=domain2,dc=com",  2));
 
         debugInfo("Export all");
         Entry exportTask = createExportAllTask();
@@ -1272,9 +1221,10 @@
            + "entryUUID: 11111111-1111-1111-1111-111111111111\n";
        Entry entry = TestCaseUtils.entryFromLdifString(lentry);
        CSN csn = new CSN(time, ts++, serverId);
-       AddMsg addMsg = new AddMsg(csn, "o=example,"+suffix,
-           user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry
-           .getAttributes(), new ArrayList<Attribute>());
+       DN exampleSuffixDN = DN.decode("o=example," + suffix);
+       AddMsg addMsg = new AddMsg(csn, exampleSuffixDN,
+           user1entryUUID, baseUUID, entry.getObjectClassAttribute(),
+           entry.getAttributes(), new ArrayList<Attribute>());
        l.add(addMsg);
 
        // - Add
@@ -1292,9 +1242,10 @@
            + "userpassword: fjen$$en" + "\n";
        Entry uentry = TestCaseUtils.entryFromLdifString(luentry);
        csn = new CSN(time, ts++, serverId);
+       DN newPersonDN = DN.decode("uid=new person,ou=People,"+suffix);
        AddMsg addMsg2 = new AddMsg(
            csn,
-           "uid=new person,ou=People,"+suffix,
+           newPersonDN,
            user1entryUUID,
            baseUUID,
            uentry.getObjectClassAttribute(),
@@ -1309,30 +1260,25 @@
        Modification mod2 = new Modification(ModificationType.REPLACE, attr2);
        Attribute attr3 = Attributes.create("modifyTimestamp", "20070917172420Z");
        Modification mod3 = new Modification(ModificationType.REPLACE, attr3);
-       List<Modification> mods = new ArrayList<Modification>();
 
-       mods.add(mod1);
-       mods.add(mod2);
-       mods.add(mod3);
+       List<Modification> mods = Arrays.asList(mod1, mod2, mod3);
 
        csn = new CSN(time, ts++, serverId);
-       DN dn = DN.decode("o=example,"+suffix);
+       DN dn = exampleSuffixDN;
        ModifyMsg modMsg = new ModifyMsg(csn, dn,
            mods, "fakeuniqueid");
        l.add(modMsg);
 
        // Modify DN
        csn = new CSN(time, ts++, serverId);
-       ModifyDNMsg  modDnMsg = new ModifyDNMsg(
-           "uid=new person,ou=People,"+suffix, csn,
+       ModifyDNMsg  modDnMsg = new ModifyDNMsg(newPersonDN, csn,
            user1entryUUID, baseUUID, false,
-           "uid=wrong, ou=people,"+suffix,
-       "uid=newrdn");
+           "uid=wrong, ou=people,"+suffix, "uid=newrdn");
        l.add(modDnMsg);
 
        // Del
        csn = new CSN(time, ts++, serverId);
-       DeleteMsg delMsg = new DeleteMsg("o=example,"+suffix, csn, "uid");
+       DeleteMsg delMsg = new DeleteMsg(exampleSuffixDN, csn, "uid");
        l.add(delMsg);
      }
      return l;
@@ -1363,18 +1309,14 @@
 
        debugInfo("Create broker");
 
-       server1 = openReplicationSession(
-         DN.decode(TEST_ROOT_DN_STRING),  1, 100, replicationServerPort,
-         1000, true);
+       server1 = openReplicationSession(TEST_ROOT_DN,
+           1, 100, replicationServerPort, 1000, true);
 
        assertTrue(server1.isConnected());
 
        debugInfo("Publish changes");
        List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, 1);
-       for(UpdateMsg msg : msgs )
-       {
-         server1.publish(msg);
-       }
+       publishAll(server1, msgs);
        Thread.sleep(500);
 
        // Sets manually the association backend-replication server since
@@ -1482,6 +1424,14 @@
      }
    }
 
+  private void publishAll(ReplicationBroker broker, List<UpdateMsg> msgs)
+  {
+    for (UpdateMsg msg : msgs)
+    {
+      broker.publish(msg);
+    }
+  }
+
   private InternalSearchOperation assertSearchResult(String baseDN,
       String filterString, ResultCode rc, int nbEntriesReturned)
       throws Exception
@@ -1596,19 +1546,11 @@
 
        // - Create 2 connected replicationServer
        ReplicationServer[] changelogs = new ReplicationServer[2];
-       int[] changelogPorts = new int[2];
-       int[] changelogIds = new int[2];
-       int[] brokerIds = new int[2];
+       int[] changelogPorts = TestCaseUtils.findFreePorts(2);
+       int[] changelogIds = new int[] { 90, 91 };
+       int[] brokerIds = new int[] { 100, 101 };
 
-       // Find 2 free ports
-       for (int i = 0; i <= 1; i++)
-       {
-         changelogPorts[i] = TestCaseUtils.findFreePort();
-         changelogIds[i] = i + 90;
-         brokerIds[i] = 100+i;
-       }
-
-       for (int i = 0; i <= 1; i++)
+       for (int i = 0; i < 2; i++)
        {
          changelogs[i] = null;
          // create the 2 replicationServer
@@ -1629,10 +1571,9 @@
        {
          // Create and connect client1 to changelog1
          // and client2 to changelog2
-         broker1 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
+         broker1 = openReplicationSession(TEST_ROOT_DN,
               brokerIds[0], 100, changelogPorts[0], 1000, emptyOldChanges);
-
-         broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
+         broker2 = openReplicationSession(TEST_ROOT_DN,
               brokerIds[1], 100, changelogPorts[1], 1000, emptyOldChanges);
 
          assertTrue(broker1.isConnected());
@@ -1651,7 +1592,7 @@
              + "entryUUID: " + user1entryUUID + "\n";
          Entry entry = TestCaseUtils.entryFromLdifString(lentry);
          csn = new CSN(time, ts++, brokerIds[0]);
-         AddMsg addMsg = new AddMsg(csn, "o=example," + TEST_ROOT_DN_STRING,
+         AddMsg addMsg = new AddMsg(csn, EXAMPLE_DN,
              user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry
              .getAttributes(), new ArrayList<Attribute>());
          broker1.publish(addMsg);
@@ -1662,8 +1603,7 @@
          List<Modification> mods = new ArrayList<Modification>();
          mods.add(mod1);
          csn = new CSN(time, ts++, brokerIds[0]);
-         ModifyMsg modMsg = new ModifyMsg(csn, DN
-             .decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid");
+         ModifyMsg modMsg = new ModifyMsg(csn, EXAMPLE_DN, mods, "fakeuniqueid");
          broker1.publish(modMsg);
 
          // - Check msg received by broker, through changeLog2
@@ -1686,14 +1626,12 @@
 
            if (msg2 instanceof AddMsg)
            {
-             AddMsg addMsg2 = (AddMsg) msg2;
-             if (addMsg2.toString().equals(addMsg.toString()))
+             if (addMsg.equals(msg2))
                ts--;
            }
            else if (msg2 instanceof ModifyMsg)
            {
-             ModifyMsg modMsg2 = (ModifyMsg) msg2;
-             if (modMsg.equals(modMsg2))
+             if (modMsg.equals(msg2))
                ts--;
            }
            else
@@ -1723,7 +1661,7 @@
          {
            // - Del
            csn = new CSN(time, ts++, brokerIds[0]);
-           DeleteMsg delMsg = new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, csn, user1entryUUID);
+           DeleteMsg delMsg = new DeleteMsg(EXAMPLE_DN, csn, user1entryUUID);
            broker1.publish(delMsg);
            // Should receive some TopologyMsg messages for disconnection
            // between the 2 RSs
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/DbHandlerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/DbHandlerTest.java
index 5e7e01c..4ec800f 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/DbHandlerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/DbHandlerTest.java
@@ -43,6 +43,7 @@
 import org.opends.server.replication.server.changelog.api.ReplicaDBCursor;
 import org.opends.server.types.DN;
 import org.opends.server.util.StaticUtils;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import static org.opends.server.TestCaseUtils.*;
@@ -57,6 +58,7 @@
 {
   /** The tracer object for the debug logger */
   private static final DebugTracer TRACER = getTracer();
+  private DN TEST_ROOT_DN;
 
   /**
    * Utility - log debug message - highlight it is from the test and not
@@ -70,6 +72,12 @@
     }
   }
 
+  @BeforeClass
+  public void setup() throws Exception
+  {
+    TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING);
+  }
+
   @Test(enabled=true)
   void testDbHandlerTrim() throws Exception
   {
@@ -87,7 +95,7 @@
       testRoot = createCleanDir();
 
       dbEnv = new ReplicationDbEnv(testRoot.getPath(), replicationServer);
-      handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 5000);
+      handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 5000);
 
       CSNGenerator gen = new CSNGenerator( 1, 0);
       CSN csn1 = gen.newCSN();
@@ -96,10 +104,10 @@
       CSN csn4 = gen.newCSN();
       CSN csn5 = gen.newCSN();
 
-      handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn1, "uid"));
-      handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn2, "uid"));
-      handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn3, "uid"));
-      DeleteMsg update4 = new DeleteMsg(TEST_ROOT_DN_STRING, csn4, "uid");
+      handler.add(new DeleteMsg(TEST_ROOT_DN, csn1, "uid"));
+      handler.add(new DeleteMsg(TEST_ROOT_DN, csn2, "uid"));
+      handler.add(new DeleteMsg(TEST_ROOT_DN, csn3, "uid"));
+      DeleteMsg update4 = new DeleteMsg(TEST_ROOT_DN, csn4, "uid");
 
       //--
       // Iterator tests with memory queue only populated
@@ -252,7 +260,7 @@
 
       testRoot = createCleanDir();
       dbEnv = new ReplicationDbEnv(testRoot.getPath(), replicationServer);
-      handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 5000);
+      handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 5000);
 
       // Creates changes added to the dbHandler
       CSNGenerator gen = new CSNGenerator( 1, 0);
@@ -261,9 +269,9 @@
       CSN csn3 = gen.newCSN();
 
       // Add the changes
-      handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn1, "uid"));
-      handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn2, "uid"));
-      handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn3, "uid"));
+      handler.add(new DeleteMsg(TEST_ROOT_DN, csn1, "uid"));
+      handler.add(new DeleteMsg(TEST_ROOT_DN, csn2, "uid"));
+      handler.add(new DeleteMsg(TEST_ROOT_DN, csn3, "uid"));
 
       // Check they are here
       assertEquals(csn1, handler.getOldestCSN());
@@ -348,7 +356,7 @@
 
       testRoot = createCleanDir();
       dbEnv = new ReplicationDbEnv(testRoot.getPath(), replicationServer);
-      handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 10);
+      handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 10);
       handler.setCounterWindowSize(counterWindow);
 
       // Populate the db with 'max' msg
@@ -359,7 +367,7 @@
       {
         csnArray[i] = new CSN(now + i, mySeqnum, 1);
         mySeqnum+=2;
-        DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN_STRING, csnArray[i], "uid");
+        DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN, csnArray[i], "uid");
         handler.add(update1);
       }
       handler.flush();
@@ -444,7 +452,7 @@
       debugInfo(tn,"SHUTDOWN handler and recreate");
       handler.shutdown();
 
-      handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 10);
+      handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 10);
       handler.setCounterWindowSize(counterWindow);
 
       // Test first and last
@@ -463,7 +471,7 @@
       {
         csnArray[i] = new CSN(now+i, mySeqnum, 1);
         mySeqnum+=2;
-        DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN_STRING, csnArray[i], "uid");
+        DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN, csnArray[i], "uid");
         handler.add(update1);
       }
       handler.flush();

--
Gitblit v1.10.0