Author: veithen
Date: Mon Dec 13 20:14:27 2010
New Revision: 1045356
URL: http://svn.apache.org/viewvc?rev=1045356&view=rev
Log:
A couple of new test cases and Javadoc improvements.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAttributeValueNonExisting.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetFirstChildWithName.java
(with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.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/main/java/org/apache/axiom/om/OMContainer.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=1045356&r1=1045355&r2=1045356&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
Mon Dec 13 20:14:27 2010
@@ -72,17 +72,18 @@ public interface OMContainer extends OMS
/**
- * Returns the first child in document order that matches the given QName
- * <p/>
- * <p>The QName filter is applied as in the function {...@link
#getChildrenWithName}.</p>
- *
- * @param elementQName The QName to use for matching.
- * @return Returns the first element in document order that matches the
<tt>elementQName</tt>
- * criteria.
- * @throws OMException Could indirectly trigger building of child nodes.
- * @see #getChildrenWithName
+ * Returns the first child in document order that matches the given QName.
The QName filter is
+ * applied in the same way as by the {...@link
#getChildrenWithName(QName)} method.
+ *
+ * @param qname
+ * The QName to use for matching.
+ * @return The first child element in document order that matches the
<code>qname</code>
+ * criteria, or <code>null</code> if none is found.
+ * @throws OMException
+ * If an error occurs during deferred parsing.
+ * @see #getChildrenWithName(QName)
*/
- OMElement getFirstChildWithName(QName elementQName) throws OMException;
+ OMElement getFirstChildWithName(QName qname) throws OMException;
/**
* Returns an iterator for the children of the container.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1045356&r1=1045355&r2=1045356&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
Mon Dec 13 20:14:27 2010
@@ -194,9 +194,10 @@ public interface OMElement extends OMNod
/**
* Returns a named attribute's value, if present.
- *
- * @param qname the qualified name to search for
- * @return Returns a String containing the attribute value, or null
+ *
+ * @param qname
+ * the qualified name to search for
+ * @return The attribute value, or <code>null</code> if no matching
attribute is found.
*/
String getAttributeValue(QName qname);
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=1045356&r1=1045355&r2=1045356&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 20:14:27 2010
@@ -40,10 +40,12 @@ public class AxiomTestSuiteBuilder {
public TestSuite build() {
suite = new TestSuite();
+ 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));
addTest(new
org.apache.axiom.ts.om.element.TestGetAttributeWithXmlPrefix1(metaFactory));
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));
return suite;
}
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAttributeValueNonExisting.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAttributeValueNonExisting.java?rev=1045356&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAttributeValueNonExisting.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAttributeValueNonExisting.java
Mon Dec 13 20:14:27 2010
@@ -0,0 +1,43 @@
+/*
+ * 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.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {...@link OMElement#getAttributeValue(QName)} if the
element has no attribute
+ * with the given QName.
+ */
+public class TestGetAttributeValueNonExisting extends AxiomTestCase {
+ public TestGetAttributeValueNonExisting(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMElement element = factory.createOMElement("test", null);
+ element.addAttribute("attr", "value", null);
+ assertNull(element.getAttributeValue(new QName("urn:ns", "attr2")));
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetAttributeValueNonExisting.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetFirstChildWithName.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetFirstChildWithName.java?rev=1045356&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetFirstChildWithName.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetFirstChildWithName.java
Mon Dec 13 20:14:27 2010
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+/**
+ * Tests the behavior of {...@link OMElement#getFirstChildWithName(QName)}.
+ */
+public class TestGetFirstChildWithName extends AxiomTestCase {
+ public TestGetFirstChildWithName(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "ns1");
+ OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "ns2");
+ OMElement parent = factory.createOMElement("root", null);
+ OMElement child1 = factory.createOMElement("a", ns1, parent);
+ factory.createOMComment(parent, "some comment");
+ OMElement child2 = factory.createOMElement("b", ns2, parent);
+ OMElement child3 = factory.createOMElement("b", ns1, parent);
+ OMElement child4 = factory.createOMElement("c", null, parent);
+ factory.createOMElement("a", ns1, parent);
+
+ // Check that it's really the first element that is returned
+ assertSame(child1, parent.getFirstChildWithName(new QName("urn:ns1",
"a")));
+
+ // Test with a child that is not the first one
+ assertSame(child2, parent.getFirstChildWithName(new QName("urn:ns2",
"b")));
+
+ // Check that the namespace URI is taken into account
+ assertNull(parent.getFirstChildWithName(new QName("b")));
+
+ // Check that the prefix of the given QName is not taken into account
+ assertSame(child3, parent.getFirstChildWithName(new QName("urn:ns1",
"b", "ns2")));
+
+ // Test with null namespace
+ assertSame(child4, parent.getFirstChildWithName(new QName("c")));
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetFirstChildWithName.java
------------------------------------------------------------------------------
svn:eol-style = native