cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1475979 - in /cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs: JAXRSClientServerSpringBookTest.java JAXRSMultipartTest.java MultipartServer.java MultipartStore.java
Date Thu, 25 Apr 2013 21:44:41 GMT
Author: sergeyb
Date: Thu Apr 25 21:44:40 2013
New Revision: 1475979

URL: http://svn.apache.org/r1475979
Log:
[CXF-4988] System test updates

Modified:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.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/MultipartServer.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/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=1475979&r1=1475978&r2=1475979&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
Thu Apr 25 21:44:40 2013
@@ -381,6 +381,7 @@ public class JAXRSClientServerSpringBook
     public void testGetBookXsiType() throws Exception {
         String address = "http://localhost:" + PORT + "/the/thebooksxsi/bookstore/books/xsitype";
         WebClient wc = WebClient.create(address);
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
         wc.accept("application/xml");
         Book book = wc.get(Book.class);
         assertEquals("SuperBook", book.getName());

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=1475979&r1=1475978&r2=1475979&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 Apr 25 21:44:40 2013
@@ -99,7 +99,8 @@ public class JAXRSMultipartTest extends 
         WebClient wc = WebClient.create(address);
         wc.type("multipart/mixed;type=text/xml");
         wc.accept("text/xml");
-        
+        WebClient.getConfig(wc).getRequestContext().put("support.type.as.multipart", 
+            "true");
         Book book = wc.post(new Book("CXF in Action - 2", 12345L), Book.class);
         assertEquals(432L, book.getId());
     }
@@ -346,6 +347,8 @@ public class JAXRSMultipartTest extends 
             getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/add_book.txt");
         String address = "http://localhost:" + PORT + "/bookstore/books/jaxb";
         WebClient client = WebClient.create(address);
+        WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",

+            "true");
         client.type("multipart/related;type=text/xml").accept("text/xml");
         Book book = client.post(is1, Book.class);
         assertEquals("CXF in Action - 2", book.getName());
@@ -387,10 +390,8 @@ public class JAXRSMultipartTest extends 
         bean.setProperties(Collections.singletonMap(org.apache.cxf.message.Message.MTOM_ENABLED,

                                                     (Object)"true"));
         WebClient client = bean.createWebClient();
-        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
-        conduit.getClient().setReceiveTimeout(1000000);
-        conduit.getClient().setConnectionTimeout(1000000);
-        
+        WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",

+            "true");
         client.type("multipart/related").accept("multipart/related");
         
         XopType xop = new XopType();
@@ -612,10 +613,9 @@ public class JAXRSMultipartTest extends 
             getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg");
         String address = "http://localhost:" + PORT + "/bookstore/books/image";
         WebClient client = WebClient.create(address);
-        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
-        conduit.getClient().setReceiveTimeout(1000000);
-        conduit.getClient().setConnectionTimeout(1000000);
         client.type("multipart/mixed").accept("multipart/mixed");
+        WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",

+            "true");
         InputStream is2 = client.post(is1, InputStream.class);
         byte[] image1 = IOUtils.readBytesFromStream(
             getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
@@ -663,11 +663,9 @@ public class JAXRSMultipartTest extends 
                                .toURI().getPath());
         String address = "http://localhost:" + PORT + "/bookstore/books/formimage2";
         WebClient client = WebClient.create(address);
-        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
-        conduit.getClient().setReceiveTimeout(1000000);
-        conduit.getClient().setConnectionTimeout(1000000);
         client.type("multipart/form-data").accept("multipart/form-data");
-        
+        WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",

+                                                            "true");
         MultipartBody body2 = client.post(file, MultipartBody.class);
         InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
         byte[] image1 = IOUtils.readBytesFromStream(

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java?rev=1475979&r1=1475978&r2=1475979&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
Thu Apr 25 21:44:40 2013
@@ -26,7 +26,6 @@ import org.apache.cxf.attachment.Attachm
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
     
 
@@ -40,7 +39,6 @@ public class MultipartServer extends Abs
         
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(AttachmentDeserializer.ATTACHMENT_MAX_SIZE, String.valueOf(1024 * 10));
-        props.put(JAXRSUtils.DEFAULT_PROVIDERS_FOR_SIMPLE_TYPES, "true");
         sf.setProperties(props);
         //default lifecycle is per-request, change it to singleton
         sf.setResourceProvider(MultipartStore.class,
@@ -65,4 +63,5 @@ public class MultipartServer extends Abs
             System.out.println("done!");
         }
     }
