Repository: cxf Updated Branches: refs/heads/master d29745feb -> 200b28254
Add a PATCH extension Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/200b2825 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/200b2825 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/200b2825 Branch: refs/heads/master Commit: 200b2825439a5ac42d0f848a53ad33441befe62c Parents: d29745f Author: Sergey Beryozkin <[email protected]> Authored: Sun Jul 26 22:23:36 2015 +0300 Committer: Sergey Beryozkin <[email protected]> Committed: Sun Jul 26 22:23:36 2015 +0300 ---------------------------------------------------------------------- .../java/org/apache/cxf/jaxrs/ext/PATCH.java | 39 ++++++++++++++++++++ .../org/apache/cxf/systest/jaxrs/BookStore.java | 9 +++++ .../cxf/systest/jaxrs/JAXRSAsyncClientTest.java | 11 ++++++ 3 files changed, 59 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/200b2825/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/PATCH.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/PATCH.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/PATCH.java new file mode 100644 index 0000000..b0befd8 --- /dev/null +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/PATCH.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.jaxrs.ext; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.ws.rs.HttpMethod; + +/** + * Indicates that the annotated method responds to HTTP PATCH requests. + * + * @see HttpMethod + */ +@Target({ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@HttpMethod("PATCH") +public @interface PATCH { + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/200b2825/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java index 2684b98..90564a8 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java @@ -91,6 +91,7 @@ import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.jaxrs.ext.MessageContext; import org.apache.cxf.jaxrs.ext.Nullable; import org.apache.cxf.jaxrs.ext.Oneway; +import org.apache.cxf.jaxrs.ext.PATCH; import org.apache.cxf.jaxrs.ext.StreamingResponse; import org.apache.cxf.jaxrs.ext.search.QueryContext; import org.apache.cxf.jaxrs.ext.search.SearchCondition; @@ -286,6 +287,14 @@ public class BookStore { return book; } + @PATCH + @Path("/patch") + @Produces("application/xml") + @Consumes("application/xml") + public Response patchBook(Book book) { + return Response.ok(book).build(); + } + @DELETE @Path("/deletebody") @Produces("application/xml") http://git-wip-us.apache.org/repos/asf/cxf/blob/200b2825/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java index a8bf64e..40c1255 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java @@ -89,6 +89,17 @@ public class JAXRSAsyncClientTest extends AbstractBusClientServerTestBase { } @Test + public void testPatchBook() throws Exception { + String address = "http://localhost:" + PORT + "/bookstore/patch"; + WebClient wc = WebClient.create(address); + wc.type("application/xml"); + WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", true); + Book book = wc.invoke("PATCH", new Book("Patch", 123L), Book.class); + assertEquals("Patch", book.getName()); + wc.close(); + } + + @Test public void testDeleteWithBody() throws Exception { String address = "http://localhost:" + PORT + "/bookstore/deletebody"; WebClient wc = WebClient.create(address);
