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/16 22:37:16 UTC

svn commit: r1434416 - in /webservices/commons/trunk/modules/axiom/modules: axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/cont...

Author: veithen
Date: Wed Jan 16 21:37:15 2013
New Revision: 1434416

URL: http://svn.apache.org/viewvc?rev=1434416&view=rev
Log:
* Consolidated a couple of test cases and increased the code coverage.
* Fixed an issue in the logic introduced by AXIOM-96.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerialize.java
      - copied, changed from r1433547, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/Strategy.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializationStrategy.java
      - copied, changed from r1433547, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializationMethod.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeFromXMLStreamReader.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToOutputStream.java
      - copied, changed from r1433547, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializeToOutputStream.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToWriter.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToXMLStreamWriter.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XML.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsByteArray.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsString.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/package.html
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializationMethod.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializeToOutputStream.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/BuilderFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/OMContainerFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java?rev=1434416&r1=1434415&r2=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java Wed Jan 16 21:37:15 2013
@@ -901,7 +901,7 @@ class SwitchingWrapper extends AbstractX
      */
     private boolean isLeaf(OMSerializable n) {
         if (n instanceof OMContainer) {
-            return streamSwitch.isDataSourceALeaf() && isOMSourcedElement(n) && n != rootNode;
+            return streamSwitch.isDataSourceALeaf() && isOMSourcedElement(n) && !((OMSourcedElement)n).isExpanded() && n != rootNode;
         } else {
             return true;
         }
@@ -1384,17 +1384,24 @@ class SwitchingWrapper extends AbstractX
         OMDataSource ds = null;
         if (node != null &&
             node instanceof OMSourcedElement) {
-            try {
-                ds = ((OMSourcedElement) node).getDataSource();
-            } catch (UnsupportedOperationException e) {
-                // Some implementations throw an UnsupportedOperationException.
-                ds =null;
-            }
-            if (log.isDebugEnabled()) {
-                if (ds != null) {
-                    log.debug("OMSourcedElement exposed an OMDataSource." + ds);
-                } else {
-                    log.debug("OMSourcedElement does not have a OMDataSource.");
+            OMSourcedElement element = (OMSourcedElement)node;
+            if (element.isExpanded()) {
+                // If the element is expanded, then we can't return the OMDataSource because the
+                // expanded element may already have been modified
+                ds = null;
+            } else {
+                try {
+                    ds = element.getDataSource();
+                } catch (UnsupportedOperationException e) {
+                    // Some implementations throw an UnsupportedOperationException.
+                    ds =null;
+                }
+                if (log.isDebugEnabled()) {
+                    if (ds != null) {
+                        log.debug("OMSourcedElement exposed an OMDataSource." + ds);
+                    } else {
+                        log.debug("OMSourcedElement does not have a OMDataSource.");
+                    }
                 }
             }
         }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1434416&r1=1434415&r2=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Wed Jan 16 21:37:15 2013
@@ -28,13 +28,16 @@ import org.apache.axiom.testutils.suite.
 import org.apache.axiom.ts.om.container.BuilderFactory;
 import org.apache.axiom.ts.om.container.OMContainerFactory;
 import org.apache.axiom.ts.om.container.OMElementFactory;
-import org.apache.axiom.ts.om.container.SerializationMethod;
-import org.apache.axiom.ts.om.container.SerializeToOutputStream;
 import org.apache.axiom.ts.om.factory.CreateOMElementParentSupplier;
 import org.apache.axiom.ts.om.factory.CreateOMElementVariant;
 import org.apache.axiom.ts.om.sourcedelement.OMSourcedElementVariant;
 import org.apache.axiom.ts.om.xpath.AXIOMXPathTestCase;
 import org.apache.axiom.ts.om.xpath.TestAXIOMXPath;
+import org.apache.axiom.ts.strategy.serialization.SerializationStrategy;
+import org.apache.axiom.ts.strategy.serialization.SerializeFromXMLStreamReader;
+import org.apache.axiom.ts.strategy.serialization.SerializeToOutputStream;
+import org.apache.axiom.ts.strategy.serialization.SerializeToWriter;
+import org.apache.axiom.ts.strategy.serialization.SerializeToXMLStreamWriter;
 
 public class OMTestSuiteBuilder extends TestSuiteBuilder {
     private static final BuilderFactory[] builderFactories = {
@@ -47,9 +50,15 @@ public class OMTestSuiteBuilder extends 
         new OMElementFactory(false),
         new OMElementFactory(true) };
     
-    private static final SerializationMethod[] serializationMethods = {
+    private static final SerializationStrategy[] serializationStrategies = {
         new SerializeToOutputStream(true),
-        new SerializeToOutputStream(false) };
+        new SerializeToOutputStream(false),
+        new SerializeToWriter(true),
+        new SerializeToWriter(false),
+        new SerializeToXMLStreamWriter(true),
+        new SerializeToXMLStreamWriter(false),
+        new SerializeFromXMLStreamReader(true),
+        new SerializeFromXMLStreamReader(false) };
     
     private static final QName[] qnames = {
         new QName("root"),
@@ -119,8 +128,8 @@ public class OMTestSuiteBuilder extends 
                 // On a document containing entity references, serialization tests will only work correctly if
                 // the entire document is serialized (so that the DTD is available)
                 if (!file.hasEntityReferences() || cf == OMContainerFactory.DOCUMENT) {
-                    for (int k=0; k<serializationMethods.length; k++) {
-                        addTest(new org.apache.axiom.ts.om.container.TestSerialize(metaFactory, file, containerFactories[j], serializationMethods[k]));
+                    for (int k=0; k<serializationStrategies.length; k++) {
+                        addTest(new org.apache.axiom.ts.om.container.TestSerialize(metaFactory, file, containerFactories[j], serializationStrategies[k]));
                     }
                     // The SAXSource returned by getSAXSource is not able to reconstruct the internal subset.
                     // Skip test documents that have a DTD with an internal subset.
@@ -461,27 +470,20 @@ public class OMTestSuiteBuilder extends 
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestName4QualifiedPrefix(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestName4Unqualified(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestRemoveChildrenUnexpanded(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeAndConsumeToStream(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeAndConsumeToWriter(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeAndConsumeToXMLWriter(metaFactory));
+            for (int i = 0; i < serializationStrategies.length; i++) {
+                SerializationStrategy serializationStrategy = serializationStrategies[i];
+                for (int expand = 0; expand <= 2; expand++) {
+                    for (int count = 1; count <= 2; count++) {
+                        addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerialize(metaFactory, serializationStrategy, false, false, expand, count));
+                        addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerialize(metaFactory, serializationStrategy, false, true, expand, count));
+                        addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerialize(metaFactory, serializationStrategy, true, false, expand, count));
+                        addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerialize(metaFactory, serializationStrategy, true, true, expand, count));
+                    }
+                }
+            }
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeAndConsumeToXMLWriterEmbedded(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeModifiedOMSEWithNonDestructiveDataSource(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToStream(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToWriter(metaFactory));
-            addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriter(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterEmbedded(metaFactory));
-            for (int expand = 0; expand <= 2; expand++) {
-                for (int count = 1; count <= 2; count++) {
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, false, false, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, false, true, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, true, false, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, false, true, true, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, false, false, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, false, true, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, true, false, expand, count));
-                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReader(metaFactory, true, true, true, expand, count));
-                }
-            }
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerializeToXMLWriterFromReaderEmbedded(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSetDataSource(metaFactory));
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestSetDataSourceOnAlreadyExpandedElement(metaFactory));

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/BuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/BuilderFactory.java?rev=1434416&r1=1434415&r2=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/BuilderFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/BuilderFactory.java Wed Jan 16 21:37:15 2013
@@ -28,13 +28,14 @@ import org.apache.axiom.om.OMXMLBuilderF
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.testutils.stax.XMLStreamReaderComparator;
 import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.strategy.Strategy;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
 /**
  * Defines a strategy to create an {@link OMXMLParserWrapper} from a given test file.
  */
-public interface BuilderFactory {
+public interface BuilderFactory extends Strategy {
     /**
      * Creates an {@link OMXMLParserWrapper} directly from the given {@link InputSource}, i.e. let
      * instantiate an appropriate parser.
@@ -104,7 +105,5 @@ public interface BuilderFactory {
     
     void configureXMLStreamReaderComparator(XMLStreamReaderComparator comparator);
     
-    void addTestProperties(AxiomTestCase testCase);
-    
     OMXMLParserWrapper getBuilder(OMMetaFactory metaFactory, InputSource inputSource) throws Exception;
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/OMContainerFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/OMContainerFactory.java?rev=1434416&r1=1434415&r2=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/OMContainerFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/OMContainerFactory.java Wed Jan 16 21:37:15 2013
@@ -26,12 +26,13 @@ import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.RootWhitespaceFilter;
 import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.strategy.Strategy;
 import org.xml.sax.InputSource;
 
 /**
  * Extracts an {@link OMContainer} instance from a test file.
  */
-public interface OMContainerFactory {
+public interface OMContainerFactory extends Strategy {
     OMContainerFactory DOCUMENT = new OMContainerFactory() {
         public void addTestProperties(AxiomTestCase testCase) {
             testCase.addTestProperty("container", "document");
@@ -50,8 +51,6 @@ public interface OMContainerFactory {
         }
     };
     
-    void addTestProperties(AxiomTestCase testCase);
-    
     /**
      * Prepare a control document that has the same content as the container returned by
      * {@link #getContainer(OMXMLParserWrapper)}.

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java?rev=1434416&r1=1434415&r2=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java Wed Jan 16 21:37:15 2013
@@ -28,6 +28,8 @@ import org.apache.axiom.om.OMMetaFactory
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.testutils.conformance.ConformanceTestFile;
 import org.apache.axiom.ts.ConformanceTestCase;
+import org.apache.axiom.ts.strategy.serialization.SerializationStrategy;
+import org.apache.axiom.ts.strategy.serialization.XML;
 import org.apache.commons.io.IOUtils;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
@@ -35,15 +37,15 @@ import org.xml.sax.InputSource;
 
 public class TestSerialize extends ConformanceTestCase {
     private final OMContainerFactory containerFactory;
-    private final SerializationMethod serializationMethod;
+    private final SerializationStrategy serializationStrategy;
     
     public TestSerialize(OMMetaFactory metaFactory, ConformanceTestFile file,
-            OMContainerFactory containerFactory, SerializationMethod serializationMethod) {
+            OMContainerFactory containerFactory, SerializationStrategy serializationStrategy) {
         super(metaFactory, file);
         this.containerFactory = containerFactory;
-        this.serializationMethod = serializationMethod;
+        this.serializationStrategy = serializationStrategy;
         containerFactory.addTestProperties(this);
-        serializationMethod.addTestProperties(this);
+        serializationStrategy.addTestProperties(this);
     }
 
     protected void runTest() throws Throwable {
@@ -54,21 +56,22 @@ public class TestSerialize extends Confo
             // We need to clone the InputSource objects so that we can dump their contents
             // if the test fails
             InputSource control[] = duplicateInputSource(containerFactory.getControl(file.getAsStream()));
-            InputSource actual[] = duplicateInputSource(serializationMethod.serialize(container));
+            XML actual = serializationStrategy.serialize(container);
             try {
                 // Configure the InputSources such that external entities can be resolved
                 String systemId = new URL(file.getUrl(), "dummy.xml").toString();
                 control[0].setSystemId(systemId);
-                actual[0].setSystemId(systemId);
-                XMLAssert.assertXMLIdentical(XMLUnit.compareXML(control[0], actual[0]), true);
+                InputSource actualIS = actual.getInputSource();
+                actualIS.setSystemId(systemId);
+                XMLAssert.assertXMLIdentical(XMLUnit.compareXML(control[0], actualIS), true);
             } catch (Throwable ex) {
                 System.out.println("Control:");
                 dumpInputSource(control[1]);
                 System.out.println("Actual:");
-                dumpInputSource(actual[1]);
+                actual.dump(System.out);
                 throw ex;
             }
-            if (serializationMethod.isCaching()) {
+            if (serializationStrategy.isCaching()) {
                 assertTrue(container.isComplete());
             } else {
                 // TODO: need to investigate why assertConsumed is not working here

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerialize.java (from r1433547, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerialize.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerialize.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java&r1=1433547&r2=1434416&rev=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerialize.java Wed Jan 16 21:37:15 2013
@@ -18,25 +18,27 @@
  */
 package org.apache.axiom.ts.om.sourcedelement;
 
-import java.io.StringWriter;
+import java.io.StringReader;
 
 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.OMSourcedElement;
-import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.strategy.serialization.SerializationStrategy;
+import org.apache.axiom.ts.strategy.serialization.XML;
 import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.xml.sax.InputSource;
 
 /**
- * Tests {@link OMSourcedElement#getXMLStreamReader(boolean)}.
+ * Tests various ways to serialize an {@link OMSourcedElement}.
  */
-public class TestSerializeToXMLWriterFromReader extends AxiomTestCase {
+public class TestSerialize extends AxiomTestCase {
+    private final SerializationStrategy serializationStrategy;
     private final boolean destructive;
     private final boolean orphan;
-    private final boolean cache;
     private final int expand;
     private final int count;
     
@@ -45,13 +47,13 @@ public class TestSerializeToXMLWriterFro
      * 
      * @param metaFactory
      *            the meta factory for the implementation to be tested
+     * @param serializationStrategy
+     *            the serialization strategy to test
      * @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 =
@@ -60,16 +62,16 @@ public class TestSerializeToXMLWriterFro
      *            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) {
+    public TestSerialize(OMMetaFactory metaFactory, SerializationStrategy serializationStrategy, boolean destructive, boolean orphan, int expand, int count) {
         super(metaFactory);
+        this.serializationStrategy = serializationStrategy;
         this.destructive = destructive;
         this.orphan = orphan;
-        this.cache = cache;
         this.expand = expand;
         this.count = count;
+        serializationStrategy.addTestProperties(this);
         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));
     }
@@ -92,12 +94,12 @@ public class TestSerializeToXMLWriterFro
         if (expand == 2) {
             element.build();
         }
+        boolean cache = serializationStrategy.isCaching();
         for (int iteration=0; iteration<count; iteration++) {
             boolean expectException = iteration != 0 && expand != 2 && !cache && (destructive || expand == 1);
-            StringWriter writer = new StringWriter();
+            XML result;
             try {
-                OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(factory, element.getXMLStreamReader(cache));
-                builder.getDocument().serialize(writer);
+                result = serializationStrategy.serialize(element);
                 if (expectException) {
                     fail("Expected exception");
                 }
@@ -108,7 +110,7 @@ public class TestSerializeToXMLWriterFro
                     continue;
                 }
             }
-            XMLAssert.assertXMLEqual(TestDocument.DOCUMENT1.getContent(), writer.toString());
+            XMLAssert.assertXMLIdentical(XMLUnit.compareXML(new InputSource(new StringReader(TestDocument.DOCUMENT1.getContent())), result.getInputSource()), true);
             // 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.

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/Strategy.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/Strategy.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/Strategy.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/Strategy.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,25 @@
+/*
+ * 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.strategy;
+
+import org.apache.axiom.ts.AxiomTestCase;
+
+public interface Strategy {
+    void addTestProperties(AxiomTestCase testCase);
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/Strategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializationStrategy.java (from r1433547, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializationMethod.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializationStrategy.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializationStrategy.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializationMethod.java&r1=1433547&r2=1434416&rev=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializationMethod.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializationStrategy.java Wed Jan 16 21:37:15 2013
@@ -16,14 +16,30 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.ts.om.container;
+package org.apache.axiom.ts.strategy.serialization;
 
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.ts.AxiomTestCase;
-import org.xml.sax.InputSource;
+import org.apache.axiom.ts.strategy.Strategy;
 
-public interface SerializationMethod {
-    void addTestProperties(AxiomTestCase testCase);
-    InputSource serialize(OMContainer container) throws Exception;
+/**
+ * Defines a strategy to serialize an {@link OMContainer} instance to XML.
+ */
+public interface SerializationStrategy extends Strategy {
+    /**
+     * Serialize the given {@link OMContainer}.
+     * 
+     * @param container
+     *            the container to serialize to XML
+     * @return the serialized XML
+     * @throws Exception
+     */
+    XML serialize(OMContainer container) throws Exception;
+
+    /**
+     * Determine if this serialization strategy consumes the content of the {@link OMContainer}.
+     * 
+     * @return <code>true</code> if the strategy preserves the content, <code>false</code> if it
+     *         consumes the content
+     */
     boolean isCaching();
 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeFromXMLStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeFromXMLStreamReader.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeFromXMLStreamReader.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeFromXMLStreamReader.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,54 @@
+/*
+ * 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.strategy.serialization;
+
+import java.io.StringWriter;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Serializes an {@link OMContainer} by processing the result of
+ * {@link OMContainer#getXMLStreamReader(boolean)}.
+ */
+public class SerializeFromXMLStreamReader implements SerializationStrategy {
+    private final boolean cache;
+    
+    public SerializeFromXMLStreamReader(boolean cache) {
+        this.cache = cache;
+    }
+
+    public void addTestProperties(AxiomTestCase testCase) {
+        testCase.addTestProperty("serializationStrategy", "XMLStreamReader");
+        testCase.addTestProperty("cache", String.valueOf(cache));
+    }
+
+    public XML serialize(OMContainer container) throws Exception {
+        StringWriter sw = new StringWriter();
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(container.getOMFactory(), container.getXMLStreamReader(cache));
+        builder.getDocument().serialize(sw);
+        return new XMLAsString(sw.toString());
+    }
+
+    public boolean isCaching() {
+        return cache;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeFromXMLStreamReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToOutputStream.java (from r1433547, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializeToOutputStream.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToOutputStream.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToOutputStream.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializeToOutputStream.java&r1=1433547&r2=1434416&rev=1434416&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/SerializeToOutputStream.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToOutputStream.java Wed Jan 16 21:37:15 2013
@@ -16,16 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.ts.om.container;
+package org.apache.axiom.ts.strategy.serialization;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
 
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.ts.AxiomTestCase;
-import org.xml.sax.InputSource;
 
-public class SerializeToOutputStream implements SerializationMethod {
+/**
+ * Serializes an {@link OMContainer} using {@link OMContainer#serialize(OutputStream)} or
+ * {@link OMContainer#serializeAndConsume(OutputStream)}.
+ */
+public class SerializeToOutputStream implements SerializationStrategy {
     private final boolean cache;
     
     public SerializeToOutputStream(boolean cache) {
@@ -33,17 +36,18 @@ public class SerializeToOutputStream imp
     }
 
     public void addTestProperties(AxiomTestCase testCase) {
-        testCase.addTestProperty("method", cache ? "serialize" : "serializeAndConsume");
+        testCase.addTestProperty("serializationStrategy", "OutputStream");
+        testCase.addTestProperty("cache", String.valueOf(cache));
     }
 
-    public InputSource serialize(OMContainer container) throws Exception {
+    public XML serialize(OMContainer container) throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         if (cache) {
             container.serialize(baos);
         } else {
             container.serializeAndConsume(baos);
         }
-        return new InputSource(new ByteArrayInputStream(baos.toByteArray()));
+        return new XMLAsByteArray(baos.toByteArray());
     }
 
     public boolean isCaching() {

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToWriter.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToWriter.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToWriter.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.strategy.serialization;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Serializes an {@link OMContainer} using {@link OMContainer#serialize(Writer)} or
+ * {@link OMContainer#serializeAndConsume(Writer)}.
+ */
+public class SerializeToWriter implements SerializationStrategy {
+    private final boolean cache;
+    
+    public SerializeToWriter(boolean cache) {
+        this.cache = cache;
+    }
+
+    public void addTestProperties(AxiomTestCase testCase) {
+        testCase.addTestProperty("serializationStrategy", "Writer");
+        testCase.addTestProperty("cache", String.valueOf(cache));
+    }
+
+    public XML serialize(OMContainer container) throws Exception {
+        StringWriter sw = new StringWriter();
+        if (cache) {
+            container.serialize(sw);
+        } else {
+            container.serializeAndConsume(sw);
+        }
+        return new XMLAsString(sw.toString());
+    }
+
+    public boolean isCaching() {
+        return cache;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToXMLStreamWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToXMLStreamWriter.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToXMLStreamWriter.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToXMLStreamWriter.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,60 @@
+/*
+ * 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.strategy.serialization;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Serializes an {@link OMContainer} using {@link OMContainer#serialize(XMLStreamWriter)} or
+ * {@link OMContainer#serializeAndConsume(XMLStreamWriter)}.
+ */
+public class SerializeToXMLStreamWriter implements SerializationStrategy {
+    private final boolean cache;
+    
+    public SerializeToXMLStreamWriter(boolean cache) {
+        this.cache = cache;
+    }
+
+    public void addTestProperties(AxiomTestCase testCase) {
+        testCase.addTestProperty("serializationStrategy", "XMLStreamWriter");
+        testCase.addTestProperty("cache", String.valueOf(cache));
+    }
+
+    public XML serialize(OMContainer container) throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(baos);
+        if (cache) {
+            container.serialize(writer);
+        } else {
+            container.serializeAndConsume(writer);
+        }
+        writer.close();
+        return new XMLAsByteArray(baos.toByteArray());
+    }
+
+    public boolean isCaching() {
+        return cache;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/SerializeToXMLStreamWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XML.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XML.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XML.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XML.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.strategy.serialization;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.InputSource;
+
+/**
+ * Encapsulates serialized XML data. In contrast to {@link InputSource} or {@link StreamSource} the
+ * data can be read multiple times.
+ */
+public interface XML {
+    /**
+     * Get an {@link InputSource} object for the XML data.
+     * 
+     * @return the XML data as an {@link InputSource} object
+     */
+    InputSource getInputSource();
+    
+    /**
+     * Dump the XML data to the given stream.
+     * 
+     * @param out
+     *            the stream to write the XML data to
+     * @throws IOException 
+     */
+    void dump(PrintStream out) throws IOException;
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XML.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsByteArray.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsByteArray.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsByteArray.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsByteArray.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.strategy.serialization;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.xml.sax.InputSource;
+
+class XMLAsByteArray implements XML {
+    private final byte[] xml;
+
+    public XMLAsByteArray(byte[] xml) {
+        this.xml = xml;
+    }
+
+    public InputSource getInputSource() {
+        return new InputSource(new ByteArrayInputStream(xml));
+    }
+
+    public void dump(PrintStream out) throws IOException {
+        out.write(xml);
+        out.println();
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsByteArray.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsString.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsString.java?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsString.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsString.java Wed Jan 16 21:37:15 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.strategy.serialization;
+
+import java.io.PrintStream;
+import java.io.StringReader;
+
+import org.xml.sax.InputSource;
+
+class XMLAsString implements XML {
+    private final String xml;
+
+    public XMLAsString(String xml) {
+        this.xml = xml;
+    }
+
+    public InputSource getInputSource() {
+        return new InputSource(new StringReader(xml));
+    }
+
+    public void dump(PrintStream out) {
+        out.println(xml);
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/XMLAsString.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/package.html
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/package.html?rev=1434416&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/package.html (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/strategy/serialization/package.html Wed Jan 16 21:37:15 2013
@@ -0,0 +1,23 @@
+<!--
+  ~ 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.
+  -->
+<html>
+<body>
+Defines a set of strategies to serialize an {@link org.apache.axiom.om.OMContainer}.
+</body>
+</html>
\ No newline at end of file