Hi Jonathan,
For that you would have to use the JAXB APIs for XML and the
JSONJAXBContext [1] for JSON, if using Jersey's JSON support.
But you would need to be careful to ensure the same configuration for
marshaling/unmarshaling as utilized by the JAX-RS application itself,
if that is what you are using. Thus testing the XML or JSON
independently of the application itself may actually create more work
as i presume you will want to test what is returned from the
application as well?
Paul.
[1]
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/index.html
On Feb 28, 2010, at 9:15 PM, Jonathan Cook - FM&T wrote:
> Hi,
>
> I wondered if there was a way to get the actual xml or json from a
> jaxb bean in a unit test? I can obviously test the get/set methods
> on the bean but I thought it would be nice to test the serialized
> json or xml as well. Can't see an obvious method to do this. Or do I
> have to setup an http container to test this from a unit test?
>
> Thanks
> Jon
>