From 3229ddd0bfacb4e49a48275dce3befb1aab0a535 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Thu, 08 Mar 2007 10:41:00 +0000
Subject: [PATCH] Fix some synchronization tests so that they don't fail anymore when trying to add an entry that already exist.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java |   29 ++++++++++++++++-------------
 opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java                |    1 -
 opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/StressTest.java          |   19 ++++++++++++-------
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java b/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java
index 11880b9..624d548 100644
--- a/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java
+++ b/opends/src/server/org/opends/server/synchronization/plugin/SynchronizationDomain.java
@@ -1948,7 +1948,6 @@
                           modifications);
 
     ChangeNumber cn = generateChangeNumber(op);
-    System.out.println("cn is " + cn);
     OperationContext ctx = new ModifyContext(cn, "schema");
     op.setAttachment(SYNCHROCONTEXT, ctx);
     op.setResultCode(ResultCode.SUCCESS);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/StressTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/StressTest.java
index 2c4075d..c21c8e6 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/StressTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/StressTest.java
@@ -32,12 +32,14 @@
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
+import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.opends.server.TestCaseUtils;
+import org.opends.server.TestErrorLogger;
 import org.opends.server.api.MonitorProvider;
 import org.opends.server.config.ConfigEntry;
 import org.opends.server.config.ConfigException;
@@ -131,19 +133,22 @@
       entryList.add(personEntry.getDN());
       assertTrue(DirectoryServer.entryExists(personEntry.getDN()),
         "The Add Entry operation failed");
+      if (ResultCode.SUCCESS == addOp.getResultCode())
+      {
+        // Check if the client has received the msg
+        SynchronizationMessage msg = broker.receive();
 
-      // Check if the client has received the msg
-      SynchronizationMessage msg = broker.receive();
-      assertTrue(msg instanceof AddMsg,
+        assertTrue(msg instanceof AddMsg,
         "The received synchronization message is not an ADD msg");
-      AddMsg addMsg =  (AddMsg) msg;
+        AddMsg addMsg =  (AddMsg) msg;
 
-      Operation receivedOp = addMsg.createOperation(connection);
-      assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
+        Operation receivedOp = addMsg.createOperation(connection);
+        assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
         "The received synchronization message is not an ADD msg");
 
-      assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
+        assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
         "The received ADD synchronization message is not for the excepted DN");
+      }
 
       reader = new BrokerReader(broker);
       reader.start();
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java
index 5e44928..c151dea 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/UpdateOperationTest.java
@@ -855,18 +855,21 @@
       assertTrue(DirectoryServer.entryExists(personEntry.getDN()),
       "The Add Entry operation failed");
 
-      // Check if the client has received the msg
-      SynchronizationMessage msg = broker.receive();
-      assertTrue(msg instanceof AddMsg,
-      "The received synchronization message is not an ADD msg");
-      AddMsg addMsg =  (AddMsg) msg;
+      if (ResultCode.SUCCESS.equals(addOp.getResultCode()))
+      {
+        // Check if the client has received the msg
+        SynchronizationMessage msg = broker.receive();
+        assertTrue(msg instanceof AddMsg,
+        "The received synchronization message is not an ADD msg");
+        AddMsg addMsg =  (AddMsg) msg;
 
-      Operation receivedOp = addMsg.createOperation(connection);
-      assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
-      "The received synchronization message is not an ADD msg");
+        Operation receivedOp = addMsg.createOperation(connection);
+        assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
+        "The received synchronization message is not an ADD msg");
 
-      assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
-      "The received ADD synchronization message is not for the excepted DN");
+        assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(),
+        "The received ADD synchronization message is not for the excepted DN");
+      }
 
       // Modify the entry
       List<Modification> mods = generatemods("telephonenumber", "01 02 45");
@@ -878,12 +881,12 @@
       modOp.run();
 
       // See if the client has received the msg
-      msg = broker.receive();
+      SynchronizationMessage msg = broker.receive();
       assertTrue(msg instanceof ModifyMsg,
       "The received synchronization message is not a MODIFY msg");
       ModifyMsg modMsg = (ModifyMsg) msg;
 
-      receivedOp = modMsg.createOperation(connection);
+      Operation receivedOp = modMsg.createOperation(connection);
       assertTrue(DN.decode(modMsg.getDn()).compareTo(personEntry.getDN()) == 0,
       "The received MODIFY synchronization message is not for the excepted DN");
 
@@ -935,7 +938,7 @@
        *
        * Start by testing the Add message reception
        */
-      addMsg = new AddMsg(gen.NewChangeNumber(),
+      AddMsg addMsg = new AddMsg(gen.NewChangeNumber(),
           personWithUUIDEntry.getDN().toString(),
           user1entryUUID, baseUUID,
           personWithUUIDEntry.getObjectClassAttribute(),

--
Gitblit v1.10.0