users@jersey.java.net

Re: SV: [Jersey] Jersey and UriInfo.getQueryParameters()

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 30 Mar 2009 11:07:29 +0200

Hi Tor,

You might want to take a look at some of the Jersey samples. They
utilize testing using embedded contains, e.g. embedded GF.

Naresh has recently committed a new JUnit-based test-framework to the
trunk to make it easier to write unit tests with embedded servers
utilizing the Jersey client API.

Paul.


On Mar 29, 2009, at 6:43 PM, Wilhelmsen Tor Iver wrote:

>> How are you sending the request, using a browser? or say using curl?
>
> The testing is done using Maven's Surefire plugin on JUnit 4.4 test
> classes with HttpUnit 1.6, and also manually by typing into Firefox'
> address bar on a deployed instance.
>
>> What Web container are you using? do you have any "filters"
>> configured
>> for that container that modify the request URI?
>
> The container when testing is ServletUnit's ServletRunner,
> configured to
> point to the project's web.xml
>
> The container when deployed is Glassfish 2.1 (or as Sun calls this
> particular distribution Glassfish Web Space 10, i.e. "Glassfish +
> modified Liferay 5.2 portal")
>
> Before rewriting to use getQueryParameters() I had an initial version
> which only searched using name; that used @QueryParam("name") which
> worked fine.
>
>> I wonder if you could modify your "query" method as follows to print
>> out some stuff:
>>
>>
>> public ... query(@Context HttpServletRequest hsr) {
>> System.out.println("UriInfo.getRequestUri() = " +
>> info.getRequestUri());
>>
>>
>> System.out.println("HttpServletRequest.getQueryString() = "
>> + hsr.getQueryString());
>>
>> ...
>> }
>
> In tests:
>
> UriInfo.getRequestUri() = http://localhost/employees
> HttpServletRequest.getQueryString() =
>
> Under Glassfish however, it does have the complete line apparently...
>
> So I conclude that httpunit 1.6 is broken, and that I will skip those
> tests instead, and rely on the method working in well-behaved
> containers... :)
>
> (Also just tried using the latest 1.6.2 but that is even more broken,
> i.e. it insists content-type is text/plain instead of
> application/xml...)
>
> Thanks for the feedback!
>
> - Tor Iver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>