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 2013/01/27 18:36:06 UTC

svn commit: r1439125 - in /webservices/axiom/trunk/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/org...

Author: veithen
Date: Sun Jan 27 17:36:06 2013
New Revision: 1439125

URL: http://svn.apache.org/viewvc?rev=1439125&view=rev
Log:
Added a hasName(QName) method to OMElement and OMAttribute.

Added:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithNamespace.java   (with props)
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithoutNamespace.java   (with props)
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithNamespace.java   (with props)
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithoutNamespace.java   (with props)
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestHasName.java   (with props)
Modified:
    webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/StAXSerializer.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java

Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNamedInformationItem.java Sun Jan 27 17:36:06 2013
@@ -55,6 +55,9 @@ public interface OMNamedInformationItem 
 
     /**
      * Get the QName of this information item.
+     * <p>
+     * Note that if you simply need to check if the information item has a given QName, then you
+     * should use {@link #hasName(QName)} instead of this method.
      * 
      * @return the {@link QName} for the information item
      */
@@ -79,4 +82,21 @@ public interface OMNamedInformationItem 
      *         item has no namespace
      */
     String getNamespaceURI();
+    
+    /**
+     * Determine if this information item has the given name. Note that only the namespace URI and
+     * local part will be compared, the prefix is ignored.
+     * <p>
+     * The result of the expression <code>node.hasName(name)</code> is the same as
+     * <code>node.getQName().equals(name)</code>. However, the former expression is generally more
+     * efficient than the latter because it avoids the creation of the {@link QName} object. In
+     * addition, for an {@link OMSourcedElement} it avoids the expansion of the element if the
+     * prefix is unknown.
+     * 
+     * @param name
+     *            the QName to compare with the QName of this information item
+     * @return <code>true</code> if the information item has the given name, <code>false</code>
+     *         otherwise
+     */
+    boolean hasName(QName name);
 }

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/StAXSerializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/StAXSerializer.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/StAXSerializer.java (original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/StAXSerializer.java Sun Jan 27 17:36:06 2013
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
@@ -38,8 +39,7 @@ import java.util.Iterator;
 public class StAXSerializer {
     private static final Log log = LogFactory.getLog(StAXSerializer.class);
     
-    private static final String XSI_URI = "http://www.w3.org/2001/XMLSchema-instance";
-    private static final String XSI_LOCAL_NAME = "type";
+    private static final QName XSI_TYPE = new QName("http://www.w3.org/2001/XMLSchema-instance", "type");
     
     private final XMLStreamWriter writer;
     private final ArrayList writePrefixList = new ArrayList();
@@ -139,11 +139,7 @@ public class StAXSerializer {
         attrs = element.getAllAttributes();
         while (attrs.hasNext()) {
             OMAttribute attr = (OMAttribute) attrs.next();
-            String namespace = attr.getNamespaceURI();
-            String local = attr.getLocalName();
-
-            if (XSI_URI.equals(namespace) &&
-                    XSI_LOCAL_NAME.equals(local)) {
+            if (attr.hasName(XSI_TYPE)) {
                 String value = attr.getAttributeValue();
                 if (log.isDebugEnabled()) {
                     log.debug("The value of xsi:type is " + value);

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Sun Jan 27 17:36:06 2013
@@ -278,6 +278,12 @@ public class AttrImpl extends RootNode i
 
     }
 
+    public boolean hasName(QName name) {
+        return name.getLocalPart().equals(localName)
+                && (namespace == null && name.getNamespaceURI().length() == 0
+                 || namespace != null && name.getNamespaceURI().equals(namespace.getNamespaceURI()));
+    }
+
     public String getAttributeValue() {
         return getValue();
     }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Sun Jan 27 17:36:06 2013
@@ -800,6 +800,12 @@ public class ElementImpl extends ParentN
         return qName;
     }
 
+    public boolean hasName(QName name) {
+        return name.getLocalPart().equals(localName)
+                && (namespace == null && name.getNamespaceURI().length() == 0
+                 || namespace != null && name.getNamespaceURI().equals(namespace.getNamespaceURI()));
+    }
+
     public String getText() {
         return OMElementHelper.getText(this);
     }

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java Sun Jan 27 17:36:06 2013
@@ -104,6 +104,12 @@ public class OMAttributeImpl implements 
         return this.qName;
     }
 
+    public boolean hasName(QName name) {
+        return name.getLocalPart().equals(localName)
+                && (namespace == null && name.getNamespaceURI().length() == 0
+                 || namespace != null && name.getNamespaceURI().equals(namespace.getNamespaceURI()));
+    }
+
     // -------- Getters and Setters
 
     /**

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Sun Jan 27 17:36:06 2013
@@ -884,6 +884,16 @@ public class OMElementImpl extends OMNod
         }
         return qName;
     }
+    
+    public boolean hasName(QName name) {
+        if (name.getLocalPart().equals(getLocalName())) {
+            OMNamespace ns = getNamespace();
+            return ns == null && name.getNamespaceURI().length() == 0
+                    || ns != null && name.getNamespaceURI().equals(ns.getNamespaceURI());
+        } else {
+            return false;
+        }
+    }
 
     public String toStringWithConsume() throws XMLStreamException {
         StringWriter writer = new StringWriter();

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Sun Jan 27 17:36:06 2013
@@ -609,6 +609,10 @@ public class OMSourcedElementImpl extend
         }
     }
 
+    public boolean hasName(QName name) {
+        return super.hasName(name);
+    }
+
     public String toStringWithConsume() throws XMLStreamException {
         if (isExpanded()) {
             return super.toStringWithConsume();

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1439125&r1=1439124&r2=1439125&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Sun Jan 27 17:36:06 2013
@@ -82,6 +82,8 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.attribute.TestGetPrefixWithoutNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.attribute.TestGetQNameWithNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.attribute.TestGetQNameWithoutNamespace(metaFactory));
+        addTest(new org.apache.axiom.ts.om.attribute.TestHasNameWithNamespace(metaFactory));
+        addTest(new org.apache.axiom.ts.om.attribute.TestHasNameWithoutNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.attribute.TestSetLocalName(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestCloseWithInputStream(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestCloseWithReader(metaFactory));
@@ -299,6 +301,8 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithoutCachingPartiallyBuilt(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithoutCachingPartiallyBuiltModified(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithPreserveNamespaceContext(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestHasNameWithNamespace(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestHasNameWithoutNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestMultipleDefaultNS(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestRemoveAttribute(metaFactory));
@@ -439,6 +443,7 @@ public class OMTestSuiteBuilder extends 
                     addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespace(metaFactory, variant, qname));
                     addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetPrefix(metaFactory, variant, qname));
                     addTest(new org.apache.axiom.ts.om.sourcedelement.TestGetNamespaceURI(metaFactory, variant, qname));
+                    addTest(new org.apache.axiom.ts.om.sourcedelement.TestHasName(metaFactory, variant, qname));
                 }
             }
             addTest(new org.apache.axiom.ts.om.sourcedelement.TestByteArrayDS(metaFactory));

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithNamespace.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithNamespace.java?rev=1439125&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithNamespace.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithNamespace.java Sun Jan 27 17:36:06 2013
@@ -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#hasName(QName)} returns the correct value for an attribute (with
+ * namespace) created by {@link OMFactory#createOMAttribute(String, OMNamespace, String)}.
+ */
+public class TestHasNameWithNamespace extends AxiomTestCase {
+    public TestHasNameWithNamespace(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        String localName = "attr";
+        String uri = "urn:test";
+        OMFactory fac = metaFactory.getOMFactory();
+        OMNamespace ns = fac.createOMNamespace(uri, "p");
+        OMAttribute attr = fac.createOMAttribute(localName, ns, "value");
+        assertTrue(attr.hasName(new QName(uri, localName, "p")));
+        assertTrue(attr.hasName(new QName(uri, localName, "q")));
+        assertFalse(attr.hasName(new QName("http://example.org", localName, "p")));
+        assertFalse(attr.hasName(new QName(uri, "otherName", "p")));
+    }
+}

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

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithoutNamespace.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithoutNamespace.java?rev=1439125&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithoutNamespace.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestHasNameWithoutNamespace.java Sun Jan 27 17:36:06 2013
@@ -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.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#hasName(QName)} returns the correct value for an attribute (without
+ * namespace) created by {@link OMFactory#createOMAttribute(String, OMNamespace, String)}.
+ */
+public class TestHasNameWithoutNamespace extends AxiomTestCase {
+    public TestHasNameWithoutNamespace(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMAttribute attr = metaFactory.getOMFactory().createOMAttribute("name", null, "value");
+        assertTrue(attr.hasName(new QName("name")));
+        assertFalse(attr.hasName(new QName("urn:test", "name")));
+    }
+}

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

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithNamespace.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithNamespace.java?rev=1439125&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithNamespace.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithNamespace.java Sun Jan 27 17:36:06 2013
@@ -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.element;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+
+import javax.xml.namespace.QName;
+
+public class TestHasNameWithNamespace extends AxiomTestCase {
+    public TestHasNameWithNamespace(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        String localName = "TestLocalName";
+        String namespace = "http://ws.apache.org/axis2/ns";
+        String prefix = "axis2";
+        OMElement element = factory.createOMElement(localName, namespace, prefix);
+        assertTrue(element.hasName(new QName(namespace, localName, prefix)));
+        assertTrue(element.hasName(new QName(namespace, localName, "otherPrefix")));
+        assertFalse(element.hasName(new QName("http://some.other.org/", localName, prefix)));
+        assertFalse(element.hasName(new QName(namespace, "otherName", prefix)));
+    }
+}

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

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithoutNamespace.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithoutNamespace.java?rev=1439125&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithoutNamespace.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestHasNameWithoutNamespace.java Sun Jan 27 17:36:06 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.OMMetaFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestHasNameWithoutNamespace extends AxiomTestCase {
+    public TestHasNameWithoutNamespace(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMElement element = metaFactory.getOMFactory().createOMElement("name", null);
+        assertTrue(element.hasName(new QName("name")));
+        assertFalse(element.hasName(new QName("urn:test", "name")));
+    }
+}

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

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestHasName.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestHasName.java?rev=1439125&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestHasName.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestHasName.java Sun Jan 27 17:36:06 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.sourcedelement;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+
+public class TestHasName extends LazyNameTestCase {
+    public TestHasName(OMMetaFactory metaFactory, OMSourcedElementVariant variant, QName qname) {
+        super(metaFactory, variant, qname);
+    }
+
+    protected void runTest(OMSourcedElement element) throws Throwable {
+        assertTrue(element.hasName(qname));
+        assertFalse(element.hasName(new QName("urn:other", "other")));
+        if (variant.isLocalNameRequiresExpansion() || variant.isNamespaceURIRequiresExpansion()) {
+            assertTrue(element.isExpanded());
+        } else {
+            assertFalse(element.isExpanded());
+        }
+    }
+}

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