cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1484513 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Mon, 20 May 2013 16:21:40 GMT
Author: sergeyb
Date: Mon May 20 16:21:39 2013
New Revision: 1484513

URL: http://svn.apache.org/r1484513
Log:
[CXF-5027] Support for XmlAttachmentRef in the JAX-RS XOP marshaller

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentMarshaller.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
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XopType.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentMarshaller.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentMarshaller.java?rev=1484513&r1=1484512&r2=1484513&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentMarshaller.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentMarshaller.java
Mon May 20 16:21:39 2013
@@ -20,10 +20,12 @@
 package org.apache.cxf.jaxrs.provider;
 
 import java.util.Collection;
+import java.util.UUID;
 
 import javax.activation.DataHandler;
 import javax.xml.bind.attachment.AttachmentMarshaller;
 
+import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.attachment.AttachmentUtil;
 import org.apache.cxf.message.Attachment;
 
@@ -70,7 +72,11 @@ public class JAXBAttachmentMarshaller ex
 
     @Override
     public String addSwaRefAttachment(DataHandler handler) {
-        throw new UnsupportedOperationException();
+        String id = UUID.randomUUID() + "@apache.org";
+        AttachmentImpl att = new AttachmentImpl(id, handler);
+        att.setXOP(false);
+        atts.add(att);
+        return id;
     }
 
     @Override

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=1484513&r1=1484512&r2=1484513&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
Mon May 20 16:21:39 2013
@@ -51,6 +51,7 @@ import org.apache.commons.httpclient.met
 import org.apache.commons.httpclient.methods.multipart.Part;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -390,6 +391,8 @@ public class JAXRSMultipartTest extends 
         bean.setProperties(Collections.singletonMap(org.apache.cxf.message.Message.MTOM_ENABLED,

                                                     (Object)"true"));
         WebClient client = bean.createWebClient();
+        WebClient.getConfig(client).getInInterceptors().add(new LoggingInInterceptor());
+        WebClient.getConfig(client).getOutInterceptors().add(new LoggingOutInterceptor());
         WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",

             "true");
         client.type("multipart/related").accept("multipart/related");
@@ -400,6 +403,7 @@ public class JAXRSMultipartTest extends 
             getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
         byte[] data = IOUtils.readBytesFromStream(is);
         xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
+        xop.setAttachInfoRef(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
         
         String bookXsd = IOUtils.readStringFromStream(getClass().getResourceAsStream(
             "/org/apache/cxf/systest/jaxrs/resources/book.xsd"));
@@ -413,6 +417,8 @@ public class JAXRSMultipartTest extends 
                 "/org/apache/cxf/systest/jaxrs/resources/book.xsd"));
         String bookXsd2 = IOUtils.readStringFromStream(xop2.getAttachinfo().getInputStream());
       
         assertEquals(bookXsdOriginal, bookXsd2);
+        String bookXsdRef = IOUtils.readStringFromStream(xop2.getAttachInfoRef().getInputStream());
       
+        assertEquals(bookXsdOriginal, bookXsdRef);
         
         String ctString = 
             client.getResponse().getMetadata().getFirst("Content-Type").toString();

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=1484513&r1=1484512&r2=1484513&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
Mon May 20 16:21:39 2013
@@ -108,6 +108,10 @@ public class MultipartStore {
         if (!bookXsd.equals(bookXsd2)) {
             throw new RuntimeException("Wrong attachinfo property");
         }
+        String bookXsdRef = IOUtils.readStringFromStream(type.getAttachInfoRef().getInputStream());
+        if (!bookXsdRef.equals(bookXsd2)) {
+            throw new RuntimeException("Wrong attachinforef property");
+        }
         if (!Boolean.getBoolean("java.awt.headless") && type.getImage() == null)
{
             throw new RuntimeException("Wrong image property");
         }
@@ -120,7 +124,7 @@ public class MultipartStore {
             getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
         byte[] data = IOUtils.readBytesFromStream(is);
         xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
-        
+        xop.setAttachInfoRef(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
         xop.setAttachinfo2(bookXsd.getBytes());
      
         xop.setImage(ImageIO.read(getClass().getResource(

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XopType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XopType.java?rev=1484513&r1=1484512&r2=1484513&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XopType.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/XopType.java Mon May
20 16:21:39 2013
@@ -22,6 +22,7 @@ package org.apache.cxf.systest.jaxrs;
 import java.awt.Image;
 
 import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlAttachmentRef;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlMimeType;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -32,11 +33,13 @@ import javax.xml.bind.annotation.XmlType
         "name",
         "attachinfo",
         "attachinfo2",
+        "attachInfoRef",
         "image" })
 public class XopType {
 
     private String name;
     private DataHandler attachinfo;
+    private DataHandler attachInfoRef;
     private byte[] attachinfo2;
     private Image image;
 
@@ -81,4 +84,15 @@ public class XopType {
         return image;
     }
 
+    @XmlAttachmentRef
+    @XmlElement(required = true)
+    @XmlMimeType("application/octet-stream")
+    public DataHandler getAttachInfoRef() {
+        return attachInfoRef;
+    }
+
+    public void setAttachInfoRef(DataHandler attachInfoRef) {
+        this.attachInfoRef = attachInfoRef;
+    }
+
 }



Mime
View raw message