From 1cb47119972075d5f94a77e1deb1ec7d052c09f1 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 30 Sep 2015 08:14:51 +0000
Subject: [PATCH] OPENDJ-1192 Modify request replay failures

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplayTest.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplayTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplayTest.java
index 8bc8cda..224c5cd 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplayTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplayTest.java
@@ -348,6 +348,40 @@
     replay(mods, expectedDsSyncHist);
   }
 
+  @Test(enabled = false)
+  public void diffEntries_addThenDel() throws Exception
+  {
+    initialValue("X");
+
+    replaySameTime(newArrayList(newModification(ADD, "Y"), newModification(DELETE, "X")), dsSyncHist(1, ":add:Y"));
+  }
+
+  @Test(enabled = false)
+  public void diffEntries_delThenAdd() throws Exception
+  {
+    initialValue("X");
+
+    replaySameTime(newArrayList(newModification(DELETE, "X"), newModification(ADD, "Y")), dsSyncHist(1, ":add:Y"));
+  }
+
+  private void replaySameTime(List<Modification> mods, Attribute expectedDsSyncHist) throws DirectoryException
+  {
+    final ModifyContext value = new ModifyContext(new CSN(0, 1, 0), null);
+
+    PreOperationModifyOperation op = mock(PreOperationModifyOperation.class);
+    when(op.getModifications()).thenReturn(mods);
+    when(op.getAttachment(eq(OperationContext.SYNCHROCONTEXT))).thenReturn(value);
+
+    EntryHistorical entryHistorical = EntryHistorical.newInstanceFromEntry(entry);
+    entryHistorical.replayOperation(op, entry);
+    entry.applyModification(new Modification(REPLACE, entryHistorical.encodeAndPurge()));
+
+    AttributeType attrType = expectedDsSyncHist.getAttributeType();
+    Attribute actual = entry.getExactAttribute(attrType, Collections.<String> emptySet());
+
+    Assert.assertEquals(actual, expectedDsSyncHist, "wrong final value for ds-sync-hist attribute");
+  }
+
   private void noValue() throws Exception
   {
     // @formatter:off

--
Gitblit v1.10.0