Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-16620

ListAttachmentArchive's toRCS() method modifies the revision dates

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      This issue was introduced in XWIKI-5942.

      To summarize the problem:

      • toRCS() will call new Archive() or addRevision() which create new JRCS Node objects (either TrunkNode or BranchNode).
      • When a new JRCS Node is created, the date of the node is set to the current date (and time)
      • Thus calling toRCS() generates an Archive object that doesn't contain the real dates of the attachment revisions but the date of when toRCS() was called.

      This affects the new ListAttachmentArchiveTest#testGetArchiveAsString() test which compares ListAttachmentArchive#getArchive() (which calls toRCS()) with XWikiAttachmentArchive#getArchive(). The later is correct and doesn't change the dates but the former does and thus if the test doesn't execute fast enough, the comparison assert fails with:

      org.opentest4j.AssertionFailedError: array contents differ at index [85], expected: <51> but was: <50>
      	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:39)
      	at org.junit.jupiter.api.AssertArrayEquals.failArraysNotEqual(AssertArrayEquals.java:432)
      	at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:212)
      	at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:66)
      	at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:62)
      	at org.junit.jupiter.api.Assertions.assertArrayEquals(Assertions.java:1208)
      	at org.xwiki.store.legacy.doc.internal.ListAttachmentArchiveTest.testGetArchiveAsString(ListAttachmentArchiveTest.java:157)
      

      One solution is to extend Archive (see XWikiRCSArchive) with a new XWikiAttachmentRCSArchive class for example and have the code get the date from the attachment XML data and after the Node has been created, set the correct date on it.

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: