Testing XML output of Servlet.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lev_Mitnitsky
Posted On:   Tuesday, October 22, 2002 02:19 AM

I'm testing my Servlet by HttpUnit (JUnit).
The servlet response is XML.
How i can test it using XML Schema, or other way ?
Thanks.

Re: Testing XML output of Servlet.

Posted By:   Bryan_Dollery  
Posted On:   Tuesday, October 22, 2002 04:20 PM

Hi,


Check out XML-Unit.


Cheers,


Bryan

Re: Testing XML output of Servlet.

Posted By:   Lasse_Koskela  
Posted On:   Tuesday, October 22, 2002 04:01 AM

If the generated document contains a DTD/schema reference ("this document obeys this and this DDT"), you could just parse it with a SAX parser with validation enabled. If the document doesn't conform to the DTD/schema it claims, an exception is thrown.


However, if the document doesn't define a DTD/schema reference and you should validate it against some specific DTD/schema, I'm not sure how it could be done.


But I have a hunch... You could write some kind of InputStream wrapper class and tweak the read() method(s) so that it first reads the contents of a String given upon instantiation (constructor parameter) and only then starts reading from some underlying InputStream pointing to the XML file. If you can get this to work, then you can apply the previous parsing approach.

About | Sitemap | Contact