users@jersey.java.net

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

From: Markus Karg <karg_at_quipsy.de>
Date: Mon, 15 Sep 2014 08:24:49 +0200

Marek,

thanks a lot for the links! :)

As you see, being an EG member does not stop you from being lazy, blind or both! In fact, I was dumb enough not to see that renaming WebResource to WebTarget in the spec implied renaming resource() to target() in the RI! ;-)

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<mailto: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. :)

(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<https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/client/spi/Connector.html> and connector providers<https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/client/spi/ConnectorProvider.html>.

Cheers & have fun! :)

Marek



Thanks a lot!
-Markus