Author: veithen
Date: Thu Jun 11 21:36:58 2015
New Revision: 1684977

URL: http://svn.apache.org/r1684977
Log:
Fix an issue in the Attr#getNamespaceURI() implementation.

Added:
    
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestGetNamespaceURIWithNoNamespace.java
   (with props)
Modified:
    
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
    
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java

Modified: 
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1684977&r1=1684976&r2=1684977&view=diff
==============================================================================
--- 
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
 (original)
+++ 
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
 Thu Jun 11 21:36:58 2015
@@ -279,7 +279,12 @@ public class AttrImpl extends RootNode i
      */
     public String getNamespaceURI() {
         OMNamespace namespace = getNamespace();
-        return namespace != null ? namespace.getNamespaceURI() : null;
+        if (namespace == null) {
+            return null;
+        } else {
+            String namespaceURI = namespace.getNamespaceURI();
+            return namespaceURI.length() == 0 ? null : namespaceURI;
+        }
     }
 
     /*

Modified: 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1684977&r1=1684976&r2=1684977&view=diff
==============================================================================
--- 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
 (original)
+++ 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
 Thu Jun 11 21:36:58 2015
@@ -71,6 +71,7 @@ public final class DOMTestSuiteBuilder e
         addTest(new org.apache.axiom.ts.dom.attr.TestCloneNode(dbf, false));
         addTest(new org.apache.axiom.ts.dom.attr.TestGetChildNodes(dbf));
         addTest(new org.apache.axiom.ts.dom.attr.TestGetFirstChild(dbf));
+        addTest(new 
org.apache.axiom.ts.dom.attr.TestGetNamespaceURIWithNoNamespace(dbf));
         addTest(new 
org.apache.axiom.ts.dom.attr.TestGetValueWithMultipleChildren(dbf));
         addTest(new 
org.apache.axiom.ts.dom.attr.TestLookupNamespaceURIWithoutOwnerElement(dbf));
         addTest(new 
org.apache.axiom.ts.dom.attr.TestSetPrefixNotNullWithNamespace(dbf));

Added: 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestGetNamespaceURIWithNoNamespace.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestGetNamespaceURIWithNoNamespace.java?rev=1684977&view=auto
==============================================================================
--- 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestGetNamespaceURIWithNoNamespace.java
 (added)
+++ 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestGetNamespaceURIWithNoNamespace.java
 Thu Jun 11 21:36:58 2015
@@ -0,0 +1,41 @@
+/*
+ * 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.dom.attr;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+
+public class TestGetNamespaceURIWithNoNamespace extends DOMTestCase {
+    public TestGetNamespaceURIWithNoNamespace(DocumentBuilderFactory dbf) {
+        super(dbf);
+    }
+
+    protected void runTest() throws Throwable {
+        Document doc = dbf.newDocumentBuilder().newDocument();
+        Attr attr = doc.createAttributeNS(null, "test");
+        assertThat(attr.getNamespaceURI()).isNull();
+        attr = doc.createAttributeNS("", "test");
+        assertThat(attr.getNamespaceURI()).isNull();
+    }
+}

Propchange: 
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestGetNamespaceURIWithNoNamespace.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to