You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/11/11 23:13:40 UTC

svn commit: r1034176 - in /cxf/branches/2.3.x-fixes: ./ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/ systests/databinding/ systests/databinding/src/test/java/org/apache/cxf/systest/aegis/mtom/

Author: dkulp
Date: Thu Nov 11 22:13:39 2010
New Revision: 1034176

URL: http://svn.apache.org/viewvc?rev=1034176&view=rev
Log:
Merged revisions 1031124,1031158 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1031124 | bimargulies | 2010-11-04 14:21:42 -0400 (Thu, 04 Nov 2010) | 1 line
  
  CXF-3056: package non-optimized MTOM as streams to match optimized (in Aegis)
........
  r1031158 | bimargulies | 2010-11-04 15:04:58 -0400 (Thu, 04 Nov 2010) | 1 line
  
  Fix 1.5 compile problem.
........

Added:
    cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/StreamDataSource.java
      - copied unchanged from r1031158, cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/StreamDataSource.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
    cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java
    cxf/branches/2.3.x-fixes/systests/databinding/pom.xml
    cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 11 22:13:39 2010
@@ -1 +1 @@
-/cxf/trunk:1031210,1034113,1034165
+/cxf/trunk:1031124-1031158,1031210,1034113,1034165

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java?rev=1034176&r1=1034175&r2=1034176&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java (original)
+++ cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java Thu Nov 11 22:13:39 2010
@@ -18,21 +18,24 @@
  */
 package org.apache.cxf.aegis.type.mtom;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
 
 import javax.activation.DataHandler;
 
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.attachment.AttachmentImpl;
-import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.message.Attachment;
 
