From 7bb5b9a55a8d68f9622ca3ae6bb22b889b0a6a3f Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 16 Mar 2009 08:06:01 +0000
Subject: [PATCH] Fix for issue 3402 : Replication conflict: fail to resolve double mod_rdn of same entry

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

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 5723295..a6fd622 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
@@ -1095,4 +1095,63 @@
       fail("addEntries Exception:"+ e.getMessage() + " " + stackTraceToSingleLineString(e));
     }
   }
+
+  /**
+   *  Get the entryUUID for a given DN.
+   *
+   * @throws Exception if the entry does not exist or does not have
+   *                   an entryUUID.
+   */
+  protected String getEntryUUID(DN dn) throws Exception
+  {
+    Entry newEntry;
+    int count = 10;
+    if (count<1)
+      count=1;
+    String found = null;
+    while ((count> 0) && (found == null))
+    {
+      Thread.sleep(100);
+
+      Lock lock = null;
+      for (int i=0; i < 3; i++)
+      {
+        lock = LockManager.lockRead(dn);
+        if (lock != null)
+        {
+          break;
+        }
+      }
+
+      if (lock == null)
+      {
+        throw new Exception("could not lock entry " + dn);
+      }
+
+      try
+      {
+        newEntry = DirectoryServer.getEntry(dn);
+
+        if (newEntry != null)
+        {
+          List<Attribute> tmpAttrList = newEntry.getAttribute("entryuuid");
+          Attribute tmpAttr = tmpAttrList.get(0);
+
+          for (AttributeValue val : tmpAttr)
+          {
+            found = val.getValue().toString();
+            break;
+          }
+        }
+      }
+      finally
+      {
+        LockManager.unlock(dn, lock);
+      }
+      count --;
+    }
+    if (found == null)
+      throw new Exception("Entry: " + dn + " Could not be found.");
+    return found;
+  }
 }

--
Gitblit v1.10.0