This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Testing and the fly likes XMLUnit ignore Timestamps? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "XMLUnit ignore Timestamps?" Watch "XMLUnit ignore Timestamps?" New topic
Author

XMLUnit ignore Timestamps?

Alex Noknownlastname
Greenhorn

Joined: Nov 04, 2009
Posts: 1
Hi,

I have a simple question:
Is it possible to ignore timestamps within the XML-Files using XMLUnit?

I use something like this:
Diff diff = new Diff(validString, toTestString);
this.assertXMLEqual(diff,true);

The valid-String contains other timestamps as the totest-String which comes from a running database.

A very simple solution would be to erase all "timestamplike" strings in the toTestString and the validString but I think that there is an other way ... something linke an own DifferenceListener?
I think that this task is a very common one but google did not help me

The only thing I found was: It is possible with an own implementation of the DifferenceListener interface but not how.

Thanks for help
mfg KhanQ

example:
<file key="onekey" timestamp="2009.12.01"
<something/>
</file>

should be resolved as equal with

<file key="onekey" timestamp="2007.10.02"
<something/>
</file>

The timestampvalue should be ignored.
 
Consider Paul's rocket mass heater.
 
subject: XMLUnit ignore Timestamps?
 
Similar Threads
Timestampt as a primary key in MySQL
Tools which compare/diff XML files
Lost precision in Double variable
My locking approach...comments please
Mark Spritzler/ Max H/Andrew Monkhouse: please comment on the holes in my design