+/**
+ * Binding for {@link javax.activation.DataHandler}. This assumes that the DataHandler will always
+ * contain a {@link javax.activation.DataSource}, not data in the Object.
+ */
 public class DataHandlerType extends AbstractXOPType {
-    
+
     public DataHandlerType(boolean useXmimeContentType, String expectedContentTypes) {
         super(useXmimeContentType, expectedContentTypes);
     }
@@ -59,27 +62,9 @@ public class DataHandlerType extends Abs
 
     @Override
     protected Object wrapBytes(byte[] bareBytes, String contentType) {
-        // for the benefit of those who are working with string data, we have the following
-        // trickery
-        String charset = null;
-        if (contentType != null
-            && contentType.indexOf("text/") != -1
-            && contentType.indexOf("charset") != -1) {
-            charset = contentType.substring(contentType.indexOf("charset") + 8);
-            if (charset.indexOf(";") != -1) {
-                charset = charset.substring(0, charset.indexOf(";"));
-            }
-        }
-        String normalizedEncoding = HttpHeaderHelper.mapCharset(charset, "UTF-8");
-        try {
-            String stringData = new String(bareBytes, normalizedEncoding);
-            return new DataHandler(stringData, contentType);
-        } catch (UnsupportedEncodingException e) {
-            // this space intentionally left blank.
-        }
-        return new DataHandler(bareBytes, contentType);
+        return new DataHandler(new StreamDataSource(contentType, new ByteArrayInputStream(bareBytes)));
     }
-    
+
     @Override
     protected byte[] getBytes(Object object) {
         DataHandler handler = (DataHandler) object;

Modified: cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java?rev=1034176&r1=1034175&r2=1034176&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java (original)
+++ cxf/branches/2.3.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java Thu Nov 11 22:13:39 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.aegis.type.mtom;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -30,6 +31,9 @@ import org.apache.cxf.attachment.Attachm
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.message.Attachment;
 
+/**
+ * Binding for {@link javax.activation.DataSource}.
+ */
 public class DataSourceType extends AbstractXOPType {
     public DataSourceType(boolean useXmimeBinaryType, String expectedContentTypes) {
         super(useXmimeBinaryType, expectedContentTypes);
@@ -57,7 +61,7 @@ public class DataSourceType extends Abst
 
     @Override
     protected Object wrapBytes(byte[] bareBytes, String contentType) {
-        return new DataHandler(bareBytes, contentType).getDataSource();
+        return new StreamDataSource(contentType, new ByteArrayInputStream(bareBytes));
     }
 
     @Override

Modified: cxf/branches/2.3.x-fixes/systests/databinding/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/databinding/pom.xml?rev=1034176&r1=1034175&r2=1034176&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/databinding/pom.xml (original)
+++ cxf/branches/2.3.x-fixes/systests/databinding/pom.xml Thu Nov 11 22:13:39 2010
@@ -279,6 +279,12 @@
             <artifactId>jettison</artifactId>
             <scope>test</scope>
         </dependency>
+       	<dependency>
+       		<groupId>commons-io</groupId>
+       		<artifactId>commons-io</artifactId>
+       		<version>2.0</version>
+       	    <scope>test</scope>
+       	</dependency>
 
     </dependencies>
     <properties>

Modified: cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java?rev=1034176&r1=1034175&r2=1034176&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java (original)
+++ cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java Thu Nov 11 22:13:39 2010
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.aegis.mtom;
 
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -51,7 +52,7 @@ import org.springframework.test.context.
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
 /**
- * 
+ *
  */
 @ContextConfiguration(locations = { "classpath:mtomTestBeans.xml" })
 public class MtomTest extends AbstractJUnit4SpringContextTests {
@@ -61,11 +62,11 @@ public class MtomTest extends AbstractJU
     private MtomTestService client;
     private MtomTestService jaxwsClient;
     private TestUtilities testUtilities;
-    
+
     public MtomTest() {
         testUtilities = new TestUtilities(getClass());
     }
-    
+
     private void setupForTest(boolean enableClientMTOM) throws Exception {
         AegisDatabinding aegisBinding = new AegisDatabinding();
         aegisBinding.setMtomEnabled(enableClientMTOM);
@@ -125,7 +126,7 @@ public class MtomTest extends AbstractJU
         Assert.assertEquals("This is the cereal shot from guns.", data);
     }
 
-    @Test 
+    @Test
     public void testAcceptDataHandlerNoMTOM() throws Exception {
         setupForTest(false);
         DataHandlerBean dhBean = new DataHandlerBean();
@@ -137,9 +138,10 @@ public class MtomTest extends AbstractJU
         client.acceptDataHandler(dhBean);
         DataHandlerBean accepted = impl.getLastDhBean();
         Assert.assertNotNull(accepted);
-        Object data = accepted.getDataHandler().getContent();
+        InputStream data = accepted.getDataHandler().getInputStream();
         Assert.assertNotNull(data);
-        Assert.assertEquals("This is the cereal shot from guns.", data);
+        String dataString = org.apache.commons.io.IOUtils.toString(data, "utf-8");
+        Assert.assertEquals("This is the cereal shot from guns.", dataString);
     }
 
     @Test
@@ -148,14 +150,14 @@ public class MtomTest extends AbstractJU
         testUtilities.addDefaultNamespaces();
         testUtilities.addNamespace("xmime", "http://www.w3.org/2005/05/xmlmime");
         Server s = testUtilities.
-            getServerForService(new QName("http://fortest.mtom.aegis.systest.cxf.apache.org/", 
+            getServerForService(new QName("http://fortest.mtom.aegis.systest.cxf.apache.org/",
                                           "MtomTestService"));
-        Document wsdl = testUtilities.getWSDLDocument(s); 
+        Document wsdl = testUtilities.getWSDLDocument(s);
         Assert.assertNotNull(wsdl);
-        NodeList typeAttrList = 
+        NodeList typeAttrList =
             testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/"
                                       + "xsd:element[@name='dataHandler']/"
-                                      + "@type", 
+                                      + "@type",
                                       wsdl);
         Attr typeAttr = (Attr)typeAttrList.item(0);
         String typeAttrValue = typeAttr.getValue();
@@ -165,14 +167,14 @@ public class MtomTest extends AbstractJU
         Node elementNode = typeAttr.getOwnerElement();
         String url = testUtilities.resolveNamespacePrefix(pieces[0], elementNode);
         Assert.assertEquals(SOAPConstants.XSD, url);
-        
+
         s = testUtilities.getServerForAddress("http://localhost:" + PORT + "/mtomXmime");
-        wsdl = testUtilities.getWSDLDocument(s); 
+        wsdl = testUtilities.getWSDLDocument(s);
         Assert.assertNotNull(wsdl);
-        typeAttrList = 
+        typeAttrList =
             testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/"
                                       + "xsd:element[@name='dataHandler']/"
-                                      + "@type", 
+                                      + "@type",
                                       wsdl);
         typeAttr = (Attr)typeAttrList.item(0);
         typeAttrValue = typeAttr.getValue();
@@ -182,11 +184,11 @@ public class MtomTest extends AbstractJU
         elementNode = typeAttr.getOwnerElement();
         url = testUtilities.resolveNamespacePrefix(pieces[0], elementNode);
         Assert.assertEquals(AbstractXOPType.XML_MIME_NS, url);
-        
+
         /* when I add a test for a custom mapping.
         testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/"
                                   + "xsd:element[@name='dataHandler']/"
-                                  + "@xmime:expectedContentType/text()", 
+                                  + "@xmime:expectedContentType/text()",
                                   wsdl);
                                   */
     }