cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1205997 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 24 Nov 2011 22:19:48 GMT
Author: bimargulies
Date: Thu Nov 24 22:19:47 2011
New Revision: 1205997

URL: http://svn.apache.org/viewvc?rev=1205997&view=rev
Log:
Try to invent nullable multipart parameters. Test commented out because I can't figure it
out.

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.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/utils/multipart/AttachmentUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java?rev=1205997&r1=1205996&r2=1205997&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
Thu Nov 24 22:19:47 2011
@@ -108,6 +108,12 @@ public final class AttachmentUtils {
                     return a;    
                 }
             }
+            if (!id.errorIfMissing()) {
+                /*
+                 * If user asked for a null, give them a null. 
+                 */
+                return null;
+            }
             org.apache.cxf.common.i18n.Message errorMsg = 
                 new org.apache.cxf.common.i18n.Message("MULTTIPART_ID_NOT_FOUND", 
                                                        BUNDLE, 

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1205997&r1=1205996&r2=1205997&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Thu
Nov 24 22:19:47 2011
@@ -989,7 +989,7 @@ public class BookStore {
     }
     
     @XmlJavaTypeAdapter(BookInfoAdapter2.class)
-    static interface BookInfoInterface {
+    interface BookInfoInterface {
         String getName();
         
         long getId();

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=1205997&r1=1205996&r2=1205997&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 Nov 24 22:19:47 2011
@@ -28,6 +28,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -36,6 +37,7 @@ import javax.imageio.ImageIO;
 import javax.mail.util.ByteArrayDataSource;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
@@ -333,12 +335,25 @@ public class JAXRSMultipartTest extends 
         return ImageIO.read(getClass().getResource(name));
     }
     
+    @org.junit.Ignore
+    @Test
+    public void testNullableParams() throws Exception {
+        String address = "http://localhost:" + PORT + "/books/testnullpart";
+        WebClient client = WebClient.create(address);
+        client.type("multipart/form-data").accept("text/plain");
+        List<Attachment> atts = new LinkedList<Attachment>();
+        atts.add(new Attachment("somepart", "text/plain", "hello there"));
+        Response r = client.postCollection(atts, Attachment.class);
+        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
+        assertEquals("nobody home", r.getEntity());
+    }
+    
     @Test
     public void testAddBookJaxbJsonImageWebClient() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/jaxbjsonimage";
         WebClient client = WebClient.create(address);
         client.type("multipart/mixed").accept("multipart/mixed");
-        
+       
         Book jaxb = new Book("jaxb", 1L);
         Book json = new Book("json", 2L);
         InputStream is1 = 

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=1205997&r1=1205996&r2=1205997&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 Nov 24 22:19:47 2011
@@ -144,6 +144,18 @@ public class MultipartStore {
     }
     
     @POST
+    @Path("/books/testnullpart")
+    @Consumes("multipart/form-data")
+    @Produces("text/plain")
+    public String testNullPart(@Multipart(value = "someid", errorIfMissing = false) String
value) {
+        if (value != null) {
+            return value;
+        } else {
+            return "nobody home";
+        }
+    }
+    
+    @POST
     @Path("/books/jaxbjsonimage")
     @Consumes("multipart/mixed")
     @Produces("multipart/mixed")



Mime
View raw message