users@jersey.java.net

[Jersey] Re: PATCH support in Jersey Test Framework?

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 27 Mar 2012 08:28:58 +0200

Hello,

please see
http://jersey.java.net/nonav/apidocs/1.12/jersey/com/sun/jersey/client/urlconnection/URLConnectionClientHandler.html

PATCH (and any "non-standard") http method is not supported by
HttpUrlConnection from jdk and jersey-client uses that. You can
workaround this by using apache client, non-blocking client or mentioned
property (which is only experimental workaround).

Regards,
Pavel

On 3/26/12 10:12 PM, Jeremy Johnson wrote:
>
> Hi John,
>
> Thanks so much. This is exactly what I did to support PATCH
> server-side and it works like a champ.
>
> Where I'm having difficulties is on the client side testing PATCH
> using Jersey Test Framework. For the time being I'm using PATCH
> tunneling over POST via a X-HTTP-Method-Override header (thanks to the
> list for the needed init params to make it happen). This allows me to
> test the PATCH handlers on the server, but it seems that for thorough
> coverage I should have test cases using proper PATCH verbs as well.
>
> Thanks!
>
> *From:*John Yeary [mailto:johnyeary_at_gmail.com]
> *Sent:* Monday, March 26, 2012 3:54 PM
> *To:* users_at_jersey.java.net
> *Subject:* [Jersey] Re: PATCH support in Jersey Test Framework?
>
> Hello Jeremy,
>
> PATCH is not supported in Jersey. You may write your own method for PATCH.
>
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> import java.lang.annotation.Target;
>
> @Target({ElementType.METHOD})
> @Retention(RetentionPolicy.RUNTIME)
> @HttpMethod("PATCH")
> public @interface PATCH {
> }
>
>
> ____________________________
>
> John Yeary
>
> ____________________________
>
> *NetBeans Dream Team*
> *President Greenville Java Users Group
> Java Users Groups Community Leader
> Java Enterprise Community Leader*
> Description: Image removed by sender.
>
> ____________________________
>
> Description: Image removed by sender.
> <http://javaevangelist.blogspot.com/> Description: Image removed by
> sender. <https://twitter.com/jyeary> Description: Image removed by
> sender. <http://www.youtube.com/johnyeary> Description: Image removed
> by sender. <http://www.linkedin.com/in/jyeary> Description: Image
> removed by sender. <https://plus.google.com/112146428878473069965>
> Description: Image removed by sender. <http://www.facebook.com/jyeary>
> Description: Image removed by sender.
> <http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
> Description: Image removed by sender.
> <http://netbeans.org/people/84414-jyeary>
>
>
> "Far better it is to dare mighty things, to win glorious triumphs,
> even though checkered by failure, than to take rank with those poor
> spirits who neither enjoy much nor suffer much, because they live in
> the gray twilight that knows not victory nor defeat."
> -- Theodore Roosevelt
>
>
>
> On Mon, Mar 26, 2012 at 12:40 PM, Jeremy Johnson
> <jeremy.johnson_at_imtc.gatech.edu
> <mailto:jeremy.johnson_at_imtc.gatech.edu>> wrote:
>
> Hi folks,
>
> I'm trying to use the Jersey Test Framework v. 1.12 to test a web
> service that makes use of HTTP PATCH.
>
> I tried calling WebResource.Builder.method( "PATCH", ...) but received
> the following exception:
>
> com.sun.jersey.api.client.ClientHandlerException:
> java.net.ProtocolException: Invalid HTTP method: PATCH
>
> Is there a simple solution for getting the Test Framework to play
> nicely with PATCH?
>
> Thanks,
>
> Jeremy
>