ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1550919 - in /webservices/axiom/trunk/modules: axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/ axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-dom/sr...
Date Sat, 14 Dec 2013 10:50:52 GMT
Author: veithen
Date: Sat Dec 14 10:50:51 2013
New Revision: 1550919

URL: http://svn.apache.org/r1550919
Log:
Fixed an issue in the way DOOM internally represents default namespace declarations. This
also fixes an issue with getSAXResult.

Added:
    webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExistingDefaultNamespaceDeclaration.java
      - copied, changed from r1548742, webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java
Modified:
    webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
    webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.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/DocumentImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeHelper.java
    webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java

Modified: webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1550919&r1=1550918&r2=1550919&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
Sat Dec 14 10:50:51 2013
@@ -151,6 +151,7 @@ public class DOMTestSuiteBuilder extends
             addTest(new org.apache.axiom.ts.dom.element.TestSetAttributeNS(dbf, validAttrQNames[i],
"value"));
         }
         addTest(new org.apache.axiom.ts.dom.element.TestSetAttributeNSExisting(dbf));
+        addTest(new org.apache.axiom.ts.dom.element.TestSetAttributeNSExistingDefaultNamespaceDeclaration(dbf));
         for (int i=0; i<invalidAttrQNames.length; i++) {
             addTest(new org.apache.axiom.ts.dom.element.TestSetAttributeNSInvalid(dbf, invalidAttrQNames[i]));
         }

Modified: webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java?rev=1550919&r1=1550918&r2=1550919&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java
Sat Dec 14 10:50:51 2013
@@ -43,7 +43,7 @@ public class TestSetAttributeNSExisting 
         attr.setValue("value1");
         element.setAttributeNodeNS(attr);
         
-        // Now change the attribute using setAttributeNS
+        // Now change the attribute using setAttributeNS (using a different prefix and value)
         element.setAttributeNS("urn:test", "p2:attr", "value2");
         
         // DOM is expected to change the original attribute, not to create a new one

