migrate from xmlunit 1.6 to xmlunit 2.x

Description

One of our testing dependencies is xmlunit version 1.6. This was released at the end of 2014 and has not been updated since. Instead, development work has moved to xmlunit 2.x, which is up to around 2.5.1 at the time of writing.

I don't see any likelihood that version 1.6 will ever be updated for compatibility or extended in any way. As version 2.5.1 is already a dependency of Spring 5's test module, it seems a given that we need to move onto the new release at some point, and doing this sooner rather than later is probably advisable.

The 2.x version has new APIs native to it, but it also comes with a "legacy" module that implements the old API with some deviations. So there's probably a relatively low-effort path for migration although they do warn that the legacy API won't get any new features.

One thing that does look as if it may affect us when using the "legacy" API is that all static configuration has been removed. For example, one could previously say XMLUnit.setIgnoreWhitespace() to cause all tests to ignore whitespace. We do this in some of our test parent classes.

This seems like a good change to the API (tests should be independent, surely) but there's a possibility that some of our tests will now fail in an environment where this default cannot be set. Such tests would need to have relevant input documents wrapped in a WhitespaceStrippedSource or use a DiffBuilder with the ignoreWhitespace property set, as described in https://github.com/xmlunit/user-guide/wiki/Migrating-from-XMLUnit-1.x-to-2.x

I will do some nature study on all this, starting from the V8 parent project (where I need Spring 5 anyway) but I will also try to investigate whether we can move the V7 parent forward without too much work.

Environment

None

Activity

Ian YoungMarch 9, 2018 at 5:52 PM

Work related to the parent project and immediately consequent changes in other projects is now done, so closing this.

Related issues opened for individual projects, and linked to this one.

Ian YoungMarch 9, 2018 at 5:33 PM

Phase 3: remove global dependency on legacy module:

java-parent-project maint-7 branch commit 7b358c9f26e15f81f41f1a93808c1022e62c18ea
java-parent-project master branch commit 10fbd08ddf16bc09434c062e845f51ccc0602c95

Ian YoungMarch 9, 2018 at 5:22 PM
Edited

Phase 2: add explicit dependency on legacy module where used:

java-support master branch commit 8476fa74ae07a94f7a136258028d781ac33e9cdd
java-support maint-7 branch commit 2f26829e6512edca264cd72f7ea8865677866aa9
java-metadata-aggregator master branch commit 
6527725c7b2d49738a17c8e18bbcd6fb9886ae7f
java-metadata-aggregator maint-0.9 branch commit e51ec7baaa50bf50fb5bed6d78b1f0030eadd2c8
xmlsectool commit 8f97751b6cdf2227b9b5765f44c86fb1e71c2c5c
java-opensaml commit c6d446c922997cb1f610f089765ec6df245dbe11
java-identity-provider commit 15d7309c446de5fe5fca1fa4c4307d14fb837384

Ian YoungMarch 9, 2018 at 3:58 PM

Phase 1: add new managed dependencies, replace default test dependency.

java-parent-project master branch commit 1e4863f9b204a03ea940e1e9fec975a85cab8473

java-parent-project maint-7 branch commit 34a3a484ad2f014a4cd3c20d7e49dcd53b065ac2

Ian YoungMarch 7, 2018 at 2:01 PM

Observations from the v7 stack:

The same technique (declare managed dependencies for all three xmlunit 2.5.1 modules, remove the permanent dependency on xmlunit, add it back where needed) works fine for the v7 stack: after adding appropriate dependencies for xmlunit-legacy, all tests run and pass without changes.

Projects with POMs that needed tweaking: java-parent-project (as above), xmlsectool, java-support, the aggregator-parent POM in the {{maint-0.9}} branch of java-metadata-aggregator, and the -parent POM in both java-opensaml and java-identity-provider.

So there seems to be no reason not to just go ahead and do this once Tom's current global changes (for Checkstyle) have stabilised.

Done

Details

Assignee

Reporter

Fix versions

Created March 6, 2018 at 4:40 PM
Updated April 21, 2020 at 2:56 PM
Resolved March 9, 2018 at 5:52 PM