cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Add a PATCH extension
Date Sun, 26 Jul 2015 19:25:06 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7dfe07160 -> ffb79aa67


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/ffb79aa6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ffb79aa6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ffb79aa6

Branch: refs/heads/3.0.x-fixes
Commit: ffb79aa67edf3abe335690f9a528d8209b5c82bb
Parents: 7dfe071
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Sun Jul 26 22:23:36 2015 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Sun Jul 26 22:24:43 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/ffb79aa6/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/ffb79aa6/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/ffb79aa6/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 e1eead5..1b747a0 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
@@ -90,6 +90,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);


Mime
View raw message