cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1086588 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Date Tue, 29 Mar 2011 14:10:06 GMT
Author: sergeyb
Date: Tue Mar 29 14:10:05 2011
New Revision: 1086588

URL: http://svn.apache.org/viewvc?rev=1086588&view=rev
Log:
[JAX-RS] Making sure JAXBProvider does not accept Response if unmarshalAsJaxbElement flag
is set

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1086588&r1=1086587&r2=1086588&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Tue Mar 29 14:10:05 2011
@@ -324,7 +324,7 @@ public abstract class AbstractJAXBProvid
     }
     
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType
mt) {
-        return marshalAsJaxbElement || isSupported(type, genericType, anns);
+        return (marshalAsJaxbElement && type != Response.class) || isSupported(type,
genericType, anns);
     }
 
     public void setSchemaLocations(List<String> locations) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1086588&r1=1086587&r2=1086588&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue Mar 29 14:10:05 2011
@@ -41,6 +41,7 @@ import java.util.TreeSet;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
@@ -1007,6 +1008,23 @@ public class JAXBElementProviderTest ext
     }
     
     @Test 
+    public void testResponseIsNotReadable() {
+        JAXBElementProvider p = new JAXBElementProvider();
+        assertFalse(p.isReadable(Response.class, 
+                                 Response.class, 
+                                 new Annotation[]{}, MediaType.APPLICATION_XML_TYPE));
+    }
+    
+    @Test 
+    public void testResponseIsNotReadable2() {
+        JAXBElementProvider p = new JAXBElementProvider();
+        p.setUnmarshallAsJaxbElement(true);
+        assertFalse(p.isReadable(Response.class, 
+                                 Response.class, 
+                                 new Annotation[]{}, MediaType.APPLICATION_XML_TYPE));
+    }
+    
+    @Test 
     public void testPackageContextObjectFactory() {
         JAXBElementProvider p = new JAXBElementProvider();
         assertTrue(p.isReadable(org.apache.cxf.jaxrs.fortest.jaxb.Book.class, 



Mime
View raw message