users@jersey.java.net

Re: [Jersey] Problem using the JerseyTest class

From: tarjei <tarjei_at_nu.no>
Date: Tue, 14 Jul 2009 15:29:09 +0200

Hi,

Naresh, hero of the day, wrote:
> super();
> Map<String, String> contextParams = new HashMap<String, String>();
> contextParams.put("contextConfigLocation",
> "classpath:applicationContext-HSQLdb.xml");
> ApplicationDescriptor appDescriptor = new ApplicationDescriptor()
> .setContextPath(your-context-path)
>
> .setRootResourcePackageName(your-root-resource-package-name)
>
> .setServletClass(com.sun.jersey.spi.spring.container.servlet.SpringServlet.class)
>
>
> .setContextListenerClassName("org.springframework.web.context.ContextLoaderListener")
>
> .setContextParams(contextParams);
> super.setupTestEnvironment(appDescriptor);
Great!
That worked. I guess this should go into the docs?

Now I got another problem.

I use the Webresource to do a request like this:
SourceView sv = new SourceView();
.. set some sv attributes ..
SourceView sv2 = webResource.path("source").put(SourceView.class, sv);

and according to the logging, a request containing the correct XML is
generated and PUT to the server, but in my method I get a null instead
of the expected object.

Any tips to why?

The method signature looks like this:
        @PUT
        @Path("/")
     @Consumes({
                "application/xml",
                "text/xml"})
        public SourceView create(SourceView s) {
...
}



Kind regards,
Tarjei




-- 
Tarjei Huse
Mobil: 920 63 413