ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1045408 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/test/java/org/apache/axiom/om/ axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/ axiom-testsuite/ axio...
Date Mon, 13 Dec 2010 22:57:46 GMT
Author: veithen
Date: Mon Dec 13 22:57:45 2010
New Revision: 1045408

URL: http://svn.apache.org/viewvc?rev=1045408&view=rev
Log:
Refactored some existing unit tests (no tests added or removed).

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetQName.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationInScope.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationOnSameElement.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithMaskedNamespaceDeclaration.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithoutExistingNamespaceDeclaration.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetach.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfter.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterLastChild.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterOnOrphan.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBefore.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBeforeOnOrphan.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestBase64Streaming.java   (with props)
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMNodeTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/AttributeTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NodeImplTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/AttributeImplTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMNodeImplTest.java
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java?rev=1045408&r1=1045407&r2=1045408&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMElementTestBase.java Mon Dec 13 22:57:45 2010
@@ -317,86 +317,6 @@ public abstract class OMElementTestBase 
         assertEquals("value2", att2.getAttributeValue());
     }
     
-    public void testAddAttributeWithoutExistingNamespaceDeclaration() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMElement element = factory.createOMElement(new QName("test"));
-        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
-        OMAttribute att = factory.createOMAttribute("test", ns, "test");
-        element.addAttribute(att);
-        assertEquals(ns, element.findNamespace(ns.getNamespaceURI(), ns.getPrefix()));
-        Iterator it = element.getAllDeclaredNamespaces();
-        assertTrue(it.hasNext());
-        assertEquals(ns, it.next());
-        assertFalse(it.hasNext());
-    }
-
-    /**
-     * Test that adding an attribute doesn't create an additional namespace declaration if
-     * a corresponding declaration already exists on the element.
-     */
-    public void testAddAttributeWithExistingNamespaceDeclarationOnSameElement() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMElement element = factory.createOMElement(new QName("test"));
-        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
-        element.declareNamespace(ns);
-        OMAttribute att = factory.createOMAttribute("test", ns, "test");
-        element.addAttribute(att);
-        Iterator it = element.getAllDeclaredNamespaces();
-        assertTrue(it.hasNext());
-        assertEquals(ns, it.next());
-        assertFalse(it.hasNext());
-    }
-
-    /**
-     * Test that adding an attribute doesn't create an additional namespace declaration if
-     * a corresponding declaration is already in scope.
-     */
-    public void testAddAttributeWithExistingNamespaceDeclarationInScope() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMElement root = factory.createOMElement(new QName("test"));
-        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
-        root.declareNamespace(ns);
-        OMElement child = factory.createOMElement(new QName("test"), root);
-        OMAttribute att = factory.createOMAttribute("test", ns, "test");
-        child.addAttribute(att);
-        Iterator it = child.getAllDeclaredNamespaces();
-        assertFalse(it.hasNext());
-    }
-
-    /**
-     * Test checking that {@link OMElement#addAttribute(OMAttribute)} correctly generates a
-     * new namespace declaration if an equivalent namespace declaration exists but is masked.
-     * The test attempts to create the following XML:
-     * <pre>
-     * &lt;a xmlns:p="urn:ns1">
-     *   &lt;b xmlns:p="urn:ns2">
-     *     &lt;c xmlns:p="urn:ns1" p:attr="test"/>
-     *   &lt;/b>
-     * &lt;/a></pre>
-     * It only explicitly creates the namespace declarations on <tt>&lt;a></tt> and
-     * <tt>&lt;b></tt>. When adding the attribute to <tt>&lt;c></tt>, Axiom must generate
-     * a new namespace declaration because the declaration on <tt>&lt;a></tt> is masked
-     * by the one on <tt>&lt;b></tt>.
-     * <p>
-     * Note that because of WSTX-202, Axiom will not be able to serialize the resulting XML.
-     */
-    public void testAddAttributeWithMaskedNamespaceDeclaration() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "p");
-        OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "p");
-        OMElement element1 = factory.createOMElement(new QName("a"));
-        element1.declareNamespace(ns1);
-        OMElement element2 = factory.createOMElement(new QName("b"), element1);
-        element2.declareNamespace(ns2);
-        OMElement element3 = factory.createOMElement(new QName("c"), element2);
-        OMAttribute att = factory.createOMAttribute("attr", ns1, "test");
-        element3.addAttribute(att);
-        Iterator it = element3.getAllDeclaredNamespaces();
-        assertTrue(it.hasNext());
-        assertEquals(ns1, it.next());
-        assertFalse(it.hasNext());
-    }
-    
     private int getNumberOfOccurrences(String xml, String pattern) {
         int index = -1;
         int count = 0;

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java?rev=1045408&r1=1045407&r2=1045408&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTextTestBase.java Mon Dec 13 22:57:45 2010
@@ -20,11 +20,8 @@
 package org.apache.axiom.om;
 
 import javax.activation.DataHandler;
-import javax.activation.DataSource;
 
 import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
-import org.apache.axiom.testutils.activation.TestDataSource;
-import org.apache.commons.io.output.NullOutputStream;
 
 public class OMTextTestBase extends AbstractTestCase {
     static class TestDataHandlerProvider implements DataHandlerProvider {
@@ -89,25 +86,4 @@ public class OMTextTestBase extends Abst
 
         assertEquals("Text value mismatch", tempText, textNode.getText());
     }
-    
-    /**
-     * Test that when an OMText node is written to an XMLStreamWriter without MTOM support,
-     * the implementation doesn't construct an in-memory base64 representation of the complete
-     * binary content, but writes it in chunks (streaming).
-     * <p>
-     * Regression test for WSCOMMONS-433.
-     * 
-     * @throws Exception
-     */
-    public void testBase64Streaming() throws Exception {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMElement elem = factory.createOMElement("test", null);
-        // Create a data source that would eat up all memory when loaded. If the test
-        // doesn't fail with an OutOfMemoryError, we know that the OMText implementation
-        // supports streaming.
-        DataSource ds = new TestDataSource('A', Runtime.getRuntime().maxMemory());
-        OMText text = factory.createOMText(new DataHandler(ds), false);
-        elem.addChild(text);
-        elem.serialize(new NullOutputStream());
-    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml?rev=1045408&r1=1045407&r2=1045408&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/pom.xml Mon Dec 13 22:57:45 2010
@@ -47,5 +47,15 @@
             <artifactId>junit</artifactId>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>axiom-testutils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 </project>

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java?rev=1045408&r1=1045407&r2=1045408&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestCase.java Mon Dec 13 22:57:45 2010
@@ -19,10 +19,9 @@
 package org.apache.axiom.ts;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.custommonkey.xmlunit.XMLTestCase;
 
-import junit.framework.TestCase;
-
-public abstract class AxiomTestCase extends TestCase {
+public abstract class AxiomTestCase extends XMLTestCase {
     protected final OMMetaFactory metaFactory;
 
     public AxiomTestCase(OMMetaFactory metaFactory) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java?rev=1045408&r1=1045407&r2=1045408&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java Mon Dec 13 22:57:45 2010
@@ -40,6 +40,11 @@ public class AxiomTestSuiteBuilder {
     
     public TestSuite build() {
         suite = new TestSuite();
+        addTest(new org.apache.axiom.ts.om.attribute.TestGetQName(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithExistingNamespaceDeclarationInScope(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithExistingNamespaceDeclarationOnSameElement(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithMaskedNamespaceDeclaration(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithoutExistingNamespaceDeclaration(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeValueNonExisting(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeValueWithXmlPrefix1(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeValueWithXmlPrefix2(metaFactory));
@@ -47,6 +52,14 @@ public class AxiomTestSuiteBuilder {
         addTest(new org.apache.axiom.ts.om.element.TestGetAttributeWithXmlPrefix2(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetFirstChildWithName(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestSetTextQName(metaFactory));
+        addTest(new org.apache.axiom.ts.om.node.TestDetach(metaFactory, true));
+        addTest(new org.apache.axiom.ts.om.node.TestDetach(metaFactory, false));
+        addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingAfter(metaFactory));
+        addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingAfterLastChild(metaFactory));
+        addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnOrphan(metaFactory));
+        addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingBefore(metaFactory));
+        addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnOrphan(metaFactory));
+        addTest(new org.apache.axiom.ts.om.text.TestBase64Streaming(metaFactory));
         return suite;
     }
     

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetQName.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetQName.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetQName.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestGetQName.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.attribute;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMAttribute#getQName()} returns the correct value for an attribute (with
+ * namespace) created by {@link OMFactory#createOMAttribute(String, OMNamespace, String)}.
+ */
+public class TestGetQName extends AxiomTestCase {
+    public TestGetQName(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        String localName = "attr";
+        String uri = "http://ns1";
+        OMFactory fac = metaFactory.getOMFactory();
+        OMNamespace ns = fac.createOMNamespace(uri, null);
+        OMAttribute attr = fac.createOMAttribute(localName, ns, "value");
+        QName qname = attr.getQName();
+        assertEquals("Wrong namespace", uri, qname.getNamespaceURI());
+        assertEquals("Wrong localPart", localName, qname.getLocalPart());
+        assertEquals("Wrong prefix", "", qname.getPrefix());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationInScope.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationInScope.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationInScope.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationInScope.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,52 @@
+/*
+ * 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.element;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests {@link OMElement#addAttribute(OMAttribute)} doesn't create an additional namespace declaration if
+ * a corresponding declaration is already in scope.
+ */
+public class TestAddAttributeWithExistingNamespaceDeclarationInScope extends AxiomTestCase {
+    public TestAddAttributeWithExistingNamespaceDeclarationInScope(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement root = factory.createOMElement(new QName("test"));
+        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
+        root.declareNamespace(ns);
+        OMElement child = factory.createOMElement(new QName("test"), root);
+        OMAttribute att = factory.createOMAttribute("test", ns, "test");
+        child.addAttribute(att);
+        Iterator it = child.getAllDeclaredNamespaces();
+        assertFalse(it.hasNext());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationOnSameElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationOnSameElement.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationOnSameElement.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithExistingNamespaceDeclarationOnSameElement.java Mon Dec 13 22:57:45 2010
@@ -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.element;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests {@link OMElement#addAttribute(OMAttribute)} doesn't create an additional namespace
+ * declaration if a corresponding declaration already exists on the element.
+ */
+public class TestAddAttributeWithExistingNamespaceDeclarationOnSameElement extends AxiomTestCase {
+    public TestAddAttributeWithExistingNamespaceDeclarationOnSameElement(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = factory.createOMElement(new QName("test"));
+        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
+        element.declareNamespace(ns);
+        OMAttribute att = factory.createOMAttribute("test", ns, "test");
+        element.addAttribute(att);
+        Iterator it = element.getAllDeclaredNamespaces();
+        assertTrue(it.hasNext());
+        assertEquals(ns, it.next());
+        assertFalse(it.hasNext());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithMaskedNamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithMaskedNamespaceDeclaration.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithMaskedNamespaceDeclaration.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithMaskedNamespaceDeclaration.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.element;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Test checking that {@link OMElement#addAttribute(OMAttribute)} correctly generates a
+ * new namespace declaration if an equivalent namespace declaration exists but is masked.
+ * The test attempts to create the following XML:
+ * <pre>
+ * &lt;a xmlns:p="urn:ns1">
+ *   &lt;b xmlns:p="urn:ns2">
+ *     &lt;c xmlns:p="urn:ns1" p:attr="test"/>
+ *   &lt;/b>
+ * &lt;/a></pre>
+ * It only explicitly creates the namespace declarations on <tt>&lt;a></tt> and
+ * <tt>&lt;b></tt>. When adding the attribute to <tt>&lt;c></tt>, Axiom must generate
+ * a new namespace declaration because the declaration on <tt>&lt;a></tt> is masked
+ * by the one on <tt>&lt;b></tt>.
+ * <p>
+ * Note that because of WSTX-202, Axiom will not be able to serialize the resulting XML.
+ */
+public class TestAddAttributeWithMaskedNamespaceDeclaration extends AxiomTestCase {
+    public TestAddAttributeWithMaskedNamespaceDeclaration(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "p");
+        OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "p");
+        OMElement element1 = factory.createOMElement(new QName("a"));
+        element1.declareNamespace(ns1);
+        OMElement element2 = factory.createOMElement(new QName("b"), element1);
+        element2.declareNamespace(ns2);
+        OMElement element3 = factory.createOMElement(new QName("c"), element2);
+        OMAttribute att = factory.createOMAttribute("attr", ns1, "test");
+        element3.addAttribute(att);
+        Iterator it = element3.getAllDeclaredNamespaces();
+        assertTrue(it.hasNext());
+        assertEquals(ns1, it.next());
+        assertFalse(it.hasNext());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithoutExistingNamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithoutExistingNamespaceDeclaration.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithoutExistingNamespaceDeclaration.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeWithoutExistingNamespaceDeclaration.java Mon Dec 13 22:57:45 2010
@@ -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.element;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMElement#addAttribute(OMAttribute)} adds a namespace declaration if the
+ * attribute has a namespace and a corresponding namespace declaration doesn't exist yet.
+ */
+public class TestAddAttributeWithoutExistingNamespaceDeclaration extends AxiomTestCase {
+    public TestAddAttributeWithoutExistingNamespaceDeclaration(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = factory.createOMElement(new QName("test"));
+        OMNamespace ns = factory.createOMNamespace("urn:ns", "p");
+        OMAttribute att = factory.createOMAttribute("test", ns, "test");
+        element.addAttribute(att);
+        assertEquals(ns, element.findNamespace(ns.getNamespaceURI(), ns.getPrefix()));
+        Iterator it = element.getAllDeclaredNamespaces();
+        assertTrue(it.hasNext());
+        assertEquals(ns, it.next());
+        assertFalse(it.hasNext());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetach.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetach.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetach.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetach.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,58 @@
+/*
+ * 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.node;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {@link OMNode#detach()}.
+ */
+public class TestDetach extends AxiomTestCase {
+    private final boolean build;
+    
+    public TestDetach(OMMetaFactory metaFactory, boolean build) {
+        super(metaFactory);
+        this.build = build;
+        setName(getName() + " [build=" + build + "]");
+    }
+
+    protected void runTest() throws Throwable {
+        OMElement root = AXIOMUtil.stringToOM(metaFactory.getOMFactory(), "<root><a/><b/><c/></root>");
+        if (build) {
+            root.build();
+        } else {
+            assertFalse(root.isComplete());
+        }
+        OMElement a = (OMElement)root.getFirstOMChild();
+        assertEquals("a", a.getLocalName());
+        OMElement b = (OMElement)a.getNextOMSibling();
+        assertEquals("b", b.getLocalName());
+        b.detach();
+        assertNull(b.getParent());
+        OMElement c = (OMElement)a.getNextOMSibling();
+        assertEquals("c", c.getLocalName());
+        assertSame(c, a.getNextOMSibling());
+        assertSame(a, c.getPreviousOMSibling());
+        root.close(false);
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfter.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfter.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfter.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,45 @@
+/*
+ * 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.node;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {@link OMNode#insertSiblingAfter(OMNode)}.
+ */
+public class TestInsertSiblingAfter extends AxiomTestCase {
+    public TestInsertSiblingAfter(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory fac = metaFactory.getOMFactory();
+        OMElement parent = fac.createOMElement("test", null);
+        OMText text1 = fac.createOMText("text1");
+        OMText text2 = fac.createOMText("text2");
+        parent.addChild(text1);
+        text1.insertSiblingAfter(text2);
+        assertSame(parent, text2.getParent());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterLastChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterLastChild.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterLastChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterLastChild.java Mon Dec 13 22:57:45 2010
@@ -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.node;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Regression test for <a href="https://issues.apache.org/jira/browse/AXIOM-153">AXIOM-153</a>.
+ */
+public class TestInsertSiblingAfterLastChild extends AxiomTestCase {
+    public TestInsertSiblingAfterLastChild(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory fac = metaFactory.getOMFactory();
+        OMNamespace ns = fac.createOMNamespace("http://www.testuri.com","ns");
+        OMElement parent = fac.createOMElement("parent", ns);
+        
+        // Create three OMElements
+        OMElement c1 = fac.createOMElement("c1", ns);
+        OMElement c2 = fac.createOMElement("c2", ns);
+        OMElement c3 = fac.createOMElement("c3", ns);
+
+        // Add c1 to parent using parent.addChild()
+        parent.addChild(c1);
+        // Add c2 to c1 as a sibling after
+        c1.insertSiblingAfter(c2);
+        // Now add c3 to parent using parent.addChild()
+        parent.addChild(c3);
+        assertXMLEqual("<ns:parent xmlns:ns=\"http://www.testuri.com\">" +
+                "<ns:c1 /><ns:c2 /><ns:c3 /></ns:parent>", parent.toString());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterOnOrphan.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterOnOrphan.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterOnOrphan.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingAfterOnOrphan.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.node;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNode#insertSiblingBefore(OMNode)} fails if the node doesn't have a parent.
+ */
+public class TestInsertSiblingAfterOnOrphan extends AxiomTestCase {
+    public TestInsertSiblingAfterOnOrphan(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory fac = metaFactory.getOMFactory();
+        OMText text1 = fac.createOMText("text1");
+        OMText text2 = fac.createOMText("text2");
+        try {
+            text1.insertSiblingBefore(text2);
+            fail("Expected OMException because node has no parent");
+        } catch (OMException ex) {
+            // Expected
+        }
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBefore.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBefore.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBefore.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBefore.java Mon Dec 13 22:57:45 2010
@@ -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.node;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {@link OMNode#insertSiblingBefore(OMNode)}.
+ */
+public class TestInsertSiblingBefore extends AxiomTestCase {
+    public TestInsertSiblingBefore(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory fac = metaFactory.getOMFactory();
+        OMElement parent = fac.createOMElement("test", null);
+        OMText text1 = fac.createOMText("text1");
+        OMText text2 = fac.createOMText("text2");
+        parent.addChild(text1);
+        text1.insertSiblingBefore(text2);
+        assertSame(parent, text2.getParent());
+        assertSame(text2, parent.getFirstOMChild());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBeforeOnOrphan.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBeforeOnOrphan.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBeforeOnOrphan.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestInsertSiblingBeforeOnOrphan.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.node;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests that {@link OMNode#insertSiblingAfter(OMNode)} fails if the node doesn't have a parent.
+ */
+public class TestInsertSiblingBeforeOnOrphan extends AxiomTestCase {
+    public TestInsertSiblingBeforeOnOrphan(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory fac = metaFactory.getOMFactory();
+        OMText text1 = fac.createOMText("text1");
+        OMText text2 = fac.createOMText("text2");
+        try {
+            text1.insertSiblingAfter(text2);
+            fail("Expected OMException because node has no parent");
+        } catch (OMException ex) {
+            // Expected
+        }
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestBase64Streaming.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestBase64Streaming.java?rev=1045408&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestBase64Streaming.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestBase64Streaming.java Mon Dec 13 22:57:45 2010
@@ -0,0 +1,55 @@
+/*
+ * 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.text;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.testutils.activation.TestDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.commons.io.output.NullOutputStream;
+
+/**
+ * Test that when an {@link OMText} node is written to an XMLStreamWriter without MTOM support, the
+ * implementation doesn't construct an in-memory base64 representation of the complete binary
+ * content, but writes it in chunks (streaming).
+ * <p>
+ * Regression test for <a href="https://issues.apache.org/jira/browse/AXIOM-236">AXIOM-236</a>.
+ */
+public class TestBase64Streaming extends AxiomTestCase {
+    public TestBase64Streaming(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement elem = factory.createOMElement("test", null);
+        // Create a data source that would eat up all memory when loaded. If the test
+        // doesn't fail with an OutOfMemoryError, we know that the OMText implementation
+        // supports streaming.
+        DataSource ds = new TestDataSource('A', Runtime.getRuntime().maxMemory());
+        OMText text = factory.createOMText(new DataHandler(ds), false);
+        elem.addChild(text);
+        elem.serialize(new NullOutputStream());
+    }
+}

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



Mime
View raw message