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 2012/09/01 13:23:44 UTC

svn commit: r1379742 - 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/document/ axiom-dom-testsuite/src/test/java/org/apache/axio...

Author: veithen
Date: Sat Sep  1 11:23:44 2012
New Revision: 1379742

URL: http://svn.apache.org/viewvc?rev=1379742&view=rev
Log:
AXIOM-423: Fixed a NullPointerException in the lookupNamespaceURI implementation.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestLookupNamespaceURIWithEmptyDocument.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-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.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=1379742&r1=1379741&r2=1379742&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 Sat Sep  1 11:23:44 2012
@@ -65,6 +65,7 @@ public class DOMTestSuiteBuilder extends
         addTest(new org.apache.axiom.ts.dom.document.TestGetDomConfigDefaults(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestGetOwnerDocument(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestLookupNamespaceURI(dbf));
+        addTest(new org.apache.axiom.ts.dom.document.TestLookupNamespaceURIWithEmptyDocument(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestNormalizeDocumentNamespace(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestTransformerWithIdentityStylesheet(dbf, org.apache.xalan.processor.TransformerFactoryImpl.class));
         addTest(new org.apache.axiom.ts.dom.document.TestTransformerWithIdentityStylesheet(dbf, net.sf.saxon.TransformerFactoryImpl.class));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestLookupNamespaceURIWithEmptyDocument.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestLookupNamespaceURIWithEmptyDocument.java?rev=1379742&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestLookupNamespaceURIWithEmptyDocument.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestLookupNamespaceURIWithEmptyDocument.java Sat Sep  1 11:23:44 2012
@@ -0,0 +1,39 @@
+/*
+ * 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.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Tests the behavior of {@link Node#lookupNamespaceURI(String)} on an empty {@link Document}.
+ */
+public class TestLookupNamespaceURIWithEmptyDocument extends DOMTestCase {
+    public TestLookupNamespaceURIWithEmptyDocument(DocumentBuilderFactory dbf) {
+        super(dbf);
+    }
+
+    protected void runTest() throws Throwable {
+        Document document = dbf.newDocumentBuilder().newDocument();
+        assertNull(document.lookupNamespaceURI("p"));
+    }
+}

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

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java?rev=1379742&r1=1379741&r2=1379742&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/test/java/org/apache/axiom/ts/dom/XercesTest.java Sat Sep  1 11:23:44 2012
@@ -23,6 +23,7 @@ import javax.xml.parsers.DocumentBuilder
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.axiom.ts.dom.document.TestLookupNamespaceURIWithEmptyDocument;
 import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
 
 public class XercesTest extends TestCase {
@@ -30,6 +31,10 @@ public class XercesTest extends TestCase
         DocumentBuilderFactory dbf = new DocumentBuilderFactoryImpl();
         dbf.setNamespaceAware(true);
         DOMTestSuiteBuilder builder = new DOMTestSuiteBuilder(dbf);
+        
+        // XERCESJ-1582
+        builder.exclude(TestLookupNamespaceURIWithEmptyDocument.class);
+        
         return builder.build();
     }
 }

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=1379742&r1=1379741&r2=1379742&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 Sat Sep  1 11:23:44 2012
@@ -34,6 +34,7 @@ import org.apache.axiom.om.util.StAXUtil
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.UserDataHandler;
@@ -297,8 +298,9 @@ public abstract class NodeImpl implement
 
         }
         case Node.DOCUMENT_NODE: {
-            return ((NodeImpl) ((Document) this).getDocumentElement())
-                    .lookupNamespaceURI(specifiedPrefix);
+            Element documentElement = ((Document) this).getDocumentElement();
+            return documentElement == null ? null
+                    : documentElement.lookupNamespaceURI(specifiedPrefix);
         }
         case Node.ENTITY_NODE:
         case Node.NOTATION_NODE: