1

I am writing some integration tests that need to compare a generated zip file containing mainly xml files with a baseline version. What is the easiest way to assert that two zip files contain the same files? One main requirement would be to produce human readable error messages pointing to the actual difference (e.g. element /xml/sth doesn't exist in file sthElse.xml in actual zip file), so simple byte-by-byte comparison is out of the question. Also, it would be nice if the comparison of the xml files is done using some DOM, to rule out irrelevant formatting etc.

Grzenio
  • 35,875
  • 47
  • 158
  • 240
  • can generation of an XSD out of existed XML and then comparison with a canonic XSD help you? – Yaugen Vlasau Feb 11 '14 at 11:12
  • @YaugenVlasau, for the actual `xml` comparison I thought I would try to use http://xmlunit.sourceforge.net/, might be easier. I haven't seen anything for the zip comparison though.... – Grzenio Feb 11 '14 at 11:15
  • 1
    but this is already half of the story! what about creating a temporary folder and unzip all content before the check. For unzipping the files you can execute command line command (http://stackoverflow.com/questions/206323/how-to-execute-command-line-in-c-get-std-out-results) of your archivator (in case of winrar http://comptb.cects.com/2503-using-the-winrar-command-line-tools-in-windows) – Yaugen Vlasau Feb 11 '14 at 13:12
  • @YaugenVlasau, I knocked up a small library, see my answer below. – Grzenio Feb 24 '14 at 21:20

1 Answers1

2

I couldn't find any ready-made tool, so I knocked up a library myself: ZipUnit. I am willing to maintain it and add new features, so please give me a chase if you require anything! And patches are obviously welcome as well.

Grzenio
  • 35,875
  • 47
  • 158
  • 240