Merged latest changes from trunk.
diff --git a/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java b/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
index 2fb30f1..f4a7aeb 100644
--- a/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
+++ b/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
@@ -31,7 +31,7 @@
 
 public class SOAPImplementationTest extends TestCase {
     public static TestSuite suite() {
-        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMDOMMetaFactory());
+        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMDOMMetaFactory(), false);
         builder.exclude(TestWSCommons202.class);
         builder.exclude(TestGetDefaultFaultEnvelope.class);
         
diff --git a/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java b/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
index 1e465b8..13bdfdb 100644
--- a/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
+++ b/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
@@ -26,7 +26,7 @@
 
 public class SOAPImplementationTest extends TestCase {
     public static TestSuite suite() {
-        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMLinkedListMetaFactory());
+        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMLinkedListMetaFactory(), true);
         return builder.build();
     }
 }
diff --git a/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java b/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
deleted file mode 100644
index 7b723dd..0000000
--- a/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * 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 org.apache.axiom.om.ds.ByteArrayDataSource;
-import org.apache.axiom.om.ds.CharArrayDataSource;
-import org.apache.axiom.om.ds.InputStreamDataSource;
-import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-
-import javax.xml.stream.XMLStreamReader;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-/**
- * Validate the basic functionality of the OMSourcedElement interface,
- * the OMDataSourceExt interface, InputStreamDataSource and ByteArrayDataSource.
- */
-public class OMSourcedElementTest extends AbstractTestCase implements OMConstants {
-    private SOAPFactory soapFactory;
-    private SOAPEnvelope soapEnvelope;
-    private ByteArrayDataSource bads1;
-    private InputStreamDataSource isds1;
-    private CharArrayDataSource cads;
-    private String localName = "myPayload";
-    private OMNamespace ns;
-    
-    private final String ENCODING = "utf-8";
-    
-    private String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
-
-    public OMSourcedElementTest(String testName) {
-        super(testName);
-        soapFactory = OMAbstractFactory.getSOAP11Factory();
-    }
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
-        soapEnvelope = soapFactory.createSOAPEnvelope();
-        soapFactory.createSOAPBody(soapEnvelope);
-        soapFactory.createSOAPHeader(soapEnvelope);
-        
-        bads1 = new ByteArrayDataSource(payload1.getBytes(ENCODING), ENCODING);
-        ByteArrayInputStream bais1 = new ByteArrayInputStream(payload1.getBytes(ENCODING));
-        isds1 = new InputStreamDataSource(bais1, ENCODING);
-        cads = new CharArrayDataSource(payload1.toCharArray());
-        ns = soapFactory.createOMNamespace("urn://test", "tns");
-    }
-
-    /**
-     * Validates creation and insertion of OMSourcedElement
-     * @throws Exception
-     */
-    public void testFactory() throws Exception {
-        SOAPBody soapBody = soapEnvelope.getBody();
-        OMFactory factory = soapBody.getOMFactory();
-        OMSourcedElement omse = factory.createOMElement(bads1, localName, ns);
-        soapBody.addChild(omse);
-        OMNode firstChild = soapBody.getFirstOMChild();
-        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
-    }
-    
-    /**
-     * Tests functionality of ByteArrayDataSource
-     * @throws Exception
-     */
-    public void testByteArrayDS() throws Exception {
-        SOAPBody soapBody = soapEnvelope.getBody();
-        OMFactory factory = soapBody.getOMFactory();
-        OMSourcedElement omse = factory.createOMElement(bads1, localName, ns);
-        soapBody.addChild(omse);
-        OMNode firstChild = soapBody.getFirstOMChild();
-        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
-        OMSourcedElement child = (OMSourcedElement) firstChild;
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
-                   child.getDataSource() instanceof ByteArrayDataSource);
-        
-        // A ByteArrayDataSource does not consume the backing object when read.
-        // Thus getting the XMLStreamReader of the ByteArrayDataSource should not 
-        // cause expansion of the OMSourcedElement.
-        XMLStreamReader reader = child.getXMLStreamReader();
-        reader.next();
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        
-        // Likewise, a ByteArrayDataSource does not consume the backing object when 
-        // written.  Thus serializing the OMSourcedElement should not cause the expansion
-        // of the OMSourcedElement.
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        soapBody.serialize(baos);
-        String output = baos.toString(ENCODING);
-//        System.out.println(output);
-        assertTrue("The payload was not present in the output",
-                   output.indexOf(payload1) > 0);
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        
-        // If a consumer calls build or buildWithAttachments on the tree, the 
-        // tree should not be expanded.
-        soapBody.build();
-        assertTrue("OMSourcedElement is expanded after build().  This is unexpected", !child.isExpanded());
-        soapBody.buildWithAttachments();
-        assertTrue("OMSourcedElement is expanded after buildWithAttachments().  This is unexpected", !child.isExpanded());
-        
-        // Test getting the raw bytes from the ByteArrayDataSource.
-        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
-        byte[] bytes = ds.getXMLBytes("UTF-16");  // Get the bytes as UTF-16 
-        String payload = new String(bytes, "utf-16");
-        assertTrue("The obtained bytes did not match the payload",
-                   payload1.equals(payload));
-        
-       
-        // Test getting the raw bytes with the default encoding
-        OMOutputFormat outputFormat = new OMOutputFormat();
-        baos = new ByteArrayOutputStream();
-        ds.serialize(baos, outputFormat);
-        output = baos.toString(OMOutputFormat.DEFAULT_CHAR_SET_ENCODING);
-//        System.out.println(output);
-        assertTrue("The obtained bytes did not match the payload",
-                   payload1.equals(output));     
-    }
-    
-    /**
-     * Tests functionality of ByteArrayDataSource
-     * @throws Exception
-     */
-    public void testHeader_ByteArrayDS() throws Exception {
-        SOAPHeader soapHeader = soapEnvelope.getHeader();
-        OMFactory factory = soapHeader.getOMFactory();
-        
-        // Set an empty MustUnderstand property on the data source
-        bads1.setProperty(SOAPHeaderBlock.MUST_UNDERSTAND_PROPERTY, null);
-        
-        OMSourcedElement omse = ((SOAPFactory)factory).createSOAPHeaderBlock(localName, ns, bads1);
-        soapHeader.addChild(omse);
-        OMNode firstChild = soapHeader.getFirstOMChild();
-        assertTrue("Expected OMSourcedElement child", firstChild instanceof SOAPHeaderBlock);
-        SOAPHeaderBlock child = (SOAPHeaderBlock) firstChild;
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
-                   child.getDataSource() instanceof ByteArrayDataSource);
-        
-        // Make sure that getting the MustUnderstand property does not cause expansion.
-        assertTrue(!child.getMustUnderstand());
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
-                   child.getDataSource() instanceof ByteArrayDataSource);
-        
-        // A ByteArrayDataSource does not consume the backing object when read.
-        // Thus getting the XMLStreamReader of the ByteArrayDataSource should not 
-        // cause expansion of the OMSourcedElement.
-        XMLStreamReader reader = child.getXMLStreamReader();
-        reader.next();
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        
-        // Likewise, a ByteArrayDataSource does not consume the backing object when 
-        // written.  Thus serializing the OMSourcedElement should not cause the expansion
-        // of the OMSourcedElement.
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        soapHeader.serialize(baos);
-        String output = baos.toString(ENCODING);
-//        System.out.println(output);
-        assertTrue("The payload was not present in the output",
-                   output.indexOf(payload1) > 0);
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        
-        // Test getting the raw bytes from the ByteArrayDataSource.
-        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
-        byte[] bytes = ds.getXMLBytes("UTF-16");  // Get the bytes as UTF-16 
-        String payload = new String(bytes, "utf-16");
-        assertTrue("The obtained bytes did not match the payload",
-                   payload1.equals(payload));
-        
-    }
-    
-    /**
-     * Tests functionality of ByteArrayDataSource
-     * @throws Exception
-     */
-    public void testCharArrayDS() throws Exception {
-        SOAPBody soapBody = soapEnvelope.getBody();
-        OMFactory factory = soapBody.getOMFactory();
-        OMSourcedElement omse = factory.createOMElement(cads, localName, ns);
-        soapBody.addChild(omse);
-        OMNode firstChild = soapBody.getFirstOMChild();
-        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
-        OMSourcedElement child = (OMSourcedElement) firstChild;
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
-                   child.getDataSource() instanceof CharArrayDataSource);
-        
-        // A CharArrayDataSource does not consume the backing object when read.
-        // Thus getting the XMLStreamReader of the CharArrayDataSource should not 
-        // cause expansion of the OMSourcedElement.
-        XMLStreamReader reader = child.getXMLStreamReader();
-        reader.next();
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        
-        // Likewise, a CharArrayDataSource does not consume the backing object when 
-        // written.  Thus serializing the OMSourcedElement should not cause the expansion
-        // of the OMSourcedElement.
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        soapBody.serialize(baos);
-        String output = baos.toString(ENCODING);
-//        System.out.println(output);
-        assertTrue("The payload was not present in the output",
-                   output.indexOf(payload1) > 0);
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        
-        // Test getting the raw bytes from the ByteArrayDataSource.
-        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
-        char[] chars = (char[]) ds.getObject();  // Get the chars
-        String payload = new String(chars);
-        assertTrue("The obtained chars did not match the payload",
-                   payload1.equals(payload));
-        
-        // Validate close
-        ds.close();
-        assertTrue("Close should free the resource", ds.getObject() == null);
-        
-    }
-    
-    /**
-     * Tests functionality of InputStreamDataSource
-     * @throws Exception
-     */
-    public void testInputStreamDS() throws Exception {
-        SOAPBody soapBody = soapEnvelope.getBody();
-        OMFactory factory = soapBody.getOMFactory();
-        OMSourcedElement omse = factory.createOMElement(isds1, localName, ns);
-        soapBody.addChild(omse);
-        OMNode firstChild = soapBody.getFirstOMChild();
-        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
-        OMSourcedElement child = (OMSourcedElement) firstChild;
-        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
-        assertTrue("OMSourcedElement should be backed by a InputStreamDataSource",
-                   child.getDataSource() instanceof InputStreamDataSource);
-        
-        // A InputStreamDataSource consumes the backing object when read.
-        // Thus getting the XMLStreamReader of the ByteArrayDataSource should  
-        // cause expansion of the OMSourcedElement.
-        XMLStreamReader reader = child.getXMLStreamReader();
-        reader.next();
-        assertTrue("OMSourcedElement is not expanded.  This is unexpected", 
-                   child.isExpanded());
-        
-        child.detach();
-        
-        // Reset the tree
-        isds1 = new InputStreamDataSource(
-            new ByteArrayInputStream(payload1.getBytes(ENCODING)), 
-            ENCODING);
-        omse = factory.createOMElement(isds1, localName, ns);
-        soapBody.addChild(omse);
-        firstChild = soapBody.getFirstOMChild();
-        child = (OMSourcedElement) firstChild;
-        
-        // Likewise, an InputStreamDataSource consumes the backing object when 
-        // written.  Thus serializing the OMSourcedElement should cause the expansion
-        // of the OMSourcedElement.
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        soapBody.serialize(baos);
-        String output = baos.toString(ENCODING);
-        assertTrue("The payload was not present in the output",
-                   output.indexOf(payload1) > 0);
-        assertTrue("OMSourcedElement is not expanded.  This is unexpected", child.isExpanded());
-        
-        // Reset the tree
-        child.detach();
-        isds1 = new InputStreamDataSource(
-            new ByteArrayInputStream(payload1.getBytes(ENCODING)), 
-            ENCODING);
-        omse = factory.createOMElement(isds1, localName, ns);
-        soapBody.addChild(omse);
-        firstChild = soapBody.getFirstOMChild();
-        child = (OMSourcedElement) firstChild;
-        
-        // Test getting the raw bytes from the ByteArrayDataSource.
-        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
-        byte[] bytes = ds.getXMLBytes(ENCODING);  // Get the bytes as UTF-16 
-        String payload = new String(bytes, ENCODING);
-        assertTrue("The obtained bytes did not match the payload",
-                   payload1.equals(payload));
-        
-    }
-}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
index 473eb7d..9dc91ac 100644
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
@@ -340,11 +340,14 @@
                     addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceURI(metaFactory, variant, qname));
                 }
             }
