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: Tue, 16 Sep 2014 16:33:04 +0200

On 16 Sep 2014, at 11:21, Markus Karg <karg_at_quipsy.de> wrote:

> Marek,
>
> thank you for your kind help. In fact, I now am using the below code, and it is working like a charm! J
>
> @Override protected final void configureClient(final ClientConfig config) {
> config.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, TRUE);
> }
>
> I hope that with JEP 110’s new HTTP 2.0 Client API announced to be part of Java SE 9 tricks like those are finally not needed anymore on ANY JRE… ;-)

Yeah, that would certainly help :)

Marek

>
> Regards
> -Markus
>
> Von: Marek Potociar [mailto:marek.potociar_at_oracle.com]
> Gesendet: Freitag, 12. September 2014 21:49
> An: users_at_jersey.java.net
> Betreff: [Jersey] Re: Migrating from Jersey Test Framework 1.x to 2.x
>
> 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