cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1404308 - in /cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs: JAXRSMultipartTest.java MultipartStore.java
Date Wed, 31 Oct 2012 19:19:32 GMT
Author: sergeyb
Date: Wed Oct 31 19:19:32 2012
New Revision: 1404308

URL: http://svn.apache.org/viewvc?rev=1404308&view=rev
Log:
[CXF-4348] Adding one more test

Modified:
    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/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=1404308&r1=1404307&r2=1404308&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 Oct 31 19:19:32 2012
@@ -50,6 +50,7 @@ import org.apache.commons.httpclient.met
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
 import org.apache.commons.httpclient.methods.multipart.Part;
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -411,10 +412,29 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
-    public void testAddBookJaxbJsonImageWebClient() throws Exception {
+    public void testAddBookJaxbJsonImageWebClientMixed() throws Exception {
+        Map<String, String> params = 
+            doTestAddBookJaxbJsonImageWebClient("multipart/mixed");
+        assertEquals(1, params.size());
+        assertNotNull(params.get("boundary"));
+        
+    }
+    
+    @Test
+    public void testAddBookJaxbJsonImageWebClientRelated() throws Exception {
+        Map<String, String> params = 
+            doTestAddBookJaxbJsonImageWebClient("multipart/related");
+        assertEquals(3, params.size());
+        assertNotNull(params.get("boundary"));
+        assertNotNull(params.get("type"));
+        assertNotNull(params.get("start"));
+    }
+    
+    private Map<String, String> doTestAddBookJaxbJsonImageWebClient(String multipartType)
throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/jaxbjsonimage";
         WebClient client = WebClient.create(address);
-        client.type("multipart/mixed").accept("multipart/mixed");
+        WebClient.getConfig(client).getInInterceptors().add(new LoggingInInterceptor());
+        client.type(multipartType).accept(multipartType);
        
         Book jaxb = new Book("jaxb", 1L);
         Book json = new Book("json", 2L);
@@ -441,10 +461,7 @@ public class JAXRSMultipartTest extends 
         String ctString = 
             client.getResponse().getMetadata().getFirst("Content-Type").toString();
         MediaType mt = MediaType.valueOf(ctString);
-        Map<String, String> params = mt.getParameters();
-        assertEquals(1, params.size());
-        assertNotNull(params.get("boundary"));
-        
+        return mt.getParameters();
     }
     
     @Test

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=1404308&r1=1404307&r2=1404308&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 Oct 31 19:19:32 2012
@@ -166,8 +166,8 @@ public class MultipartStore {
     
     @POST
     @Path("/books/jaxbjsonimage")
-    @Consumes("multipart/mixed")
-    @Produces("multipart/mixed")
+    @Consumes({"multipart/mixed", "multipart/related" })
+    @Produces({"multipart/mixed", "multipart/related" })
     public Map<String, Object> addBookJaxbJsonImage(@Multipart("root.message@cxf.apache.org")
Book jaxb, 
                                                     @Multipart("1") Book json, 
                                                     @Multipart("2") byte[] image) throws
Exception {



Mime
View raw message