cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1062807 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Mon, 24 Jan 2011 14:44:30 GMT
Author: sergeyb
Date: Mon Jan 24 14:44:29 2011
New Revision: 1062807

URL: http://svn.apache.org/viewvc?rev=1062807&view=rev
Log:
[CXF-3207] Updating WebClient to support ResponseReader

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1062807&r1=1062806&r2=1062807&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Mon Jan 24 14:44:29 2011
@@ -392,10 +392,6 @@ public class AbstractClient implements C
         
         MessageBodyWriter mbw = ProviderFactory.getInstance(outMessage).createMessageBodyWriter(
             cls, type, anns, contentType, outMessage);
-        if (mbw == null) {
-            mbw = ProviderFactory.getInstance().createMessageBodyWriter(
-                      cls, type, anns, contentType, outMessage);
-        }
         if (mbw != null) {
             try {
                 mbw.writeTo(o, cls, type, anns, contentType, headers, os);
@@ -436,10 +432,6 @@ public class AbstractClient implements C
         
         MessageBodyReader mbr = ProviderFactory.getInstance(outMessage).createMessageBodyReader(
             cls, type, anns, contentType, outMessage);
-        if (mbr == null) {
-            ProviderFactory.getInstance().createMessageBodyReader(
-                cls, type, anns, contentType, outMessage);
-        }
         if (mbr != null) {
             try {
                 return mbr.readFrom(cls, type, anns, contentType, 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1062807&r1=1062806&r2=1062807&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Mon
Jan 24 14:44:29 2011
@@ -237,7 +237,7 @@ public class WebClient extends AbstractC
      *         error message if client or server error occured
      */
     public Response invoke(String httpMethod, Object body) {
-        return doInvoke(httpMethod, body, InputStream.class, InputStream.class);
+        return doInvoke(httpMethod, body, Response.class, Response.class);
     }
     
     /**
@@ -636,7 +636,8 @@ public class WebClient extends AbstractC
             
             Object entity = readBody(currentResponse, conn, outMessage, responseClass, genericType,
                                      new Annotation[]{});
-            rb.entity(entity);
+            rb.entity(entity instanceof Response 
+                      ? ((Response)entity).getEntity() : entity);
             
             return rb.build();
         } catch (Throwable ex) {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1062807&r1=1062806&r2=1062807&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Jan 24 14:44:29 2011
@@ -589,6 +589,18 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testGetBookFromResponseWithWebClient() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/genericresponse/123";
+        WebClient wc = WebClient.create(address, 
+                                        Collections.singletonList(
+                                        new ResponseReader(Book.class)));
+        Response r = wc.accept("application/xml").get();
+        assertEquals(200, r.getStatus());
+        Book book = (Book)r.getEntity();
+        assertEquals(123L, book.getId());
+    }
+    
+    @Test
     public void testUpdateWithProxy() throws Exception {
         BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
         Book book = new Book();



Mime
View raw message