cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6677] Updating the proxy impl
Date Mon, 16 Nov 2015 20:57:56 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes d2b5baa69 -> 08752e19d


[CXF-6677] Updating the proxy impl


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/08752e19
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/08752e19
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/08752e19

Branch: refs/heads/3.1.x-fixes
Commit: 08752e19dbe55998b1a8fd2c3554135be78541d6
Parents: d2b5baa
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Mon Nov 16 17:05:48 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon Nov 16 20:57:29 2015 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/client/ClientProxyImpl.java    | 16 +++++++++++-----
 .../org/apache/cxf/systest/jaxrs/BookStore.java     |  4 ++++
 .../systest/jaxrs/JAXRSClientServerBookTest.java    | 15 +++++++++------
 3 files changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/08752e19/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
index 85e4b95..d41721f 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
@@ -343,11 +343,17 @@ public class ClientProxyImpl extends AbstractClient implements
         if (headers.getFirst(HttpHeaders.CONTENT_TYPE) == null) {
             if (formParams || bodyClass != null && MultivaluedMap.class.isAssignableFrom(bodyClass))
{
                 headers.putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
-            } else if (bodyClass != null) {
-                String cType = ori.getConsumeTypes().isEmpty() 
-                    || ori.getConsumeTypes().get(0).equals(MediaType.WILDCARD_TYPE) 
-                    ? MediaType.APPLICATION_XML : JAXRSUtils.mediaTypeToString(ori.getConsumeTypes().get(0));
  
-                headers.putSingle(HttpHeaders.CONTENT_TYPE, cType);
+            } else {
+                String ctType = null;
+                List<MediaType> consumeTypes = ori.getConsumeTypes();
+                if (!consumeTypes.isEmpty() && !consumeTypes.get(0).equals(MediaType.WILDCARD_TYPE))
{
+                    ctType = JAXRSUtils.mediaTypeToString(ori.getConsumeTypes().get(0));
+                } else if (bodyClass != null) {
+                    ctType = MediaType.APPLICATION_XML;
+                }
+                if (ctType != null) {
+                    headers.putSingle(HttpHeaders.CONTENT_TYPE, ctType);
+                }
             }
         }
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/08752e19/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 cde5c7f..a0d506b 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
@@ -425,7 +425,11 @@ public class BookStore {
     
     @PUT
     @Path("emptyput")
+    @Consumes("application/json")
     public void emptyput() {
+        if (!httpHeaders.getMediaType().toString().equals("application/json")) {
+            throw new RuntimeException();
+        }
     }
     
     @POST

http://git-wip-us.apache.org/repos/asf/cxf/blob/08752e19/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
index 429cf0e..94c2897 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
@@ -1323,7 +1323,7 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
         WebClient wc = 
             WebClient.create("http://localhost:" 
                              + PORT + "/bookstore/emptyput");
-        Response response = wc.put(null);
+        Response response = wc.type("application/json").put(null);
         assertEquals(204, response.getStatus());
         assertNull(response.getMetadata().getFirst("Content-Type"));
         
@@ -1333,12 +1333,15 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     }
     
     @Test
+    public void testEmptyPutProxy() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        store.emptyput();
+        assertEquals(204, WebClient.client(store).getResponse().getStatus());
+    }
+    
+    @Test
     public void testEmptyPostProxy() throws Exception {
-        String address = "http://localhost:" + PORT;
-        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); 
-        bean.setAddress(address);
-        bean.setResourceClass(BookStore.class);
-        BookStore store = bean.create(BookStore.class);
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
         store.emptypost();
         assertEquals(204, WebClient.client(store).getResponse().getStatus());
     }


Mime
View raw message