users@jersey.java.net

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

From: Sathyakumar <sathyakumar.s_at_gmail.com>
Date: Sat, 20 Sep 2014 10:05:57 +0530

I just typed it wrong I guess. The issue is real. I will file a bug with a
reproducible test case

On Friday, September 19, 2014, Robert DiFalco <robert.difalco_at_gmail.com>
wrote:

> 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
> <javascript:_e(%7B%7D,'cvml','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).
>>
>>
>>
>