cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r787311 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Mon, 22 Jun 2009 16:42:44 GMT
Author: dkulp
Date: Mon Jun 22 16:42:44 2009
New Revision: 787311

URL: http://svn.apache.org/viewvc?rev=787311&view=rev
Log:
Merged revisions 787291 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r787291 | sergeyb | 2009-06-22 11:59:28 -0400 (Mon, 22 Jun 2009) | 1 line
  
  CXF-2291 : proper handling of Response return values in the client api
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun 22 16:42:44 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290,787305
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun 22 16:42:44 2009
@@ -1 +1 @@
-/cxf/trunk:1-782619,782728-782730,783097,783294,783396,784059,784181-784184,784893-785866,785932,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290,787305
+/cxf/trunk:1-782619,782728-782730,783097,783294,783396,784059,784181-784184,784893-785866,785932,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=787311&r1=787310&r2=787311&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Mon Jun 22 16:42:44 2009
@@ -330,6 +330,12 @@
             } catch (Exception ex) {
                 // nothing we can do really
             }
+        } else {
+            try {
+                responseBuilder.entity(conn.getInputStream());
+            } catch (Exception ex) {
+                // it may that the successful response has no response body
+            }
         }
         return responseBuilder;
     }
@@ -388,11 +394,14 @@
         if (mbr != null) {
             try {
                 return mbr.readFrom(cls, type, anns, contentType, 
-                       new MetadataMap<String, Object>(r.getMetadata(), true, true),
conn.getInputStream());
+                       new MetadataMap<String, Object>(r.getMetadata(), true, true),

+                       (InputStream)r.getEntity());
             } catch (Exception ex) {
                 throw new WebApplicationException();
             }
              
+        } else if (cls == Response.class) {
+            return r;
         } else {
             reportNoMessageHandler("NO_MSG_READER", cls);
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=787311&r1=787310&r2=787311&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Mon Jun 22 16:42:44 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxrs.client;
 
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
@@ -399,7 +400,9 @@
         if (method.getReturnType() == Void.class) { 
             return null;
         }
-        if (method.getReturnType() == Response.class) {
+        if (method.getReturnType() == Response.class
+            && (r.getEntity() == null || InputStream.class.isAssignableFrom(r.getEntity().getClass())
+                && ((InputStream)r.getEntity()).available() == 0)) {
             return r;
         }
         

Modified: cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=787311&r1=787310&r2=787311&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Mon Jun 22 16:42:44 2009
@@ -375,7 +375,7 @@
             throw new RuntimeException("Unexpected content type");
         }
         
-        book.setId(++bookId);
+        book.setId(bookId + 1);
         books.put(book.getId(), book);
 
         return Response.ok(book).build();

Modified: cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=787311&r1=787310&r2=787311&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Jun 22 16:42:44 2009
@@ -40,6 +40,7 @@
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
@@ -67,6 +68,20 @@
                       "application/xml", 500);
     }
     
+    @Test 
+    public void testAddBookProxyResponse() {
+        BookStore store = JAXRSClientFactory.create("http://localhost:9080", BookStore.class);
+        Book b = new Book("CXF rocks", 123L);
+        Response r = store.addBook(b);
+        assertNotNull(r);
+        InputStream is = (InputStream)r.getEntity();
+        assertNotNull(is);
+        XMLSource source = new XMLSource(is);
+        source.setBuffering(true);
+        assertEquals(124L, Long.parseLong(source.getValue("Book/id")));
+        assertEquals("CXF rocks", source.getValue("Book/name"));
+    }
+    
     @Test
     public void testGetBookByURL() throws Exception {
         getAndCompareAsStrings("http://localhost:9080/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123",
@@ -242,7 +257,7 @@
     @Test
     public void testBookExists() throws Exception {
         checkBook("http://localhost:9080/bookstore/books/check/123", true);
-        checkBook("http://localhost:9080/bookstore/books/check/124", false);  
+        checkBook("http://localhost:9080/bookstore/books/check/125", false);  
         
     }
     



Mime
View raw message