users@jersey.java.net

Re: [Jersey] Problem using the JerseyTest class

From: Naresh <Srinivas.Bhimisetty_at_Sun.COM>
Date: Tue, 14 Jul 2009 19:12:40 +0530

tarjei wrote:
> 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.
Cool.
> I guess this should go into the docs?
I think I'll add it to the blog entry [1].

[1] http://blogs.sun.com/naresh/entry/jersey_test_framework_makes_it

Thanks,
Naresh
>
> 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
>
>
>
>