cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1503450 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Mon, 15 Jul 2013 20:22:18 GMT
Author: sergeyb
Date: Mon Jul 15 20:22:18 2013
New Revision: 1503450

URL: http://svn.apache.org/r1503450
Log:
Merged revisions 1503447 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1503447 | sergeyb | 2013-07-15 21:11:04 +0100 (Mon, 15 Jul 2013) | 1 line
  
  [CXF-5129] Update to HttpServletResponseFilter to get content-type not lost in some cases
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1503447

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java?rev=1503450&r1=1503449&r2=1503450&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
Mon Jul 15 20:22:18 2013
@@ -41,6 +41,21 @@ public class HttpServletResponseFilter e
     }
     
     @Override
+    public void setContentType(String ct) {
+        super.setContentType(ct);
+        m.getExchange().put(Message.CONTENT_TYPE, ct);
+    }
+    
+    @Override
+    public void addHeader(String name, String value) {
+        if (Message.CONTENT_TYPE.equals(name)) {
+            setContentType(value);
+        } else {
+            super.addHeader(name, value);
+        }
+    }
+    
+    @Override
     public ServletOutputStream getOutputStream() throws IOException {
         return new ServletOutputStreamFilter(super.getOutputStream(), m);
     }

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1503450&r1=1503449&r2=1503450&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Mon Jul 15 20:22:18 2013
@@ -167,6 +167,17 @@ public class BookStore {
         return doGetBook("123");
     }
     
+    @GET
+    @Path("/httpresponse")
+    public void getBookDesciptionHttpResponse(@Context HttpServletResponse response) {
+        response.setContentType("text/plain");
+        try {
+            response.getOutputStream().write("Good Book".getBytes());
+        } catch (IOException ex) {
+            throw new WebApplicationException(ex);
+        }
+    }
+    
     @RETRIEVE
     @Path("/retrieve")
     @Produces("application/xml")

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1503450&r1=1503449&r2=1503450&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Jul 15 20:22:18 2013
@@ -57,6 +57,7 @@ import org.apache.commons.httpclient.met
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -97,6 +98,16 @@ public class JAXRSClientServerBookTest e
         Response r = wc.form(new org.apache.cxf.jaxrs.ext.form.Form());
         assertEquals("empty form", r.readEntity(String.class));
     }
+    
+    @Test
+    public void testGetBookDescriptionHttpResponse() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/httpresponse";
+        WebClient wc = WebClient.create(address);
+        WebClient.getConfig(wc).getInInterceptors().add(new LoggingInInterceptor());
+        Response r = wc.get();
+        assertEquals("text/plain", r.getMediaType().toString());
+        assertEquals("Good Book", r.readEntity(String.class));
+    }
 
     @Test
     public void testGetCustomBookResponse() {



Mime
View raw message