ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1145742 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ axiom-tests/src/test/java/org/apache/axiom/om/impl/traverse/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-test...
Date Tue, 12 Jul 2011 19:54:47 GMT
Author: veithen
Date: Tue Jul 12 19:54:47 2011
New Revision: 1145742

URL: http://svn.apache.org/viewvc?rev=1145742&view=rev
Log:
AXIOM-311: Refactored OMChildrenWithQNameIteratorTest.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName2.java
  (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName3.java
  (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName4.java
  (with props)
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/traverse/OMChildrenWithQNameIteratorTest.java
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
    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/OMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1145742&r1=1145741&r2=1145742&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
Tue Jul 12 19:54:47 2011
@@ -25,6 +25,7 @@ import org.apache.axiom.om.impl.dom.fact
 import org.apache.axiom.ts.OMTestSuiteBuilder;
 import org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOMSource;
 import org.apache.axiom.ts.om.container.TestSerialize;
+import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
 import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement;
 import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
 import org.apache.axiom.ts.om.element.TestSetTextQName;
@@ -72,6 +73,9 @@ public class OMImplementationTest extend
         // TODO: suspecting Woodstox bug here
         builder.exclude(TestCreateOMBuilderFromDOMSource.class, "(file=spaces.xml)");
         
+        // TODO: investigate why this is not working with DOOM
+        builder.exclude(TestGetChildrenWithName4.class);
+        
         return builder.build();
     }
 }

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=1145742&r1=1145741&r2=1145742&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
Tue Jul 12 19:54:47 2011
@@ -20,6 +20,7 @@ package org.apache.axiom.ts;
 
 import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.Iterator;
 
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMMetaFactory;
@@ -55,4 +56,14 @@ public abstract class AxiomTestCase exte
         }
         assertTrue(isConsumed);
     }
+
+    protected static int getChildrenCount(Iterator childrenIter) {
+        int childCount = 0;
+        while (childrenIter.hasNext()) {
+            childrenIter.next();
+            childCount++;
+        }
+
+        return childCount;
+    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1145742&r1=1145741&r2=1145742&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
Tue Jul 12 19:54:47 2011
@@ -95,6 +95,9 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestGetChildrenRemove4(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithLocalName(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithName(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithName2(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithName3(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithName4(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetFirstChildWithName(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetFirstChildWithNameOnIncompleteElement(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetNamespaceURI(metaFactory));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName2.java?rev=1145742&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName2.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName2.java
Tue Jul 12 19:54:47 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetChildrenWithName2 extends AxiomTestCase {
+    public TestGetChildrenWithName2(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMNamespace testNamespace = factory.createOMNamespace("http://test.ws.org", "test");
+        OMElement documentElement = factory.createOMElement("Employees", testNamespace);
+        documentElement.declareNamespace(testNamespace);
+        OMText txt = factory.createOMText(documentElement, " ");
+        OMElement e = factory.createOMElement("Employee", testNamespace, documentElement);
+        e.setText("Apache Developer");
+
+        Iterator childrenIter = documentElement.getChildrenWithName(new QName("http://test.ws.org",
"Employee", "test"));
+
+        int childCount = getChildrenCount(childrenIter);
+        assertEquals("Iterator must return 1 child with the given qname", childCount, 1);
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName3.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName3.java?rev=1145742&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName3.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName3.java
Tue Jul 12 19:54:47 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.element;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+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.om.OMText;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Regression test for <a href="https://issues.apache.org/jira/browse/AXIOM-166">AXIOM-166</a>.
+ */
+public class TestGetChildrenWithName3 extends AxiomTestCase {
+    public TestGetChildrenWithName3(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMNamespace testNamespace = factory.createOMNamespace("http://test.ws.org", "test");
+        OMElement documentElement = factory.createOMElement("Employees", testNamespace);
+        documentElement.declareNamespace(testNamespace);
+        OMText txt = factory.createOMText(documentElement, " ");
+        OMElement e = factory.createOMElement("Employee", testNamespace, documentElement);
+        e.setText("Apache Developer");
+
+        Iterator childrenIter = documentElement.getChildrenWithName(new QName("http://test.ws.org",
"Employee", "test"));
+        OMElement employee = (OMElement) childrenIter.next(); // should walk past OMText
+        assertEquals("Employee test was incorrect", employee.getText(), "Apache Developer");
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName4.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName4.java?rev=1145742&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName4.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildrenWithName4.java
Tue Jul 12 19:54:47 2011
@@ -0,0 +1,82 @@
+/*
+ * 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.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;
+
+public class TestGetChildrenWithName4 extends AxiomTestCase {
+    private static final String NS_A = "urn://a";
+    private static final String NS_B = "urn://b";
+    private static final String NS_C = "urn://c";
+    
+    public TestGetChildrenWithName4(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        // Create a document with 2 children, each named "sample" but
+        // have different namespaces.
+        OMFactory factory = metaFactory.getOMFactory();
+        OMNamespace a = factory.createOMNamespace(NS_A, "a");
+        OMNamespace b = factory.createOMNamespace(NS_B, "b");
+        
+        OMElement documentElement = factory.createOMElement("Document", a);
+        factory.createOMElement("sample", a, documentElement);
+        factory.createOMElement("sample", b, documentElement);
+        
+        
+        // Test for fully qualified names
+        QName qName = new QName(NS_A, "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 1);
+        qName = new QName(NS_B, "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 1);
+        qName = new QName(NS_C, "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 0);
+        
+        // Test for QName with no namespace.
+        // The original Axiom implementation interpretted this as a wildcard.
+        // In order to not break existing code, this should return 2
+        qName = new QName("", "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 2);
+        
+        // Now add an unqualified sample element to the documentElement
+        factory.createOMElement("sample", null, documentElement);
+        
+        
+        // Repeat the tests
+        qName = new QName(NS_A, "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 1);
+        qName = new QName(NS_B, "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 1);
+        qName = new QName(NS_C, "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 0);
+       
+        // Since there actually is an unqualified element child, the most accurate
+        // interpretation of getChildrenWithName should be to return this one 
+        // child
+        qName = new QName("", "sample");
+        assertTrue(getChildrenCount(documentElement.getChildrenWithName(qName)) == 1);
+    }
+}

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



Mime
View raw message