ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1198594 [2/2] - in /webservices/commons/trunk/modules/axiom/modules: axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/ axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-...
Date Sun, 06 Nov 2011 23:43:11 GMT
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToStream.java
Sun Nov  6 23:43:10 2011
@@ -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.om.sourcedelement;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * Test serialization of OMSourcedElementImpl to a Stream
+ */
+public class TestSerializeAndConsumeToStream extends OMSourcedElementTest {
+    public TestSerializeAndConsumeToStream(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        element.serializeAndConsume(bos);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
+                     new String(bos.toByteArray())), true);
+        assertFalse("Element expansion when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToWriter.java
Sun Nov  6 23:43:10 2011
@@ -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.om.sourcedelement;
+
+import java.io.StringWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * Test serialization of OMSourcedElementImpl to a Writer
+ */
+public class TestSerializeAndConsumeToWriter extends OMSourcedElementTest {
+    public TestSerializeAndConsumeToWriter(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        StringWriter writer = new StringWriter();
+        element.serializeAndConsume(writer);
+        String result = writer.toString();
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
result), true);
+        assertFalse("Element expansion when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriter.java
Sun Nov  6 23:43:10 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.StAXUtils;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * Test serialization of OMSourcedElementImpl to an XMLWriter
+ */
+public class TestSerializeAndConsumeToXMLWriter extends OMSourcedElementTest {
+    public TestSerializeAndConsumeToXMLWriter(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        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);
+        assertFalse("Element expansion when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeAndConsumeToXMLWriterEmbedded.java
Sun Nov  6 23:43:10 2011
@@ -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.om.sourcedelement;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * Tests OMSourcedElement serialization when the root (parent) is serialized.
+ */
+public class TestSerializeAndConsumeToXMLWriterEmbedded extends OMSourcedElementTest {
+    public TestSerializeAndConsumeToXMLWriterEmbedded(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        StringWriter writer = new StringWriter();
+        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
+        root.serializeAndConsume(writer);
+        xmlwriter.flush();
+        String result = writer.toString();
+
+        // We can't test for equivalence because the underlying OMSourceElement is 
+        // streamed 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());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeModifiedOMSEWithNonDestructiveDataSource.java
Sun Nov  6 23:43:10 2011
@@ -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.om.sourcedelement;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.ds.CharArrayDataSource;
+
+public class TestSerializeModifiedOMSEWithNonDestructiveDataSource extends OMSourcedElementTest
{
+    public TestSerializeModifiedOMSEWithNonDestructiveDataSource(OMMetaFactory metaFactory)
{
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMDataSourceExt ds = new CharArrayDataSource("<element><child/></element>".toCharArray());
+        assertFalse(ds.isDestructiveWrite());
+        
+        OMFactory f = metaFactory.getOMFactory();
+        OMElement element = f.createOMElement(ds, "element", null);
+        
+        element.getFirstElement().setText("TEST");
+        
+        StringWriter sw = new StringWriter();
+        element.serialize(sw);
+        assertTrue(sw.toString().indexOf("TEST") != -1);
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        element.serialize(baos);
+        assertTrue(new String(baos.toByteArray(), "UTF-8").indexOf("TEST") != -1);
+        
+        assertTrue(element.toString().indexOf("TEST") != -1);
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToStream.java
Sun Nov  6 23:43:10 2011
@@ -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.om.sourcedelement;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * Test serialization of OMSourcedElementImpl to a Stream
+ */
+public class TestSerializeToStream extends OMSourcedElementTest {
+    public TestSerializeToStream(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        element.serialize(bos);
+        String newText = new String(bos.toByteArray());
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
newText), true);
+        assertTrue("Element not expanded when serializing", element.isExpanded());
+
+        bos = new ByteArrayOutputStream();
+        element.serialize(bos);
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
+                     new String(bos.toByteArray())), true);
+        assertTrue("Element not expanded when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToWriter.java
Sun Nov  6 23:43:10 2011
@@ -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.om.sourcedelement;
+
+import java.io.StringWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * Test serialization of OMSourcedElementImpl to a Writer
+ */
+public class TestSerializeToWriter extends OMSourcedElementTest {
+    public TestSerializeToWriter(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        StringWriter writer = new StringWriter();
+        element.serialize(writer);
+        String result = writer.toString();
+        XMLAssert.assertXMLIdentical("Serialized text error", XMLUnit.compareXML(testDocument,
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);
+        assertTrue("Element not expanded when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriter.java
Sun Nov  6 23:43:10 2011
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.StAXUtils;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * Test serialization of OMSourcedElementImpl to an XMLWriter
+ */
+public class TestSerializeToXMLWriter extends OMSourcedElementTest {
+    public TestSerializeToXMLWriter(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        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);
+        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);
+        assertTrue("Element not expanded when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterEmbedded.java
Sun Nov  6 23:43:10 2011
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * Tests OMSourcedElement serialization when the root (parent) is serialized.
+ */
+public class TestSerializeToXMLWriterEmbedded extends OMSourcedElementTest {
+    public TestSerializeToXMLWriterEmbedded(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        StringWriter writer = new StringWriter();
+        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
+        root.serialize(writer);
+        xmlwriter.flush();
+        String result = writer.toString();
+        // We can't test for equivalence because the underlying OMSourceElement is 
+        // streamed as it is serialized.  So I am testing for an internal value.
+        assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
+        assertTrue("Element not expanded when serializing", element.isExpanded());
+
+        writer = new StringWriter();
+        xmlwriter = StAXUtils.createXMLStreamWriter(writer);
+        root.serialize(writer);
+        xmlwriter.flush();
+        result = writer.toString();
+        // We can't test for equivalence because the underlying OMSourceElement is 
+        // streamed as it is serialized.  So I am testing for an internal value.
+        assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
+        assertTrue("Element not expanded when serializing", element.isExpanded());
+    }
+}

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

Added: 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/TestSerializeToXMLWriterFromReader.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReader.java
Sun Nov  6 23:43:10 2011
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import java.io.StringWriter;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * Tests OMSourcedElement getReader support
+ */
+public class TestSerializeToXMLWriterFromReader extends OMSourcedElementTest {
+    public TestSerializeToXMLWriterFromReader(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        StringWriter writer = new StringWriter();
+        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
+
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(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);
+        }
+
+        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());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSerializeToXMLWriterFromReaderEmbedded.java
Sun Nov  6 23:43:10 2011
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import java.io.StringWriter;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * Tests OMSourcedElement processing when the getReader() of the parent is accessed.
+ */
+public class TestSerializeToXMLWriterFromReaderEmbedded extends OMSourcedElementTest {
+    public TestSerializeToXMLWriterFromReaderEmbedded(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        StringWriter writer = new StringWriter();
+        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);
+
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(root.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);
+        }
+        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);
+        // The implementation uses OMNavigator to walk the tree.  Currently OMNavigator must

+        // expand the OMSourcedElement to correctly walk the elements. (See OMNavigator._getFirstChild)
+        //assertFalse("Element expansion when serializing", element.isExpanded());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java?rev=1198594&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestSetDataSourceOnAlreadyExpandedElement.java
Sun Nov  6 23:43:10 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import org.apache.axiom.om.OMMetaFactory;
+
+public class TestSetDataSourceOnAlreadyExpandedElement extends OMSourcedElementTest {
+    public TestSetDataSourceOnAlreadyExpandedElement(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        // Make sure the OMSourcedElement is expanded
+        element.getFirstOMChild();
+        assertTrue(element.isExpanded());
+        // Now set a new data source
+        element.setDataSource(new TestDataSource(testDocument2));
+        assertFalse(element.isExpanded());
+        // getNextOMSibling should not expand the element
+        assertNull(element.getNextOMSibling());
+        assertFalse(element.isExpanded());
+    }
+}

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



Mime
View raw message