users@jersey.java.net

[Jersey] Re: JAXB to JSON in a Junit

From: Jason Erickson <jason_at_jasonerickson.com>
Date: Mon, 27 Jun 2011 11:24:11 -0700

Is this enough help?

ContextResolver<JAXBContext> resolver = new MyJAXBContextResolver();
JSONJAXBContext context = (JSONJAXBContext) resolver.getContext(MyClass.class);
JSONMarshaller marshaller = context.createJSONMarshaller();
JSONUnmarshaller unmarshaller = context.createJSONUnmarshaller();

On Jun 27, 2011, at 8:07 AM, Alejandro Calbazana wrote:

> Hi,
>
> Simple question...
>
> I'd like to verify serialization of JAXB annotated classes to JSON in
> a unit test as part of my service's test suite. Is this possible? It
> looks like Jersey facilitates the processing of JAXB to JSON, but I
> am not sure how to replicate this path in a junit to ensure that the
> serialization that Jersey will apply will be what I expect.
>
> Any help on this is appreciated.
>
> Thanks,
>
> Alejandro