You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/01/10 22:14:37 UTC

svn commit: r1057366 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/test/java/org/apache/axiom/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/

Author: veithen
Date: Mon Jan 10 21:14:37 2011
New Revision: 1057366

URL: http://svn.apache.org/viewvc?rev=1057366&view=rev
Log:
Refactored a couple of unit tests from OMElementTestBase into the new test suite.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByElement.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByOtherElement.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace1.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace2.java   (with props)
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-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=1057366&r1=1057365&r2=1057366&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 Jan 10 21:14:37 2011
@@ -98,82 +98,6 @@ public abstract class OMElementTestBase 
         root.close(false);
     }
     
-    /**
-     * Test that calling {@link OMElement#addAttribute(OMAttribute)} with an attribute that is
-     * already owned by another element will clone the attribute.
-     */
-    public void testAddAttributeAlreadyOwnedByOtherElement() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMElement element1 = factory.createOMElement(new QName("test"));
-        OMElement element2 = factory.createOMElement(new QName("test"));
-        OMAttribute att1 = element1.addAttribute("test", "test", null);
-        OMAttribute att2 = element2.addAttribute(att1);
-        assertSame(element1, att1.getOwner());
-        assertNotSame(att1, att2);
-        assertSame(element2, att2.getOwner());
-    }
-    
-    /**
-     * Test that calling {@link OMElement#addAttribute(OMAttribute)} with an attribute that is
-     * already owned by the element is a no-op.
-     */
-    public void testAddAttributeAlreadyOwnedByElement() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        OMElement element = factory.createOMElement(new QName("test"));
-        OMAttribute att = element.addAttribute("test", "test", null);
-        OMAttribute result = element.addAttribute(att);
-        assertSame(result, att);
-        assertSame(element, att.getOwner());
-        Iterator it = element.getAllAttributes();
-        assertTrue(it.hasNext());
-        assertSame(att, it.next());
-        assertFalse(it.hasNext());
-    }
-    
-    /**
-     * Test that {@link OMElement#addAttribute(OMAttribute)} behaves correctly when an attribute
-     * with the same name and namespace URI already exists.
-     */
-    public void testAddAttributeReplace1() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        // Use same namespace URI but different prefixes
-        OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
-        OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
-        OMElement element = factory.createOMElement(new QName("test"));
-        OMAttribute att1 = factory.createOMAttribute("test", ns1, "test");
-        OMAttribute att2 = factory.createOMAttribute("test", ns2, "test");
-        element.addAttribute(att1);
-        element.addAttribute(att2);
-        Iterator it = element.getAllAttributes();
-        assertTrue(it.hasNext());
-        assertSame(att2, it.next());
-        assertFalse(it.hasNext());
-        assertNull(att1.getOwner());
-        assertSame(element, att2.getOwner());
-    }
-    
-    /**
-     * Test that {@link OMElement#addAttribute(String, String, OMNamespace)} behaves correctly when
-     * an attribute with the same name and namespace URI already exists.
-     */
-    public void testAddAttributeReplace2() {
-        OMFactory factory = omMetaFactory.getOMFactory();
-        // Use same namespace URI but different prefixes
-        OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
-        OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
-        OMElement element = factory.createOMElement(new QName("test"));
-        OMAttribute att1 = element.addAttribute("test", "value1", ns1);
-        OMAttribute att2 = element.addAttribute("test", "value2", ns2);
-        Iterator it = element.getAllAttributes();
-        assertTrue(it.hasNext());
-        assertSame(att2, it.next());
-        assertFalse(it.hasNext());
-        assertNull(att1.getOwner());
-        assertSame(element, att2.getOwner());
-        assertEquals("value1", att1.getAttributeValue());
-        assertEquals("value2", att2.getAttributeValue());
-    }
-    
     private int getNumberOfOccurrences(String xml, String pattern) {
         int index = -1;
         int count = 0;

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=1057366&r1=1057365&r2=1057366&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 Jan 10 21:14:37 2011
@@ -53,6 +53,10 @@ public class AxiomTestSuiteBuilder {
         addTest(new org.apache.axiom.ts.om.document.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
         addTest(new org.apache.axiom.ts.om.document.TestSerializeAndConsume(metaFactory));
         addTest(new org.apache.axiom.ts.om.document.TestSerializeAndConsumeWithIncompleteDescendant(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeAlreadyOwnedByElement(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeAlreadyOwnedByOtherElement(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeReplace1(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestAddAttributeReplace2(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));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByElement.java?rev=1057366&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByElement.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByElement.java Mon Jan 10 21:14:37 2011
@@ -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.ts.AxiomTestCase;
+
+/**
+ * Test that calling {@link OMElement#addAttribute(OMAttribute)} with an attribute that is already
+ * owned by the element is a no-op.
+ */
+public class TestAddAttributeAlreadyOwnedByElement extends AxiomTestCase {
+    public TestAddAttributeAlreadyOwnedByElement(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element = factory.createOMElement(new QName("test"));
+        OMAttribute att = element.addAttribute("test", "test", null);
+        OMAttribute result = element.addAttribute(att);
+        assertSame(result, att);
+        assertSame(element, att.getOwner());
+        Iterator it = element.getAllAttributes();
+        assertTrue(it.hasNext());
+        assertSame(att, it.next());
+        assertFalse(it.hasNext());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByOtherElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByOtherElement.java?rev=1057366&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByOtherElement.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeAlreadyOwnedByOtherElement.java Mon Jan 10 21:14:37 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.element;
+
+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.ts.AxiomTestCase;
+
+/**
+ * Test that calling {@link OMElement#addAttribute(OMAttribute)} with an attribute that is already
+ * owned by another element will clone the attribute.
+ */
+public class TestAddAttributeAlreadyOwnedByOtherElement extends AxiomTestCase {
+    public TestAddAttributeAlreadyOwnedByOtherElement(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement element1 = factory.createOMElement(new QName("test"));
+        OMElement element2 = factory.createOMElement(new QName("test"));
+        OMAttribute att1 = element1.addAttribute("test", "test", null);
+        OMAttribute att2 = element2.addAttribute(att1);
+        assertSame(element1, att1.getOwner());
+        assertNotSame(att1, att2);
+        assertSame(element2, att2.getOwner());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace1.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace1.java?rev=1057366&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace1.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace1.java Mon Jan 10 21:14:37 2011
@@ -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.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 that {@link OMElement#addAttribute(OMAttribute)} behaves correctly when an attribute with
+ * the same name and namespace URI already exists.
+ */
+public class TestAddAttributeReplace1 extends AxiomTestCase {
+    public TestAddAttributeReplace1(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        // Use same namespace URI but different prefixes
+        OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
+        OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
+        OMElement element = factory.createOMElement(new QName("test"));
+        OMAttribute att1 = factory.createOMAttribute("test", ns1, "test");
+        OMAttribute att2 = factory.createOMAttribute("test", ns2, "test");
+        element.addAttribute(att1);
+        element.addAttribute(att2);
+        Iterator it = element.getAllAttributes();
+        assertTrue(it.hasNext());
+        assertSame(att2, it.next());
+        assertFalse(it.hasNext());
+        assertNull(att1.getOwner());
+        assertSame(element, att2.getOwner());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace2.java?rev=1057366&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace2.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestAddAttributeReplace2.java Mon Jan 10 21:14:37 2011
@@ -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.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 that {@link OMElement#addAttribute(String, String, OMNamespace)} behaves correctly when an
+ * attribute with the same name and namespace URI already exists.
+ */
+public class TestAddAttributeReplace2 extends AxiomTestCase {
+    public TestAddAttributeReplace2(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        // Use same namespace URI but different prefixes
+        OMNamespace ns1 = factory.createOMNamespace("urn:ns", "p1");
+        OMNamespace ns2 = factory.createOMNamespace("urn:ns", "p2");
+        OMElement element = factory.createOMElement(new QName("test"));
+        OMAttribute att1 = element.addAttribute("test", "value1", ns1);
+        OMAttribute att2 = element.addAttribute("test", "value2", ns2);
+        Iterator it = element.getAllAttributes();
+        assertTrue(it.hasNext());
+        assertSame(att2, it.next());
+        assertFalse(it.hasNext());
+        assertNull(att1.getOwner());
+        assertSame(element, att2.getOwner());
+        assertEquals("value1", att1.getAttributeValue());
+        assertEquals("value2", att2.getAttributeValue());
+    }
+}

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