cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1551206 - in /cxf/trunk: rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Date Mon, 16 Dec 2013 13:30:42 GMT
Author: sergeyb
Date: Mon Dec 16 13:30:41 2013
New Revision: 1551206

URL: http://svn.apache.org/r1551206
Log:
Updating JAX-RS proxies to buffer Response if requested

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1551206&r1=1551205&r2=1551206&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Mon Dec 16 13:30:41 2013
@@ -55,6 +55,7 @@ import javax.ws.rs.core.UriBuilder;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -84,6 +85,7 @@ public class ClientProxyImpl extends Abs
     private static final Logger LOG = LogUtils.getL7dLogger(ClientProxyImpl.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ClientProxyImpl.class);
     private static final String SLASH = "/";
+    private static final String BUFFER_PROXY_RESPONSE = "buffer.proxy.response";
     
     private ClassResourceInfo cri;
     private ClassLoader proxyLoader;
@@ -679,6 +681,10 @@ public class ClientProxyImpl extends Abs
                     && ((InputStream)r.getEntity()).available() == 0)) {
                 return r;
             }
+            if (PropertyUtils.isTrue(super.getConfiguration().getResponseContext().get(BUFFER_PROXY_RESPONSE)))
{
+                r.bufferEntity();
+            }
+            
             Class<?> returnType = method.getReturnType();
             Type genericType = 
                 InjectionUtils.processGenericTypeIfNeeded(serviceCls, 

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=1551206&r1=1551205&r2=1551206&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 Dec 16 13:30:41 2013
@@ -643,6 +643,15 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testBookWithSpaceProxyWithBufferedStream() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        WebClient.getConfig(store).getResponseContext().put("buffer.proxy.response", "true");
+        Book book = store.getBookWithSpace("123");
+        assertEquals(123L, book.getId());
+        assertTrue(WebClient.client(store).getResponse().readEntity(String.class).contains("<Book"));
+    }
+    
+    @Test
     public void testBookWithMultipleExceptions() throws Exception {
         List<Object> providers = new LinkedList<Object>();
         providers.add(new NotReturnedExceptionMapper());



Mime
View raw message