users@jersey.java.net

[Jersey] Re: Migrating from Jersey Test Framework 1.x to 2.x

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 12 Sep 2014 21:48:48 +0200

Hi Markus,

On 10 Sep 2014, at 17:04, Markus Karg <karg_at_quipsy.de> wrote:

> I am currently migrating some rather old source code from Jersey Test Framework 1.x to 2.x and found some issue I couldn’t solve using the published docs, so I hope that the Jersey team reads this posting and can provide a short answer. J
>
> (1) The old code is using JerseyTest.resource() to get a client that is preconfigured to the path of the application (not a single resource!) provided in the constructor. There is no more resource() method now, so can I rely upon JerseyTest.client() to be preconfigured to the root URL of the application, or how to get that root URL in the 2.x test framework?

Just look around more carefully: https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/test/JerseyTest.html#target()

...after all you have been on JAX-RS EG where we renamed WebResource to WebTarget... ;-)

> (2) The old code is using URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND = Boolean.TRUE to enable the tweaks I contributed to Jersey some years ago. As URLConnectionClientHandler is gone in 2.x framework, how to enable the tweaks now?

See either of these:
https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/client/HttpUrlConnectorProvider.html#SET_METHOD_WORKAROUND
https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/client/HttpUrlConnectorProvider.html#useSetMethodWorkaround()

Jersey 2.x has replaced client handlers with connectors and connector providers.

Cheers & have fun! :)

Marek

>
> Thanks a lot!
> -Markus