Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 44653 invoked from network); 6 Apr 2011 11:43:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Apr 2011 11:43:06 -0000 Received: (qmail 18515 invoked by uid 500); 6 Apr 2011 11:43:06 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 18468 invoked by uid 500); 6 Apr 2011 11:43:06 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 18461 invoked by uid 99); 6 Apr 2011 11:43:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Apr 2011 11:43:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Apr 2011 11:43:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E450C23889E2; Wed, 6 Apr 2011 11:42:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110406114241.E450C23889E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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