users@jersey.java.net

[Jersey] Re: Unit Testing a Resource method that has QueryParam

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Fri, 19 Sep 2014 08:54:43 -0700

Isn't your problem that you are missing "/{path}"?

   @Path("resource/{path}")

You are getting a PathParam that doesn't seem to exist.


On Wed, Sep 17, 2014 at 10:39 PM, Sathyakumar <sathyakumar.s_at_gmail.com>
wrote:

> Am having trouble unit testing a Resource which has QueryParam (and also a
> path param) in it.
> I am extending JerseyTest class in my unit test. The QueryParam in my
> resource class's method is always null and the PathParam instead gets the
> query string appended to it,
>
> For e.g,
> ...
> @Path("resource")
> ...
> @GET
> public void get(@PathParam("path") String path, @QueryParam("q") String
> query)
> ..
>
> When I test the above resource with say /resource?q=test, I always get
> query value as null and path value as "resource?q=test". The same works if
> I just build and deploy the war, but wont work when unit tested by
> extending JerseyTest. (Am using version 2.12).
>
>
>