ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1379927 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/ axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
Date Sun, 02 Sep 2012 08:40:49 GMT
Author: veithen
Date: Sun Sep  2 08:40:49 2012
New Revision: 1379927

URL: http://svn.apache.org/viewvc?rev=1379927&view=rev
Log:
AXIOM-423: Fixed a NullPointerException.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestLookupNamespaceURIWithoutOwnerElement.java
  (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1379927&r1=1379926&r2=1379927&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
Sun Sep  2 08:40:49 2012
@@ -39,6 +39,7 @@ public class DOMTestSuiteBuilder extends
         addTest(new org.apache.axiom.ts.dom.attr.TestGetFirstChild(dbf));
         addTest(new org.apache.axiom.ts.dom.attr.TestGetValueWithMultipleChildren(dbf));
         addTest(new org.apache.axiom.ts.dom.attr.TestLookupNamespaceURI(dbf));
+        addTest(new org.apache.axiom.ts.dom.attr.TestLookupNamespaceURIWithoutOwnerElement(dbf));
         addTest(new org.apache.axiom.ts.dom.attr.TestSetPrefixNotNullWithNamespace(dbf));
         addTest(new org.apache.axiom.ts.dom.attr.TestSetPrefixNotNullWithoutNamespace(dbf));
         addTest(new org.apache.axiom.ts.dom.builder.TestParseURI(dbf));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestLookupNamespaceURIWithoutOwnerElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestLookupNamespaceURIWithoutOwnerElement.java?rev=1379927&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestLookupNamespaceURIWithoutOwnerElement.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/attr/TestLookupNamespaceURIWithoutOwnerElement.java
Sun Sep  2 08:40:49 2012
@@ -0,0 +1,42 @@
+/*
+ * 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 javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Tests the behavior of {@link Node#lookupNamespaceURI(String)} on an attribute node that
has no
+ * owner element.
+ */
+public class TestLookupNamespaceURIWithoutOwnerElement extends DOMTestCase {
+    public TestLookupNamespaceURIWithoutOwnerElement(DocumentBuilderFactory dbf) {
+        super(dbf);
+    }
+
+    protected void runTest() throws Throwable {
+        Document document = dbf.newDocumentBuilder().newDocument();
+        Attr attr = document.createAttributeNS("urn:test", "p:attr");
+        assertNull(attr.lookupNamespaceURI("p"));
+    }
+}

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

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1379927&r1=1379926&r2=1379927&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Sun Sep  2 08:40:49 2012
@@ -309,12 +309,8 @@ public abstract class NodeImpl implement
             // type is unknown
             return null;
         case Node.ATTRIBUTE_NODE: {
-            NodeImpl ownerNode = (NodeImpl) ((Attr) this).getOwnerElement();
-            if (ownerNode.getNodeType() == Node.ELEMENT_NODE) {
-                return ownerNode.lookupNamespaceURI(specifiedPrefix);
-
-            }
-            return null;
+            Element ownerElement = ((Attr) this).getOwnerElement();
+            return ownerElement == null ? null : ownerElement.lookupNamespaceURI(specifiedPrefix);
         }
         default: {
             NodeImpl ancestor = (NodeImpl) getElementAncestor(this);



Mime
View raw message