Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 60749 invoked from network); 11 Nov 2010 22:14:33 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Nov 2010 22:14:33 -0000 Received: (qmail 15236 invoked by uid 500); 11 Nov 2010 22:15:04 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 15133 invoked by uid 500); 11 Nov 2010 22:15:04 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 15126 invoked by uid 99); 11 Nov 2010 22:15:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 22:15:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 22:14:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 40DE72388A02; Thu, 11 Nov 2010 22:13:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Thu, 11 Nov 2010 22:13:40 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101111221340.40DE72388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ jettison test + + commons-io + commons-io + 2.0 + test + 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); */ }