You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2013/01/01 11:18:23 UTC

svn commit: r1427339 [2/2] - in /webservices/axiom/branches/AXIOM-201: ./ code-coverage/ modules/axiom-api/src/main/java/org/apache/axiom/locator/ modules/axiom-api/src/main/java/org/apache/axiom/om/ modules/axiom-api/src/main/java/org/apache/axiom/om/...

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestDataSource.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestDataSource.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestDataSource.java Tue Jan  1 10:18:22 2013
@@ -1,97 +1,56 @@
 /*
- * Copyright 2009-2011 Andreas Veithen
+ * 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
  *
- * Licensed 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
  *
- *     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.
+ * 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.IOException;
-import java.io.OutputStream;
 import java.io.StringReader;
-import java.io.Writer;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.axiom.om.OMDataSource;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
+import org.apache.axiom.om.ds.AbstractPullOMDataSource;
 import org.apache.axiom.om.util.StAXUtils;
 
-class TestDataSource implements OMDataSource {
-    // The data source is a ByteArrayInputStream so that we can verify that the datasource 
-    // is only accessed once.  Currently there is no way to identify a destructive vs. non-destructive OMDataSource.
-    private final ByteArrayInputStream data;
+class TestDataSource extends AbstractPullOMDataSource {
+    private final String data;
+    private final boolean destructive;
+    private boolean destroyed;
 
     TestDataSource(String data) {
-        this.data = new ByteArrayInputStream(data.getBytes());
-        this.data.mark(0);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.axiom.om.OMDataSource#serialize(java.io.OutputStream, org.apache.axiom.om.OMOutputFormat)
-     */
-    public void serialize(OutputStream output, OMOutputFormat format)
-            throws XMLStreamException {
-        try {
-            output.write(getBytes());
-        } catch (IOException e) {
-            throw new XMLStreamException(e);
-        }
+        this(data, true);
     }
