cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1089407 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/
Date Wed, 06 Apr 2011 11:42:41 GMT
Author: sergeyb
Date: Wed Apr  6 11:42:41 2011
New Revision: 1089407

URL: http://svn.apache.org/viewvc?rev=1089407&view=rev
Log:
[JAX-RS] Verifying multipart/form-data requests with a single file can be handled, minor update
to simplify the retrieval of multipart/form-data parts

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFile
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartBody.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/ext/multipart/MultipartBody.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartBody.java?rev=1089407&r1=1089406&r2=1089407&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartBody.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartBody.java
Wed Apr  6 11:42:41 2011
@@ -85,6 +85,10 @@ public class MultipartBody {
             if (contentId.equalsIgnoreCase(a.getContentId())) {
                 return a;
             }
+            ContentDisposition cd = a.getContentDisposition();
+            if (cd != null && contentId.equals(cd.getParameter("name"))) {
+                return a;
+            }
         }
         return null;
     }

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=1089407&r1=1089406&r2=1089407&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
Wed Apr  6 11:42:41 2011
@@ -123,12 +123,18 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
-    public void testBookJSONFormFiles() throws Exception {
+    public void testBookJSONFormTwoFiles() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/filesform";
         doAddFormBook(address, "attachmentFormJsonFiles", 200);               
     }
     
     @Test
+    public void testBookJSONFormOneFile() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/books/fileform";
+        doAddFormBook(address, "attachmentFormJsonFile", 200);               
+    }
+    
+    @Test
     public void testBookAsMessageContextAttachment() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/attachment";
         doAddBook(address, "attachmentData", 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=1089407&r1=1089406&r2=1089407&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
Wed Apr  6 11:42:41 2011
@@ -379,6 +379,23 @@ public class MultipartStore {
     }
     
     @POST
+    @Path("/books/fileform")
+    @Produces("text/xml")
+    @Consumes("multipart/form-data")
+    public Response addBookFilesForm(MultipartBody body) 
+        throws Exception {
+        String owner = body.getAttachmentObject("owner", String.class);
+        Book book = body.getAttachmentObject("file", Book.class);
+        if (!"CXF in Action - 1".equals(book.getName())
+            || !"Larry".equals(owner)) {
+            throw new WebApplicationException();
+        }
+        book.setId(124);
+        book.setName("CXF in Action - 2");
+        return Response.ok(book).build();
+    }
+    
+    @POST
     @Path("/books/jaxbform")
     @Produces("text/xml")
     @Consumes("multipart/form-data")

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFile
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFile?rev=1089407&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFile
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFile
Wed Apr  6 11:42:41 2011
@@ -0,0 +1,13 @@
+
+--bqJky99mlBWa-ZuqjC53mG6EzbmlxB
+Content-Disposition: form-data; name="owner"
+Content-Type: text/plain
+
+Larry
+--bqJky99mlBWa-ZuqjC53mG6EzbmlxB
+Content-Disposition: form-data; name="file"; filename="book1.text"
+Content-Type: application/json; charset=US-ASCII
+Content-Transfer-Encoding: 8bit
+
+{"Book":{"name":"CXF in Action - 1","id":123}}
+--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
\ No newline at end of file



Mime
View raw message