+            addTest(new org.apache.axiom.ts.om.sourcedelement.TestByteArrayDS(metaFactory));
+            addTest(new org.apache.axiom.ts.om.sourcedelement.TestCharArrayDS(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestComplete(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestExpand(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceNormalized(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceNormalized2(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetTextAsStreamWithNonDestructiveOMDataSource(metaFactory));
+            addTest(new org.apache.axiom.ts.om.sourcedelement.TestInputStreamDS(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestName1DefaultPrefix(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestName1QualifiedPrefix(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestName1Unqualified(metaFactory));
@@ -372,6 +375,7 @@
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSetDataSourceOnAlreadyExpandedElement(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSetLocalName(metaFactory, false));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSetLocalName(metaFactory, true));
+            addTest(new org.apache.axiom.ts.om.sourcedelement.TestWrappedTextNodeOMDataSourceFromReader(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestWriteTextToWithNonDestructiveOMDataSource(metaFactory));
         }
         addTest(new org.apache.axiom.ts.om.pi.TestDigest(metaFactory));
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestByteArrayDS.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestByteArrayDS.java
new file mode 100644
index 0000000..ecdc11f
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestByteArrayDS.java
@@ -0,0 +1,105 @@
+/*
+ * 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.ts.om.sourcedelement;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.ByteArrayDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests functionality of ByteArrayDataSource
+ */
+public class TestByteArrayDS extends AxiomTestCase {
+    public TestByteArrayDS(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        
+        String localName = "myPayload";
+        String encoding = "utf-8";
+        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
+        OMNamespace ns = factory.createOMNamespace("urn://test", "tns");
+        ByteArrayDataSource bads1 = new ByteArrayDataSource(payload1.getBytes(encoding), encoding);
+
+        OMElement parent = factory.createOMElement("root", null);
+        OMSourcedElement omse = factory.createOMElement(bads1, localName, ns);
+        parent.addChild(omse);
+        OMNode firstChild = parent.getFirstOMChild();
+        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
+        OMSourcedElement child = (OMSourcedElement) firstChild;
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
+                   child.getDataSource() instanceof ByteArrayDataSource);
+        
+        // A ByteArrayDataSource does not consume the backing object when read.
+        // Thus getting the XMLStreamReader of the ByteArrayDataSource should not 
+        // cause expansion of the OMSourcedElement.
+        XMLStreamReader reader = child.getXMLStreamReader();
+        reader.next();
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        
+        // Likewise, a ByteArrayDataSource does not consume the backing object when 
+        // written.  Thus serializing the OMSourcedElement should not cause the expansion
+        // of the OMSourcedElement.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        parent.serialize(baos);
+        String output = baos.toString(encoding);
+//        System.out.println(output);
+        assertTrue("The payload was not present in the output",
+                   output.indexOf(payload1) > 0);
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        
+        // If a consumer calls build or buildWithAttachments on the tree, the 
+        // tree should not be expanded.
+        parent.build();
+        assertTrue("OMSourcedElement is expanded after build().  This is unexpected", !child.isExpanded());
+        parent.buildWithAttachments();
+        assertTrue("OMSourcedElement is expanded after buildWithAttachments().  This is unexpected", !child.isExpanded());
+        
+        // Test getting the raw bytes from the ByteArrayDataSource.
+        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
+        byte[] bytes = ds.getXMLBytes("UTF-16");  // Get the bytes as UTF-16 
+        String payload = new String(bytes, "utf-16");
+        assertTrue("The obtained bytes did not match the payload",
+                   payload1.equals(payload));
+        
+       
+        // Test getting the raw bytes with the default encoding
+        OMOutputFormat outputFormat = new OMOutputFormat();
+        baos = new ByteArrayOutputStream();
+        ds.serialize(baos, outputFormat);
+        output = baos.toString(OMOutputFormat.DEFAULT_CHAR_SET_ENCODING);
+//        System.out.println(output);
+        assertTrue("The obtained bytes did not match the payload",
+                   payload1.equals(output));     
+    }
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCharArrayDS.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCharArrayDS.java
new file mode 100644
index 0000000..76bffbd
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestCharArrayDS.java
@@ -0,0 +1,91 @@
+/*
+ * 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.ts.om.sourcedelement;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.CharArrayDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests functionality of ByteArrayDataSource
+ */
+public class TestCharArrayDS extends AxiomTestCase {
+    public TestCharArrayDS(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        
+        String localName = "myPayload";
+        String encoding = "utf-8";
+        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
+        OMNamespace ns = factory.createOMNamespace("urn://test", "tns");
+        CharArrayDataSource cads = new CharArrayDataSource(payload1.toCharArray());
+
+        OMElement parent = factory.createOMElement("root", null);
+        OMSourcedElement omse = factory.createOMElement(cads, localName, ns);
+        parent.addChild(omse);
+        OMNode firstChild = parent.getFirstOMChild();
+        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
+        OMSourcedElement child = (OMSourcedElement) firstChild;
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
+                   child.getDataSource() instanceof CharArrayDataSource);
+        
+        // A CharArrayDataSource does not consume the backing object when read.
+        // Thus getting the XMLStreamReader of the CharArrayDataSource should not 
+        // cause expansion of the OMSourcedElement.
+        XMLStreamReader reader = child.getXMLStreamReader();
+        reader.next();
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        
+        // Likewise, a CharArrayDataSource does not consume the backing object when 
+        // written.  Thus serializing the OMSourcedElement should not cause the expansion
+        // of the OMSourcedElement.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        parent.serialize(baos);
+        String output = baos.toString(encoding);
+//        System.out.println(output);
+        assertTrue("The payload was not present in the output",
+                   output.indexOf(payload1) > 0);
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        
+        // Test getting the raw bytes from the ByteArrayDataSource.
+        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
+        char[] chars = (char[]) ds.getObject();  // Get the chars
+        String payload = new String(chars);
+        assertTrue("The obtained chars did not match the payload",
+                   payload1.equals(payload));
+        
+        // Validate close
+        ds.close();
+        assertTrue("Close should free the resource", ds.getObject() == null);
+    }
+}
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestInputStreamDS.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestInputStreamDS.java
new file mode 100644
index 0000000..7baf94d
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestInputStreamDS.java
@@ -0,0 +1,110 @@
+/*
+ * 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.ts.om.sourcedelement;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.InputStreamDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests functionality of InputStreamDataSource
+ */
+public class TestInputStreamDS extends AxiomTestCase {
+    public TestInputStreamDS(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        
+        String localName = "myPayload";
+        String encoding = "utf-8";
+        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
+        OMNamespace ns = factory.createOMNamespace("urn://test", "tns");
+        ByteArrayInputStream bais1 = new ByteArrayInputStream(payload1.getBytes(encoding));
+        InputStreamDataSource isds1 = new InputStreamDataSource(bais1, encoding);
+        
+        OMElement parent = factory.createOMElement("root", null);
+        OMSourcedElement omse = factory.createOMElement(isds1, localName, ns);
+        parent.addChild(omse);
+        OMNode firstChild = parent.getFirstOMChild();
+        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
+        OMSourcedElement child = (OMSourcedElement) firstChild;
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        assertTrue("OMSourcedElement should be backed by a InputStreamDataSource",
+                   child.getDataSource() instanceof InputStreamDataSource);
+        
+        // A InputStreamDataSource consumes the backing object when read.
+        // Thus getting the XMLStreamReader of the ByteArrayDataSource should  
+        // cause expansion of the OMSourcedElement.
+        XMLStreamReader reader = child.getXMLStreamReader();
+        reader.next();
+        assertTrue("OMSourcedElement is not expanded.  This is unexpected", 
+                   child.isExpanded());
+        
+        child.detach();
+        
+        // Reset the tree
+        isds1 = new InputStreamDataSource(
+            new ByteArrayInputStream(payload1.getBytes(encoding)), 
+            encoding);
+        omse = factory.createOMElement(isds1, localName, ns);
+        parent.addChild(omse);
+        firstChild = parent.getFirstOMChild();
+        child = (OMSourcedElement) firstChild;
+        
+        // Likewise, an InputStreamDataSource consumes the backing object when 
+        // written.  Thus serializing the OMSourcedElement should cause the expansion
+        // of the OMSourcedElement.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        parent.serialize(baos);
+        String output = baos.toString(encoding);
+        assertTrue("The payload was not present in the output",
+                   output.indexOf(payload1) > 0);
+        assertTrue("OMSourcedElement is not expanded.  This is unexpected", child.isExpanded());
+        
+        // Reset the tree
+        child.detach();
+        isds1 = new InputStreamDataSource(
+            new ByteArrayInputStream(payload1.getBytes(encoding)), 
+            encoding);
+        omse = factory.createOMElement(isds1, localName, ns);
+        parent.addChild(omse);
+        firstChild = parent.getFirstOMChild();
+        child = (OMSourcedElement) firstChild;
+        
+        // Test getting the raw bytes from the ByteArrayDataSource.
+        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
+        byte[] bytes = ds.getXMLBytes(encoding);  // Get the bytes as UTF-16 
+        String payload = new String(bytes, encoding);
+        assertTrue("The obtained bytes did not match the payload",
+                   payload1.equals(payload));
+    }
+}
diff --git a/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceTest.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestWrappedTextNodeOMDataSourceFromReader.java
similarity index 78%
rename from modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceTest.java
rename to modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestWrappedTextNodeOMDataSourceFromReader.java
index 8f62caf..2660761 100644
--- a/modules/axiom-tests/src/test/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceTest.java
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestWrappedTextNodeOMDataSourceFromReader.java
@@ -17,23 +17,26 @@
  * under the License.
  */
 
-package org.apache.axiom.om.ds;
+package org.apache.axiom.ts.om.sourcedelement;
 
 import java.io.StringReader;
 import java.util.Random;
 
 import javax.xml.namespace.QName;
 
-import junit.framework.TestCase;
-
-import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader;
+import org.apache.axiom.ts.AxiomTestCase;
 
-public class WrappedTextNodeOMDataSourceTest extends TestCase {
-    public void testFromReader() throws Exception {
+public class TestWrappedTextNodeOMDataSourceFromReader extends AxiomTestCase {
+    public TestWrappedTextNodeOMDataSourceFromReader(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
         Random random = new Random();
         StringBuilder buffer = new StringBuilder(40000);
         for (int i=0; i<40000; i++) {
@@ -42,7 +45,7 @@
         String testData = buffer.toString();
         QName qname = new QName("data");
         OMDataSource ds = new WrappedTextNodeOMDataSourceFromReader(qname, new StringReader(testData));
-        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMFactory factory = metaFactory.getOMFactory();
         OMSourcedElement element = factory.createOMElement(ds, qname);
         assertEquals(testData, element.getText());
     }
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
index 0fe8e16..1d19635 100644
--- a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
@@ -31,9 +31,11 @@
         TestConstants.EMPTY_BODY_MESSAGE };
     
     private final OMMetaFactory metaFactory;
+    private final boolean supportsOMSourcedElement;
     
-    public SOAPTestSuiteBuilder(OMMetaFactory metaFactory) {
+    public SOAPTestSuiteBuilder(OMMetaFactory metaFactory, boolean supportsOMSourcedElement) {
         this.metaFactory = metaFactory;
+        this.supportsOMSourcedElement = supportsOMSourcedElement;
     }
     
     private void addTests(SOAPSpec spec) {
@@ -94,6 +96,9 @@
         addTest(new org.apache.axiom.ts.soap.header.TestExtractAllHeaderBlocks(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestGetHeaderBlocksWithNSURI(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestGetHeadersToProcessWithNamespace(metaFactory, spec));
+        if (supportsOMSourcedElement) {
+            addTest(new org.apache.axiom.ts.soap.headerblock.TestByteArrayDS(metaFactory, spec));
+        }
         addTest(new org.apache.axiom.ts.soap.headerblock.TestGetMustUnderstand(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.headerblock.TestGetRole(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.headerblock.TestGetVersion(metaFactory, spec));
diff --git a/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestByteArrayDS.java b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestByteArrayDS.java
new file mode 100644
index 0000000..3fa69e3
--- /dev/null
+++ b/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestByteArrayDS.java
@@ -0,0 +1,97 @@
+/*
+ * 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.ts.soap.headerblock;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.ByteArrayDataSource;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests functionality of ByteArrayDataSource
+ */
+public class TestByteArrayDS extends SOAPTestCase {
+    public TestByteArrayDS(OMMetaFactory metaFactory, SOAPSpec spec) {
+        super(metaFactory, spec);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
+        SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
+        String localName = "myPayload";
+        String encoding = "utf-8";
+        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
+        OMNamespace ns = soapFactory.createOMNamespace("urn://test", "tns");
+        ByteArrayDataSource bads1 = new ByteArrayDataSource(payload1.getBytes(encoding), encoding);
+        
+        // Set an empty MustUnderstand property on the data source
+        bads1.setProperty(SOAPHeaderBlock.MUST_UNDERSTAND_PROPERTY, null);
+        
+        OMSourcedElement omse = soapFactory.createSOAPHeaderBlock(localName, ns, bads1);
+        soapHeader.addChild(omse);
+        OMNode firstChild = soapHeader.getFirstOMChild();
+        assertTrue("Expected OMSourcedElement child", firstChild instanceof SOAPHeaderBlock);
+        SOAPHeaderBlock child = (SOAPHeaderBlock) firstChild;
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
+                   child.getDataSource() instanceof ByteArrayDataSource);
+        
+        // Make sure that getting the MustUnderstand property does not cause expansion.
+        assertTrue(!child.getMustUnderstand());
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
+                   child.getDataSource() instanceof ByteArrayDataSource);
+        
+        // A ByteArrayDataSource does not consume the backing object when read.
+        // Thus getting the XMLStreamReader of the ByteArrayDataSource should not 
+        // cause expansion of the OMSourcedElement.
+        XMLStreamReader reader = child.getXMLStreamReader();
+        reader.next();
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        
+        // Likewise, a ByteArrayDataSource does not consume the backing object when 
+        // written.  Thus serializing the OMSourcedElement should not cause the expansion
+        // of the OMSourcedElement.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        soapHeader.serialize(baos);
+        String output = baos.toString(encoding);
+//        System.out.println(output);
+        assertTrue("The payload was not present in the output",
+                   output.indexOf(payload1) > 0);
+        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
+        
+        // Test getting the raw bytes from the ByteArrayDataSource.
+        OMDataSourceExt ds = (OMDataSourceExt) child.getDataSource();
+        byte[] bytes = ds.getXMLBytes("UTF-16");  // Get the bytes as UTF-16 
+        String payload = new String(bytes, "utf-16");
+        assertTrue("The obtained bytes did not match the payload",
+                   payload1.equals(payload));
+    }
+}