Copied: webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExistingDefaultNamespaceDeclaration.java
(from r1548742, webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExistingDefaultNamespaceDeclaration.java?p2=webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExistingDefaultNamespaceDeclaration.java&p1=webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java&r1=1548742&r2=1550919&rev=1550919&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExisting.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestSetAttributeNSExistingDefaultNamespaceDeclaration.java
Sat Dec 14 10:50:51 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.ts.dom.element;
 
+import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.axiom.ts.dom.DOMTestCase;
@@ -26,11 +27,11 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
- * Tests the behavior of {@link Element#setAttributeNS(String, String, String)} if the element
- * already has an attribute with the same namespace URI and local name.
+ * Tests the behavior of {@link Element#setAttributeNS(String, String, String)} when used
to modify
+ * a namespace declaration for the default namespace.
  */
-public class TestSetAttributeNSExisting extends DOMTestCase {
-    public TestSetAttributeNSExisting(DocumentBuilderFactory dbf) {
+public class TestSetAttributeNSExistingDefaultNamespaceDeclaration extends DOMTestCase {
+    public TestSetAttributeNSExistingDefaultNamespaceDeclaration(DocumentBuilderFactory dbf)
{
         super(dbf);
     }
 
@@ -38,16 +39,16 @@ public class TestSetAttributeNSExisting 
         Document document = dbf.newDocumentBuilder().newDocument();
         Element element = document.createElementNS(null, "test");
         
-        // Add the original attribute
-        Attr attr = document.createAttributeNS("urn:test", "p1:attr");
-        attr.setValue("value1");
+        // Add the original default namespace declaration
+        Attr attr = document.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE);
+        attr.setValue("urn:ns1");
         element.setAttributeNodeNS(attr);
         
         // Now change the attribute using setAttributeNS
-        element.setAttributeNS("urn:test", "p2:attr", "value2");
+        element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE,
"urn:ns2");
         
         // DOM is expected to change the original attribute, not to create a new one
-        assertEquals("value2", attr.getValue());
-        assertEquals("p2", attr.getPrefix());
+        assertEquals("urn:ns2", attr.getValue());
+        assertNull(attr.getPrefix());
     }
 }

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=1550919&r1=1550918&r2=1550919&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
Sat Dec 14 10:50:51 2013
@@ -375,8 +375,7 @@ public class AttrImpl extends RootNode i
      * @see org.w3c.dom.Node#getPrefix()
      */
     public String getPrefix() {
-        // TODO Error checking
-        return (this.namespace == null) ? null : this.namespace.getPrefix();
+        return NamedNodeHelper.getPrefix(this);
     }
 
     public void setPrefix(String prefix) throws DOMException {

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1550919&r1=1550918&r2=1550919&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Sat Dec 14 10:50:51 2013
@@ -143,8 +143,7 @@ public class DocumentImpl extends RootNo
         if (namespaceURI == null) {
             namespace = null;
         } else {
-            namespace = new OMNamespaceImpl(namespaceURI,
-                    prefix == null && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)
? "" : prefix);
+            namespace = new OMNamespaceImpl(namespaceURI, prefix == null ? "" : prefix);
         }
         return new AttrImpl(this, localName, namespace, this.factory);
     }

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=1550919&r1=1550918&r2=1550919&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
Sat Dec 14 10:50:51 2013
@@ -462,7 +462,7 @@ public class ElementImpl extends ParentN
         } else {
             if (namespaceURI != null) {
                 attr = new AttrImpl(ownerDocument(), localName, value, this.factory);
-                attr.setOMNamespace(new OMNamespaceImpl(namespaceURI, prefix));
+                attr.setOMNamespace(new OMNamespaceImpl(namespaceURI, prefix == null ? ""
: prefix));
     
                 this.setAttributeNodeNS(attr);
             } else {
@@ -967,13 +967,7 @@ public class ElementImpl extends ParentN
      * @see org.w3c.dom.Node#getPrefix()
      */
     public String getPrefix() {
-        OMNamespace ns = getNamespace();
-        if (ns == null) {
-            return null;
-        } else {
-            String prefix = ns.getPrefix();
-            return prefix.length() == 0 ? null : prefix;
-        }
+        return NamedNodeHelper.getPrefix(this);
     }
 
     public void setPrefix(String prefix) throws DOMException {

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeHelper.java?rev=1550919&r1=1550918&r2=1550919&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeHelper.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeHelper.java
Sat Dec 14 10:50:51 2013
@@ -22,10 +22,20 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.w3c.dom.DOMException;
 
-public final class NamedNodeHelper {
+final class NamedNodeHelper {
     private NamedNodeHelper() {}
 
-    public static void setPrefix(NamedNode node, String prefix) throws DOMException {
+    static String getPrefix(NamedNode node) {
+        OMNamespace ns = node.getNamespace();
+        if (ns == null) {
+            return null;
+        } else {
+            String prefix = ns.getPrefix();
+            return prefix.length() == 0 ? null : prefix;
+        }
+    }
+    
+    static void setPrefix(NamedNode node, String prefix) throws DOMException {
         if (prefix == null) {
             prefix = "";
         }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1550919&r1=1550918&r2=1550919&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
Sat Dec 14 10:50:51 2013
@@ -27,7 +27,6 @@ import org.apache.axiom.ts.om.builder.Te
 import org.apache.axiom.ts.om.container.TestSerialize;
 import org.apache.axiom.ts.om.document.TestClone;
 import org.apache.axiom.ts.om.document.TestDigest;
-import org.apache.axiom.ts.om.document.TestGetSAXResult;
 import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
 import org.apache.axiom.ts.om.element.TestSerializationWithTwoNonBuiltOMElements;
 import org.apache.axiom.ts.om.element.sr.TestClose;
@@ -63,9 +62,6 @@ public class OMImplementationTest extend
         
         // TODO: test case needing review
         builder.exclude(TestClose.class);
-
-        // TODO: fails because of an issue elsewhere in DOOM
-        builder.exclude(TestGetSAXResult.class);
         
         return builder.build();
     }



Mime
View raw message