Author: scheu
Date: Fri Apr 25 06:16:24 2008
New Revision: 651600
URL: http://svn.apache.org/viewvc?rev=651600&view=rev
Log:
WSCOMMONS-324
Contributor:Rich Scheuerle
Summary of Changes:
- Changed StreamingOMSerializer to recognize readers that have access to
attachments and writers that accept attachments.
Using this information, the StreamingOMSerializer either inlines or
optimizes xop:include statements.
- Added the OMAttachmentAccessor interface. The interface has one method,
getDataHandler(cid). This interface is added
to the OM objects that allow access to attachment data.
- Added setContentID to OMText. This was necessary to preserve the cid for
streaming optimized mtom cases.
- Changed the MTOMStAXSOAPModelBuilderTest to validate streaming with
optimized MTOM attachments and streaming
with inlined MTOM attachments.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttachmentAccessor.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPEnvelopeBuildTest.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
Fri Apr 25 06:16:24 2008
@@ -22,6 +22,7 @@
import org.apache.axiom.attachments.impl.PartFactory;
import org.apache.axiom.attachments.lifecycle.LifecycleManager;
import org.apache.axiom.attachments.lifecycle.impl.LifecycleManagerImpl;
+import org.apache.axiom.om.OMAttachmentAccessor;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.om.util.DetachableInputStream;
@@ -30,7 +31,6 @@
import org.apache.commons.logging.LogFactory;
import javax.activation.DataHandler;
-import javax.activation.DataSource;
import javax.mail.MessagingException;
import javax.mail.internet.ContentType;
import javax.mail.internet.ParseException;
@@ -43,7 +43,7 @@
import java.util.Set;
import java.util.TreeMap;
-public class Attachments {
+public class Attachments implements OMAttachmentAccessor {
/** <code>ContentType</code> of the MIME message */
ContentType contentType;
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttachmentAccessor.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttachmentAccessor.java?rev=651600&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttachmentAccessor.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttachmentAccessor.java
Fri Apr 25 06:16:24 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om;
+
+import javax.activation.DataHandler;
+
+/**
+ * This interface is applied to objects that
+ * can access attachments.
+ */
+public interface OMAttachmentAccessor {
+
+ /**
+ * @param blobContentID (without the surrounding angle brackets and "cid:"
prefix)
+ * @return The DataHandler of the mime part referred by the Content-Id or
*null* if the mime
+ * part referred by the content-id does not exist
+ */
+ public DataHandler getDataHandler(String blobcid);
+}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
Fri Apr 25 06:16:24 2008
@@ -83,5 +83,11 @@
* @return Returns String.
*/
String getContentID();
+
+ /**
+ * Set a specific content id
+ * @param cid
+ */
+ void setContentID(String cid);
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPAwareStAXOMBuilder.java
Fri Apr 25 06:16:24 2008
@@ -36,7 +36,8 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
-public class XOPAwareStAXOMBuilder extends StAXOMBuilder implements XOPBuilder
{
+public class XOPAwareStAXOMBuilder
+ extends StAXOMBuilder implements XOPBuilder {
/** <code>Attachments</code> handles deferred parsing of incoming MIME
Messages. */
Attachments attachments;
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPBuilder.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/XOPBuilder.java
Fri Apr 25 06:16:24 2008
@@ -19,11 +19,12 @@
package org.apache.axiom.om.impl.builder;
+import org.apache.axiom.om.OMAttachmentAccessor;
import org.apache.axiom.om.OMException;
import javax.activation.DataHandler;
-public interface XOPBuilder {
+public interface XOPBuilder extends OMAttachmentAccessor {
DataHandler getDataHandler(String blobContentID)
throws OMException;
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
Fri Apr 25 06:16:24 2008
@@ -19,18 +19,30 @@
package org.apache.axiom.om.impl.serialize;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttachmentAccessor;
+import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMSerializer;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
import org.apache.axiom.om.impl.util.OMSerializerUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import javax.activation.DataHandler;
import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+
import java.util.ArrayList;
/** Class StreamingOMSerializer */
public class StreamingOMSerializer implements XMLStreamConstants, OMSerializer
{
+
+ Log log = LogFactory.getLog(StreamingOMSerializer.class);
private static int namespaceSuffix = 0;
public static final String NAMESPACE_PREFIX = "ns";
@@ -44,6 +56,12 @@
/** Field depth */
private int depth = 0;
+
+ public static final QName XOP_INCLUDE =
+ new QName("http://www.w3.org/2004/08/xop/include", "Include");
+
+ private boolean inputHasAttachments = false;
+ private boolean skipEndElement = false;
/**
* Method serialize.
@@ -65,6 +83,12 @@
*/
public void serialize(XMLStreamReader node, XMLStreamWriter writer,
boolean startAtNext)
throws XMLStreamException {
+
+ // Set attachment status
+ if (node instanceof OMAttachmentAccessor) {
+ inputHasAttachments = true;
+ }
+
serializeNode(node, writer, startAtNext);
}
@@ -138,6 +162,7 @@
protected void serializeElement(XMLStreamReader reader,
XMLStreamWriter writer)
throws XMLStreamException {
+
// Note: To serialize the start tag, we must follow the order dictated
by the JSR-173 (StAX) specification.
// Please keep this code in sync with the code in
OMSerializerUtil.serializeStartpart
@@ -163,6 +188,20 @@
ePrefix = (ePrefix != null && ePrefix.length() == 0) ? null : ePrefix;
String eNamespace = reader.getNamespaceURI();
eNamespace = (eNamespace != null && eNamespace.length() == 0) ? null :
eNamespace;
+
+ if (this.inputHasAttachments &&
+ XOP_INCLUDE.getNamespaceURI().equals(eNamespace)) {
+ String eLocalPart = reader.getLocalName();
+ if (XOP_INCLUDE.getLocalPart().equals(eLocalPart)) {
+ if (serializeXOPInclude(reader, writer)) {
+ // Since the xop:include is replaced with inlined text,
+ // skip the rest of serialize element and skip the end
event for
+ // of the xop:include
+ skipEndElement = true;
+ return;
+ }
+ }
+ }
// Write the startElement if required
boolean setPrefixFirst =
OMSerializerUtil.isSetPrefixBeforeStartElement(writer);
@@ -355,6 +394,10 @@
*/
protected void serializeEndElement(XMLStreamWriter writer)
throws XMLStreamException {
+ if (this.skipEndElement) {
+ skipEndElement = false;
+ return;
+ }
writer.writeEndElement();
}
@@ -492,5 +535,91 @@
writer.writeNamespace(prefix, URI);
writer.setPrefix(prefix, URI);
}
+ }
+
+ /**
+ * Inspect the current element and if it is an
+ * XOP Include then write it out as inlined or optimized.
+ * @param reader
+ * @param writer
+ * @return true if inlined
+ */
+ protected boolean serializeXOPInclude(XMLStreamReader reader,
+ XMLStreamWriter writer) {
+ String cid = reader.getAttributeValue(null, "href");
+ DataHandler dh = getDataHandler(cid, (OMAttachmentAccessor) reader);
+ if (dh == null) {
+ return false;
+ }
+
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMText omText = omFactory.createOMText(dh, true);
+ omText.setContentID(cid);
+
+
+ MTOMXMLStreamWriter mtomWriter =
+ (writer instanceof MTOMXMLStreamWriter) ?
+ (MTOMXMLStreamWriter) writer :
+ null;
+
+ if (mtomWriter != null &&
+ mtomWriter.isOptimized() &&
+ mtomWriter.isOptimizedThreshold(omText)) {
+ // This will write the attachment after the xml message
+ mtomWriter.writeOptimized(omText);
+ return false;
+ }
+
+ // This will inline the attachment
+ omText.setOptimize(false);
+ try {
+ writer.writeCharacters(omText.getText());
+ return true;
+ } catch (XMLStreamException e) {
+ // Just writer out the xop:include
+ return false;
+ }
+
+ }
+
+ private DataHandler getDataHandler(String cid, OMAttachmentAccessor oaa) {
+ DataHandler dh = null;
+
+ String blobcid = cid;
+ if (blobcid.startsWith("cid:")) {
+ blobcid = blobcid.substring(4);
+ }
+ // Get the attachment
+ if (oaa != null) {
+ dh = oaa.getDataHandler(blobcid);
+ }
+
+ if (dh == null) {
+ blobcid = getNewCID(cid);
+ if (blobcid.startsWith("cid:")) {
+ blobcid = blobcid.substring(4);
+ }
+ if (oaa != null) {
+ dh = oaa.getDataHandler(blobcid);
+ }
+ }
+ return dh;
+ }
+
+ /**
+ * @param cid
+ * @return cid with translated characters
+ */
+ private String getNewCID(String cid) {
+ String cid2 = cid;
+
+ try {
+ cid2 = java.net.URLDecoder.decode(cid, "UTF-8");
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("getNewCID decoding " + cid + " as UTF-8 decoding
error: " + e);
+ }
+ }
+ return cid2;
}
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
Fri Apr 25 06:16:24 2008
@@ -628,4 +628,8 @@
public OMNamespace getNamespace() {
return textNS;
}
+
+ public void setContentID(String cid) {
+ this.contentID = cid;
+ }
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
Fri Apr 25 06:16:24 2008
@@ -25,6 +25,7 @@
import java.util.Map;
import java.util.Stack;
+import javax.activation.DataHandler;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
@@ -32,6 +33,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import org.apache.axiom.om.OMAttachmentAccessor;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMComment;
import org.apache.axiom.om.OMConstants;
@@ -54,7 +56,8 @@
* Note - This class also implements the streaming constants interface to get
access to the StAX
* constants
*/
-public class OMStAXWrapper implements XMLStreamReader, XMLStreamConstants {
+public class OMStAXWrapper
+ implements XMLStreamReader, XMLStreamConstants, OMAttachmentAccessor {
private static final Log log = LogFactory.getLog(OMStAXWrapper.class);
private static boolean DEBUG_ENABLED = log.isDebugEnabled();
@@ -1464,5 +1467,14 @@
_releaseParserOnClose = value;
}
+ }
+
+ public DataHandler getDataHandler(String blobcid) {
+ DataHandler dh = null;
+ if (builder != null &&
+ builder instanceof OMAttachmentAccessor) {
+ dh = ((OMAttachmentAccessor) builder).getDataHandler(blobcid);
+ }
+ return dh;
}
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
Fri Apr 25 06:16:24 2008
@@ -538,5 +538,9 @@
this.getDataHandler();
}
}
+
+ public void setContentID(String cid) {
+ this.contentID = cid;
+ }
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
Fri Apr 25 06:16:24 2008
@@ -22,6 +22,7 @@
import org.apache.axiom.attachments.Attachments;
import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.soap.SOAP12Constants;
@@ -30,16 +31,16 @@
import javax.activation.DataHandler;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
+
+import java.io.BufferedInputStream;
import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.BufferedInputStream;
-import java.util.Iterator;
-import java.util.Arrays;
-import java.lang.reflect.Array;
import java.net.URLEncoder;
+import java.util.Iterator;
public class MTOMStAXSOAPModelBuilderTest extends AbstractTestCase {
@@ -87,6 +88,53 @@
// object.read(actualObject,0,10);
// assertEquals("Object check", expectedObject[5],actualObject[5] );
+ }
+
+ public void testCreateAndSerializeOptimized() throws Exception {
+ String contentTypeString =
+ "multipart/Related; charset=\"UTF-8\";
type=\"application/xop+xml\"; boundary=\"----=_AxIs2_Def_boundary_=42214532\";
start=\"SOAPPart\"";
+ String inFileName = "mtom/MTOMBuilderTestIn.txt";
+ InputStream inStream = new
FileInputStream(getTestResourceFile(inFileName));
+ Attachments attachments = new Attachments(inStream, contentTypeString);
+ XMLStreamReader reader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new BufferedReader(new
InputStreamReader(attachments
+ .getSOAPPartInputStream())));
+ OMXMLParserWrapper builder = new MTOMStAXSOAPModelBuilder(reader,
attachments,
+
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ OMElement root = builder.getDocumentElement();
+
+ OMOutputFormat format = new OMOutputFormat();
+ format.setDoOptimize(true);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ root.serializeAndConsume(baos, format);
+ String msg = baos.toString();
+ // Make sure there is an xop:Include element and an optimized
attachment
+ assertTrue(msg.indexOf("xop:Include") > 0);
+ assertTrue(msg.indexOf("Content-ID: <cid:-1609420109260943731>") > 0);
+ }
+
+ public void testCreateAndSerializeInlined() throws Exception {
+ String contentTypeString =
+ "multipart/Related; charset=\"UTF-8\";
type=\"application/xop+xml\"; boundary=\"----=_AxIs2_Def_boundary_=42214532\";
start=\"SOAPPart\"";
+ String inFileName = "mtom/MTOMBuilderTestIn.txt";
+ InputStream inStream = new
FileInputStream(getTestResourceFile(inFileName));
+ Attachments attachments = new Attachments(inStream, contentTypeString);
+ XMLStreamReader reader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new BufferedReader(new
InputStreamReader(attachments
+ .getSOAPPartInputStream())));
+ OMXMLParserWrapper builder = new MTOMStAXSOAPModelBuilder(reader,
attachments,
+
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ OMElement root = builder.getDocumentElement();
+
+ OMOutputFormat format = new OMOutputFormat();
+ format.setDoOptimize(false);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ root.serializeAndConsume(baos, format);
+ String msg = baos.toString();
+ // Make sure there is not an xop:Include
+ // Make sure there is not an optimized attachment
+ assertTrue(msg.indexOf("xop:Include") < 0);
+ assertTrue(msg.indexOf("Content-ID: <cid:-1609420109260943731>") < 0);
}
public void testUTF16MTOMMessage() throws Exception {
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPEnvelopeBuildTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPEnvelopeBuildTest.java?rev=651600&r1=651599&r2=651600&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPEnvelopeBuildTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/soap/SOAPEnvelopeBuildTest.java
Fri Apr 25 06:16:24 2008
@@ -148,8 +148,6 @@
MyDebugLogger log = new MyDebugLogger();
long length = CommonUtils.logDebug(se, log);
assertTrue(length > 100);
- System.out.println(log.output);
- System.out.println(length);
assertTrue(log.output.contains("x:Content"));
}