-
-    /* (non-Javadoc)
-     * @see org.apache.axiom.om.OMDataSource#serialize(java.io.Writer, org.apache.axiom.om.OMOutputFormat)
-     */
-    public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
-        try {
-            writer.write(getString());
-        } catch (IOException e) {
-            throw new XMLStreamException(e);
-        }
+    
+    TestDataSource(String data, boolean destructive) {
+        this.data = data;
+        this.destructive = destructive;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.axiom.om.OMDataSource#serialize(javax.xml.stream.XMLStreamWriter)
-     */
-    public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
-        StreamingOMSerializer serializer = new StreamingOMSerializer();
-        serializer.serialize(getReader(), xmlWriter);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.axiom.om.OMDataSource#getReader()
-     */
     public XMLStreamReader getReader() throws XMLStreamException {
-        return StAXUtils.createXMLStreamReader(new StringReader(getString()));
-    }
-
-    private byte[] getBytes() throws XMLStreamException {
-        try {
-            // The data from the data source should only be accessed once
-            //data.reset();
-            byte[] rc = new byte[data.available()];
-            data.read(rc);
-            return rc;
-        } catch (IOException io) {
-            throw new XMLStreamException(io);
+        if (destroyed) {
+            throw new IllegalStateException("The OMDataSource has already been consumed");
+        }
+        if (destructive) {
+            destroyed = true;
         }
+        return StAXUtils.createXMLStreamReader(new StringReader(data));
     }
 
-    private String getString() throws XMLStreamException {
-        String text = new String(getBytes());
-        return text;
+    public boolean isDestructiveRead() {
+        return destructive;
     }
 }
\ No newline at end of file

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestExpand.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestExpand.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestExpand.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestExpand.java Tue Jan  1 10:18:22 2013
@@ -25,16 +25,19 @@ import javax.xml.namespace.QName;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Make sure the expanded OMSourcedElement behaves like a normal OMElement.
  */
-public class TestExpand extends OMSourcedElementTest {
+public class TestExpand extends AxiomTestCase {
     public TestExpand(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         element.getAllDeclaredNamespaces();
         assertEquals("Expanded namespace count error", 1,
                      countItems(element.getAllDeclaredNamespaces()));

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument (which uses the default namespace) Type of
  * Serialization: Serialize and cache Prefix test
  */
-public class TestName1DefaultPrefix extends OMSourcedElementTest {
+public class TestName1DefaultPrefix extends AxiomTestCase {
     public TestName1DefaultPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -46,7 +47,7 @@ public class TestName1DefaultPrefix exte
         OMNamespace ns =
                 f.createOMNamespace("http://www.sosnoski.com/uwjws/library", null);
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument), "library", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT1.getContent()), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument2 (which uses a qualified prefix) Type of Serialization:
  * Serialize and cache Prefix test
  */
-public class TestName1QualifiedPrefix extends OMSourcedElementTest {
+public class TestName1QualifiedPrefix extends AxiomTestCase {
     public TestName1QualifiedPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName1QualifiedPrefix ex
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", null);
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument2), "library", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT2.getContent()), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1Unqualified.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1Unqualified.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1Unqualified.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1Unqualified.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument3 (which uses unqualified names) Type of Serialization:
  * Serialize and cache Prefix test
  */
-public class TestName1Unqualified extends OMSourcedElementTest {
+public class TestName1Unqualified extends AxiomTestCase {
     public TestName1Unqualified(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName1Unqualified extend
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("", "");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument3), "library", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT3.getContent()), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2DefaultPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2DefaultPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2DefaultPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2DefaultPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument (which uses the default namespace) Type of
  * Serialization: Serialize and consume Tests update of prefix
  */
-public class TestName2DefaultPrefix extends OMSourcedElementTest {
+public class TestName2DefaultPrefix extends AxiomTestCase {
     public TestName2DefaultPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -46,7 +47,7 @@ public class TestName2DefaultPrefix exte
         OMNamespace ns =
                 f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "DUMMYPREFIX");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument), "library", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT1.getContent()), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2QualifiedPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2QualifiedPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2QualifiedPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2QualifiedPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument2 (which uses a qualified prefix) Type of Serialization:
  * Serialize and consume Tests update of prefix
  */
-public class TestName2QualifiedPrefix extends OMSourcedElementTest {
+public class TestName2QualifiedPrefix extends AxiomTestCase {
     public TestName2QualifiedPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName2QualifiedPrefix ex
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument2), "library", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT2.getContent()), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2Unqualified.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2Unqualified.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2Unqualified.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName2Unqualified.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument3 (which uses unqualified names) Type of Serialization:
  * Serialize and consume Tests update of prefix
  */
-public class TestName2Unqualified extends OMSourcedElementTest {
+public class TestName2Unqualified extends AxiomTestCase {
     public TestName2Unqualified(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName2Unqualified extend
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("", "");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument3), "library", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT3.getContent()), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3DefaultPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3DefaultPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3DefaultPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3DefaultPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,6 +27,7 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
@@ -34,7 +35,7 @@ import org.apache.axiom.om.util.StAXUtil
  * Serialization: Serialize and cache Tests attempt to rename namespace and localpart, which is
  * not allowed
  */
-public class TestName3DefaultPrefix extends OMSourcedElementTest {
+public class TestName3DefaultPrefix extends AxiomTestCase {
     public TestName3DefaultPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -46,7 +47,7 @@ public class TestName3DefaultPrefix exte
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument), "DUMMYNAME", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT1.getContent()), "DUMMYNAME", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3QualifiedPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3QualifiedPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3QualifiedPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3QualifiedPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument2 (which uses a qualified prefix) Type of Serialization:
  * Serialize and cache Tests attempt to rename namespace and localpart, which is not allowed
  */
-public class TestName3QualifiedPrefix extends OMSourcedElementTest {
+public class TestName3QualifiedPrefix extends AxiomTestCase {
     public TestName3QualifiedPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName3QualifiedPrefix ex
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument2), "DUMMYNAME", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT2.getContent()), "DUMMYNAME", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3Unqualified.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3Unqualified.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3Unqualified.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName3Unqualified.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument3 (which uses unqualified names) Type of Serialization:
  * Serialize and cache Tests attempt to rename namespace and localpart, which is not allowed
  */
-public class TestName3Unqualified extends OMSourcedElementTest {
+public class TestName3Unqualified extends AxiomTestCase {
     public TestName3Unqualified(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName3Unqualified extend
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument3), "DUMMYNAME", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT3.getContent()), "DUMMYNAME", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4DefaultPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4DefaultPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4DefaultPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4DefaultPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,6 +27,7 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
@@ -34,7 +35,7 @@ import org.apache.axiom.om.util.StAXUtil
  * Serialization: Serialize and consume Tests that the namespace and localName are not affected
  * by the serializeAndConsume
  */
-public class TestName4DefaultPrefix extends OMSourcedElementTest {
+public class TestName4DefaultPrefix extends AxiomTestCase {
     public TestName4DefaultPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -46,7 +47,7 @@ public class TestName4DefaultPrefix exte
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument), "DUMMYNAME", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT1.getContent()), "DUMMYNAME", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4QualifiedPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4QualifiedPrefix.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4QualifiedPrefix.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4QualifiedPrefix.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument2 (which uses a qualified prefix) Type of Serialization:
  * Serialize and cache Tests attempt to rename namespace and localpart, which is not allowed
  */
-public class TestName4QualifiedPrefix extends OMSourcedElementTest {
+public class TestName4QualifiedPrefix extends AxiomTestCase {
     public TestName4QualifiedPrefix(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName4QualifiedPrefix ex
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument2), "DUMMYNAME", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT2.getContent()), "DUMMYNAME", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4Unqualified.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4Unqualified.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4Unqualified.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName4Unqualified.java Tue Jan  1 10:18:22 2013
@@ -27,13 +27,14 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests the OMSourcedElement localName, namespace and prefix settings before and after
  * serialization Document: testDocument3 (which uses unqualified names) Type of Serialization:
  * Serialize and cache Tests attempt to rename namespace and localpart, which is not allowed
  */
-public class TestName4Unqualified extends OMSourcedElementTest {
+public class TestName4Unqualified extends AxiomTestCase {
     public TestName4Unqualified(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -45,7 +46,7 @@ public class TestName4Unqualified extend
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "");
         OMElement element =
-                f.createOMElement(new TestDataSource(testDocument3), "DUMMYNAME", ns);
+                f.createOMElement(new TestDataSource(TestDocument.DOCUMENT3.getContent()), "DUMMYNAME", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java Tue Jan  1 10:18:22 2013
@@ -21,21 +21,24 @@ package org.apache.axiom.ts.om.sourcedel
 import java.io.ByteArrayOutputStream;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 
 /**
  * Test serialization of OMSourcedElementImpl to a Stream
  */
-public class TestSerializeAndConsumeToStream extends OMSourcedElementTest {
+public class TestSerializeAndConsumeToStream extends AxiomTestCase {
     public TestSerializeAndConsumeToStream(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         element.serializeAndConsume(bos);
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(),
                      new String(bos.toByteArray())), true);
         assertFalse("Element expansion when serializing", element.isExpanded());
     }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java Tue Jan  1 10:18:22 2013
@@ -21,22 +21,25 @@ package org.apache.axiom.ts.om.sourcedel
 import java.io.StringWriter;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 
 /**
  * Test serialization of OMSourcedElementImpl to a Writer
  */
-public class TestSerializeAndConsumeToWriter extends OMSourcedElementTest {
+public class TestSerializeAndConsumeToWriter extends AxiomTestCase {
     public TestSerializeAndConsumeToWriter(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         StringWriter writer = new StringWriter();
         element.serializeAndConsume(writer);
         String result = writer.toString();
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, result), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), result), true);
         assertFalse("Element expansion when serializing", element.isExpanded());
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java Tue Jan  1 10:18:22 2013
@@ -23,24 +23,27 @@ import java.io.StringWriter;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 
 /**
  * Test serialization of OMSourcedElementImpl to an XMLWriter
  */
-public class TestSerializeAndConsumeToXMLWriter extends OMSourcedElementTest {
+public class TestSerializeAndConsumeToXMLWriter extends AxiomTestCase {
     public TestSerializeAndConsumeToXMLWriter(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         StringWriter writer = new StringWriter();
         XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
         element.serializeAndConsume(writer);
         xmlwriter.flush();
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, writer.toString()), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), writer.toString()), true);
         assertFalse("Element expansion when serializing", element.isExpanded());
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java Tue Jan  1 10:18:22 2013
@@ -22,18 +22,27 @@ import java.io.StringWriter;
 
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests OMSourcedElement serialization when the root (parent) is serialized.
  */
-public class TestSerializeAndConsumeToXMLWriterEmbedded extends OMSourcedElementTest {
+public class TestSerializeAndConsumeToXMLWriterEmbedded extends AxiomTestCase {
     public TestSerializeAndConsumeToXMLWriterEmbedded(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMFactory f = metaFactory.getOMFactory();
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(f, true);
+        OMElement root = f.createOMElement("root", f.createOMNamespace("http://sampleroot", "rootPrefix"));
+        root.addChild(element);
+        
         StringWriter writer = new StringWriter();
         XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
         root.serializeAndConsume(writer);

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java Tue Jan  1 10:18:22 2013
@@ -26,8 +26,9 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.ds.CharArrayDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
 
-public class TestSerializeModifiedOMSEWithNonDestructiveDataSource extends OMSourcedElementTest {
+public class TestSerializeModifiedOMSEWithNonDestructiveDataSource extends AxiomTestCase {
     public TestSerializeModifiedOMSEWithNonDestructiveDataSource(OMMetaFactory metaFactory) {
         super(metaFactory);
     }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java Tue Jan  1 10:18:22 2013
@@ -21,27 +21,30 @@ package org.apache.axiom.ts.om.sourcedel
 import java.io.ByteArrayOutputStream;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 
 /**
  * Test serialization of OMSourcedElementImpl to a Stream
  */
-public class TestSerializeToStream extends OMSourcedElementTest {
+public class TestSerializeToStream extends AxiomTestCase {
     public TestSerializeToStream(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         element.serialize(bos);
         String newText = new String(bos.toByteArray());
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, newText), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), newText), true);
         assertTrue("Element not expanded when serializing", element.isExpanded());
 
         bos = new ByteArrayOutputStream();
         element.serialize(bos);
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(),
                      new String(bos.toByteArray())), true);
         assertTrue("Element not expanded when serializing", element.isExpanded());
     }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java Tue Jan  1 10:18:22 2013
@@ -21,28 +21,31 @@ package org.apache.axiom.ts.om.sourcedel
 import java.io.StringWriter;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 
 /**
  * Test serialization of OMSourcedElementImpl to a Writer
  */
-public class TestSerializeToWriter extends OMSourcedElementTest {
+public class TestSerializeToWriter extends AxiomTestCase {
     public TestSerializeToWriter(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         StringWriter writer = new StringWriter();
         element.serialize(writer);
         String result = writer.toString();
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, result), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), result), true);
         assertTrue("Element not expanded when serializing", element.isExpanded());
 
         writer = new StringWriter();
         element.serialize(writer);
         result = writer.toString();
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, result), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), result), true);
         assertTrue("Element not expanded when serializing", element.isExpanded());
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java Tue Jan  1 10:18:22 2013
@@ -23,31 +23,34 @@ import java.io.StringWriter;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 
 /**
  * Test serialization of OMSourcedElementImpl to an XMLWriter
  */
-public class TestSerializeToXMLWriter extends OMSourcedElementTest {
+public class TestSerializeToXMLWriter extends AxiomTestCase {
     public TestSerializeToXMLWriter(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         StringWriter writer = new StringWriter();
         XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
         element.serialize(writer);
         xmlwriter.flush();
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, writer.toString()), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), writer.toString()), true);
         assertTrue("Element not expanded when serializing", element.isExpanded());
 
         writer = new StringWriter();
         xmlwriter = StAXUtils.createXMLStreamWriter(writer);
         element.serialize(writer);
         xmlwriter.flush();
-        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument, writer.toString()), true);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(TestDocument.DOCUMENT1.getContent(), writer.toString()), true);
         assertTrue("Element not expanded when serializing", element.isExpanded());
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java Tue Jan  1 10:18:22 2013
@@ -22,18 +22,27 @@ import java.io.StringWriter;
 
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests OMSourcedElement serialization when the root (parent) is serialized.
  */
-public class TestSerializeToXMLWriterEmbedded extends OMSourcedElementTest {
+public class TestSerializeToXMLWriterEmbedded extends AxiomTestCase {
     public TestSerializeToXMLWriterEmbedded(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMFactory f = metaFactory.getOMFactory();
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(f, true);
+        OMElement root = f.createOMElement("root", f.createOMNamespace("http://sampleroot", "rootPrefix"));
+        root.addChild(element);
+        
         StringWriter writer = new StringWriter();
         XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
         root.serialize(writer);

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java Tue Jan  1 10:18:22 2013
@@ -19,46 +19,109 @@
 package org.apache.axiom.ts.om.sourcedelement;
 
 import java.io.StringWriter;
-import java.util.Iterator;
 
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMXMLBuilderFactory;
 import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.custommonkey.xmlunit.XMLAssert;
 
 /**
- * Tests OMSourcedElement getReader support
+ * Tests {@link OMSourcedElement#getXMLStreamReader(boolean)}.
  */
-public class TestSerializeToXMLWriterFromReader extends OMSourcedElementTest {
-    public TestSerializeToXMLWriterFromReader(OMMetaFactory metaFactory) {
+public class TestSerializeToXMLWriterFromReader extends AxiomTestCase {
+    private final boolean destructive;
+    private final boolean orphan;
+    private final boolean cache;
+    private final int expand;
+    private final int count;
+    
+    /**
+     * Constructor.
+     * 
+     * @param metaFactory
+     *            the meta factory for the implementation to be tested
+     * @param destructive
+     *            determines if the {@link OMDataSource} is destructive or not
+     * @param orphan
+     *            determines if the test is to be executed on an {@link OMSourcedElement} that has a
+     *            parent or not
+     * @param cache
+     *            the argument to be passed to {@link OMSourcedElement#getXMLStreamReader(boolean)}
+     * @param expand
+     *            determines if and how the sourced element should be expanded before calling
+     *            {@link OMSourcedElement#getXMLStreamReader(boolean)}: 0 = don't expand; 1 =
+     *            expand; 2 = expand and build
+     * @param count
+     *            the number of times {@link OMSourcedElement#getXMLStreamReader(boolean)} will be
+     *            called; the only meaningful values are 1 and 2
+     */
+    public TestSerializeToXMLWriterFromReader(OMMetaFactory metaFactory, boolean destructive, boolean orphan, boolean cache, int expand, int count) {
         super(metaFactory);
+        this.destructive = destructive;
+        this.orphan = orphan;
+        this.cache = cache;
+        this.expand = expand;
+        this.count = count;
+        addTestProperty("destructive", String.valueOf(destructive));
+        addTestProperty("orphan", String.valueOf(orphan));
+        addTestProperty("cache", String.valueOf(cache));
+        addTestProperty("expand", String.valueOf(expand));
+        addTestProperty("count", String.valueOf(count));
     }
 
     protected void runTest() throws Throwable {
-        StringWriter writer = new StringWriter();
-        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
-
-        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
-                metaFactory.getOMFactory(), element.getXMLStreamReader());
-        OMDocument omDocument = builder.getDocument();
-        Iterator it = omDocument.getChildren();
-        while (it.hasNext()) {
-            OMNode omNode = (OMNode) it.next();
-            // TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
-            omNode.getNextOMSibling();
-            omNode.serializeAndConsume(xmlwriter);
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement parent;
+        if (orphan) {
+            parent = null;
+        } else {
+            parent = factory.createOMElement("parent", null);
+        }
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(factory, destructive);
+        if (parent != null) {
+            parent.addChild(element);
+        }
+        if (expand != 0) {
+            element.getFirstOMChild();
+        }
+        if (expand == 2) {
+            element.build();
+        }
+        for (int iteration=0; iteration<count; iteration++) {
+            boolean expectException = iteration != 0 && expand != 2 && !cache && (destructive || expand == 1);
+            StringWriter writer = new StringWriter();
+            try {
+                OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(factory, element.getXMLStreamReader(cache));
+                builder.getDocument().serialize(writer);
+                if (expectException) {
+                    fail("Expected exception");
+                }
+            } catch (Exception ex) {
+                if (!expectException) {
+                    throw ex;
+                } else {
+                    continue;
+                }
+            }
+            XMLAssert.assertXMLEqual(TestDocument.DOCUMENT1.getContent(), writer.toString());
+            // If the underlying OMDataSource is non destructive, the expansion status should not have been
+            // changed by the call to getXMLStreamReader. If it is destructive and caching is enabled, then
+            // the sourced element should be expanded.
+            if (expand != 0 || (destructive && cache)) {
+                assertTrue(element.isExpanded());
+                assertEquals(expand == 2 || (expand == 1 && cache) || (expand == 0 && destructive && cache), element.isComplete());
+            } else {
+                assertFalse(element.isExpanded());
+            }
+            if (parent != null) {
+                // Operations on the OMSourcedElement should have no impact on the parent
+                assertTrue(parent.isComplete());
+            }
         }
-
-        xmlwriter.flush();
-        String result = writer.toString();
-
-        // We can't test for equivalence because the underlying OMSourceElement is 
-        // changed as it is serialized.  So I am testing for an internal value.
-        assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
-        assertFalse("Element expansion when serializing", element.isExpanded());
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java Tue Jan  1 10:18:22 2013
@@ -24,21 +24,30 @@ import java.util.Iterator;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMXMLBuilderFactory;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
 
 /**
  * Tests OMSourcedElement processing when the getReader() of the parent is accessed.
  */
-public class TestSerializeToXMLWriterFromReaderEmbedded extends OMSourcedElementTest {
+public class TestSerializeToXMLWriterFromReaderEmbedded extends AxiomTestCase {
     public TestSerializeToXMLWriterFromReaderEmbedded(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMFactory f = metaFactory.getOMFactory();
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(f, true);
+        OMElement root = f.createOMElement("root", f.createOMNamespace("http://sampleroot", "rootPrefix"));
+        root.addChild(element);
+        
         StringWriter writer = new StringWriter();
         XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java Tue Jan  1 10:18:22 2013
@@ -19,18 +19,21 @@
 package org.apache.axiom.ts.om.sourcedelement;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.ts.AxiomTestCase;
 
-public class TestSetDataSourceOnAlreadyExpandedElement extends OMSourcedElementTest {
+public class TestSetDataSourceOnAlreadyExpandedElement extends AxiomTestCase {
     public TestSetDataSourceOnAlreadyExpandedElement(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 
     protected void runTest() throws Throwable {
+        OMSourcedElement element = TestDocument.DOCUMENT1.createOMSourcedElement(metaFactory.getOMFactory(), true);
         // Make sure the OMSourcedElement is expanded
         element.getFirstOMChild();
         assertTrue(element.isExpanded());
         // Now set a new data source
-        element.setDataSource(new TestDataSource(testDocument2));
+        element.setDataSource(new TestDataSource(TestDocument.DOCUMENT2.getContent()));
         assertFalse(element.isExpanded());
         // getNextOMSibling should not expand the element
         assertNull(element.getNextOMSibling());

Modified: webservices/axiom/branches/AXIOM-201/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/pom.xml?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/pom.xml (original)
+++ webservices/axiom/branches/AXIOM-201/pom.xml Tue Jan  1 10:18:22 2013
@@ -306,7 +306,7 @@
             <dependency>
                 <groupId>org.apache.james</groupId>
                 <artifactId>apache-mime4j-core</artifactId>
-                <version>0.7.2</version>
+                <version>0.8-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.osgi</groupId>
@@ -399,6 +399,7 @@
         <stax.impl.version>1.2.0</stax.impl.version>
         -->
         <shade.plugin.version>1.6</shade.plugin.version>
+        <jacoco.version>0.6.1.201212231917</jacoco.version>
     </properties>
     <build>
         <extensions>
@@ -424,6 +425,10 @@
                         </includes>
                         <systemProperties>
                             <property>
+                                <name>java.io.tmpdir</name>
+                                <value>${project.build.directory}/tmp</value>
+                            </property>
+                            <property>
                                 <name>java.awt.headless</name>
                                 <value>true</value>
                             </property>
@@ -450,7 +455,7 @@
                 </plugin>
                 <plugin>
                     <artifactId>maven-dependency-plugin</artifactId>
-                    <version>2.1</version>
+                    <version>2.6</version>
                 </plugin>
                 <plugin>
                     <artifactId>maven-shade-plugin</artifactId>
@@ -464,7 +469,7 @@
                 <plugin>
                     <groupId>org.codehaus.mojo</groupId>
                     <artifactId>build-helper-maven-plugin</artifactId>
-                    <version>1.5</version>
+                    <version>1.7</version>
                 </plugin>
                 <plugin>
                     <artifactId>maven-release-plugin</artifactId>
@@ -525,6 +530,32 @@
                 </executions>
             </plugin>
             <plugin>
+                <groupId>org.codehaus.gmaven</groupId>
+                <artifactId>gmaven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>initialize</id>
+                        <phase>initialize</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <source>
+                                import java.io.File
+                                
+                                <!-- Create the temporary directory specified in the surefire configuration -->
+                                new File(project.build.directory, 'tmp').mkdirs()
+                                
+                                <!-- Skip Jacoco if necessary -->
+                                if (project.packaging == 'pom' || project.properties['skipTests'] == 'true') {
+                                    project.properties['skipJacoco'] = 'true'
+                                }
+                            </source>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>2.3.2</version>
                 <inherited>true</inherited>
@@ -553,6 +584,46 @@
                     <attach>true</attach>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>${jacoco.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                        <configuration>
+                            <skip>${skipJacoco}</skip>
+                            <!-- Anonymize the session ID (by default it contains the name of the host executing the build) -->
+                            <sessionId>mvn:${project.groupId}:${project.artifactId}:${project.version}</sessionId>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-jacoco-exec</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <skipAttach>${skipJacoco}</skipAttach>
+                            <artifacts>
+                                <artifact>
+                                    <file>${project.build.directory}/jacoco.exec</file>
+                                    <classifier>jacoco</classifier>
+                                    <type>exec</type>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
     <profiles>
@@ -649,5 +720,6 @@
         <module>userguide</module>
         <module>apidocs</module>
         <module>distribution</module>
+        <module>code-coverage</module>
     </modules>
 </project>

Modified: webservices/axiom/branches/AXIOM-201/src/site/site.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/src/site/site.xml?rev=1427339&r1=1427338&r2=1427339&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/src/site/site.xml (original)
+++ webservices/axiom/branches/AXIOM-201/src/site/site.xml Tue Jan  1 10:18:22 2013
@@ -52,6 +52,7 @@
             <item name="Javadocs" href="/apidocs/index.html"/>
             <item name="FAQ" href="faq.html"/>
             <item name="View Source" href="http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/?root=Apache-SVN"/>
+            <item name="Code Coverage" href="code-coverage/index.html"/>
         </menu>
         <menu name="Apache">
             <item name="License" href="http://www.apache.org/licenses/"/>