mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
29.33.2015 1cb47119972075d5f94a77e1deb1ec7d052c09f1
OPENDJ-1192 Modify request replay failures

Added two test for the bug arising from a call to the SDK's diffEntries method:
- single valued attribute begins with X
- diffEntries produces a single modify operation with two modifications: add Y + delete X (resp. delete X + add Y)
- conflict resolution does not handle the temporary state where the attribute contains two values, X and Y.
1 files modified
34 ■■■■■ changed files
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplayTest.java 34 ●●●●● patch | view | raw | blame | history
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