> From: Michael Rettig [mailto:[EMAIL PROTECTED]]
> 
> ----- Original Message -----
> From: Dominique Devienne <[EMAIL PROTECTED]>
> Date: Mon, 25 Nov 2002 10:43:27 -0600
> To: "''Jakarta Commons Users List''" <[EMAIL PROTECTED]>
> Subject: RE: [jelly] assertEquals with XPATH
> > This was discussed on the Ant forums a while back, and 
> someone pointed to
> > xmlunit on SF, which has assertions for XML documents. Regards, --DD
> > 
> > :pserver:[EMAIL PROTECTED]:/cvsroot/xmlunit
> > 
> Yes, XMLUnit would be a perfect choice. Everything is already 
> implemented. Just the jelly tags have to be created. It 
> already has support for comparing xml strings, and input 
> streams. Upon failures, it gives meaningful descriptions of 
> comparison failures. 
> 
> Did I hear somebody is going to create the patch?
> 

I have written a simple TagLibrary which uses XMLUnit to compare two XML
documents.  There is a <assertDocumentsEqual/> tag which is used either with
only the attributes expected and actual:

<xu:assertDocumentsEqual expected="${doc1}" actual="${doc2}"/>

or with nested elements:

<xu:assertDocumentsEqual>
 <xu:expected>
  <someDocument/>
 </xu:expected>
 <xu:actual>
  <someOtherDocument/>
 </xu:actual>
</xu:assertDocumentsEqual>

Of course also a combination of attribute and nested element is possible.

The tag works very much like the <x:parse/> tag.  An attribute is assumed to
be of type Document, String, URI, Reader, or InputStream.  Whereas when
nested elements are used, the evaluated content is used as the XML document.

If two documents are not identical, the tag throws an AssertionFailedError
(like <junit:assertEquals/>) with the message provided by XMLUnit.

I was hoping I could add some kind of "execute" attribute to the nested
<xu:expected/> and <xu:actual/> tags, which would indicate that the content
should not be evaluated but passed on as is.  But that doesn't seem to be
possible or is it?

Comments?  Anything that's missing or should be renamed in this initial
version?  What's the best way to contribute this tag library?

Cheers,

--
knut

Reply via email to