+    
 }

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=1475979&r1=1475978&r2=1475979&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 Apr 25 21:44:40 2013
@@ -88,7 +88,8 @@ public class MultipartStore {
     @Path("/books/image")
     @Consumes("multipart/mixed")
     @Produces("multipart/mixed")
-    public byte[] addBookImage(byte[] image) throws Exception {
+    @Multipart(type = "application/stream")
+    public byte[] addBookImage(@Multipart byte[] image) throws Exception {
         return image;
     }
     
@@ -96,7 +97,8 @@ public class MultipartStore {
     @Path("/xop")
     @Consumes("multipart/related")
     @Produces("multipart/related;type=text/xml")
-    public XopType addBookXop(XopType type) throws Exception {
+    @Multipart("xop")
+    public XopType addBookXop(@Multipart XopType type) throws Exception {
         if (!"xopName".equals(type.getName())) {
             throw new RuntimeException("Wrong name property");
         }
@@ -251,7 +253,7 @@ public class MultipartStore {
     @POST
     @Path("/books/stream")
     @Produces("text/xml")
-    public Response addBookFromStream(StreamSource source) throws Exception {
+    public Response addBookFromStream(@Multipart StreamSource source) throws Exception {
         JAXBContext c = JAXBContext.newInstance(new Class[]{Book.class});
         Unmarshaller u = c.createUnmarshaller();
         Book b = (Book)u.unmarshal(source);
@@ -336,7 +338,7 @@ public class MultipartStore {
     @POST
     @Path("/books/dsource")
     @Produces("text/xml")
-    public Response addBookFromDataSource(DataSource ds) throws Exception {
+    public Response addBookFromDataSource(@Multipart DataSource ds) throws Exception {
         return readBookFromInputStream(ds.getInputStream());
     }
     
@@ -445,7 +447,7 @@ public class MultipartStore {
     @Path("/books/jsonform")
     @Produces("text/xml")
     @Consumes("multipart/form-data")
-    public Response addBookJsonFromForm(Book b1) 
+    public Response addBookJsonFromForm(@Multipart Book b1) 
         throws Exception {
         b1.setId(124);
         return Response.ok(b1).build();
@@ -524,7 +526,7 @@ public class MultipartStore {
     @Path("/books/jaxbform")
     @Produces("text/xml")
     @Consumes("multipart/form-data")
-    public Response addBookJaxbFromForm(Book b1) 
+    public Response addBookJaxbFromForm(@Multipart Book b1) 
         throws Exception {
         b1.setId(124);
         return Response.ok(b1).build();
@@ -622,14 +624,14 @@ public class MultipartStore {
     @POST
     @Path("/books/dhandler")
     @Produces("text/xml")
-    public Response addBookFromDataHandler(DataHandler dh) throws Exception {
+    public Response addBookFromDataHandler(@Multipart DataHandler dh) throws Exception {
         return readBookFromInputStream(dh.getInputStream());
     }
     
     @POST
     @Path("/books/attachment")
     @Produces("text/xml")
-    public Response addBookFromAttachment(Attachment a) throws Exception {
+    public Response addBookFromAttachment(@Multipart Attachment a) throws Exception {
         return readBookFromInputStream(a.getDataHandler().getInputStream());
     }
     
@@ -662,7 +664,7 @@ public class MultipartStore {
     @POST
     @Path("/books/jaxb")
     @Produces("text/xml")
-    public Response addBook(Book b) throws Exception {
+    public Response addBook(@Multipart Book b) throws Exception {
         b.setId(124);
         return Response.ok(b).build();
     }
@@ -671,7 +673,7 @@ public class MultipartStore {
     @Path("/books/mismatch1")
     @Consumes("multipart/related;type=\"bar/foo\"")
     @Produces("text/xml")
-    public Response addBookMismatched(Book b) {
+    public Response addBookMismatched(@Multipart Book b) {
         throw new WebApplicationException();
     }
     



Mime
View raw message