cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1421245 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 13 Dec 2012 12:27:09 GMT
Author: sergeyb
Date: Thu Dec 13 12:27:08 2012
New Revision: 1421245

URL: http://svn.apache.org/viewvc?rev=1421245&view=rev
Log:
[CXF-4697] Fixing MultipartProvider to correctly read Maps by applying a quality patch from
William Tam

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java?rev=1421245&r1=1421244&r2=1421245&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
Thu Dec 13 12:27:08 2012
@@ -143,7 +143,7 @@ public class MultipartProvider extends A
             && AnnotationUtils.getAnnotation(anns, Multipart.class) == null) {
             return getAttachmentCollection(t, infos, anns);
         }
-        if (Map.class.isAssignableFrom(c)) {
+        if (c.isAssignableFrom(Map.class)) {
             Map<String, Object> map = new LinkedHashMap<String, Object>(infos.size());
             Class<?> actual = getActualType(t, 1);
             for (Attachment a : infos) {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=1421245&r1=1421244&r2=1421245&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
Thu Dec 13 12:27:08 2012
@@ -244,6 +244,12 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
+    public void testAddBookMixedMultiValueMapParameter() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/books/mixedmultivaluedmap";
+        doAddBook("multipart/mixed", address, "attachmentFormMixed", 200);              

+    }
+    
+    @Test
     public void testAddBookAsJAXBJSON() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/jaxbjson";
         doAddBook(address, "attachmentData2", 200);               

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java?rev=1421245&r1=1421244&r2=1421245&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
Thu Dec 13 12:27:08 2012
@@ -648,6 +648,36 @@ public class MultipartStore {
         throw new WebApplicationException();
     }
     
+    @POST
+    @Path("/books/mixedmultivaluedmap")
+    @Consumes("multipart/mixed")
+    @Produces("text/xml")
+    public Response addBookFromFormConsumesMixed(
+        @Multipart(value = "mapdata", type = MediaType.APPLICATION_FORM_URLENCODED) 
+        MultivaluedMap<String, String> data,
+        @Multipart(value = "test-cid", type = MediaType.APPLICATION_XML) 
+        String testXml) throws Exception {
+        if (!"Dreams".equals(data.get("id-name").get(0))) {
+            throw new Exception("Map entry 0 does not match");
+        }
+        if (!"True".equals(data.get("entity-name").get(0))) {
+            throw new Exception("Map entry 1 does not match");
+        }
+        if (!"NAT5\n".equals(data.get("native-id").get(0))) {
+            throw new Exception("Map entry 2 does not match");
+        }
+        if (data.size() != 3) {
+            throw new Exception("Map size does not match");
+        }
+        if ("<hello>World2</hello>".equals(testXml)) {
+            throw new Exception("testXml does not match");
+        }
+        
+        Book b = new Book();
+        b.setId(124);
+        b.setName("CXF in Action - 2");
+        return Response.ok(b).build();
+    }
     private Response readBookFromInputStream(InputStream is) throws Exception {
         JAXBContext c = JAXBContext.newInstance(new Class[]{Book.class});
         Unmarshaller u = c.createUnmarshaller();



Mime
View raw message