You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2010/08/22 23:24:27 UTC

svn commit: r987949 - in /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test: java/org/apache/axiom/om/impl/dom/ElementImplTest.java resources/ resources/attributetest.xml

Author: veithen
Date: Sun Aug 22 21:24:26 2010
New Revision: 987949

URL: http://svn.apache.org/viewvc?rev=987949&view=rev
Log:
Added some test cases for WSCOMMONS-557.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/attributetest.xml   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java?rev=987949&r1=987948&r2=987949&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java Sun Aug 22 21:24:26 2010
@@ -24,8 +24,10 @@ import org.apache.axiom.om.OMElementTest
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
+import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
@@ -263,4 +265,65 @@ public class ElementImplTest extends OME
             }
         });
     }
+
+    // TODO: This provides evidence for WSCOMMONS-557 (not yet fixed)
+    public void _testAttributes() throws Exception {
+        DOMTestUtil.execute(new DOMTestUtil.Test() {
+            public void execute(DocumentBuilderFactory dbf) throws Exception {
+                Document doc = dbf.newDocumentBuilder().parse(getTestResource("attributetest.xml"));
+
+                // Check whether body has attributes
+                Element bodyElement = doc.getDocumentElement();
+                assertTrue(bodyElement.hasAttributes());
+
+                Element directionResponse = (Element)bodyElement.getElementsByTagName("GetDirectionsResponse").item(0);
+                assertTrue(directionResponse.hasAttributes());
+
+                NamedNodeMap attributes = directionResponse.getAttributes();
+                Attr attr = (Attr)attributes.item(0);
+                assertEquals(attr.getName(), "xmlns");
+                assertEquals(attr.getValue(), "http://www.example.org/webservices/");
+
+                Element directionResult = (Element)bodyElement.getElementsByTagName("GetDirectionsResult").item(0);
+                assertFalse(directionResult.hasAttributes());
+
+                Element drivingDirection = (Element)directionResult.getElementsByTagName("drivingdirections").item(0);
+                assertTrue(drivingDirection.hasAttributes());
+
+                attributes = drivingDirection.getAttributes();
+                attr = (Attr)attributes.item(0);
+                assertEquals(attr.getName(), "xmlns");
+                assertEquals(attr.getValue(), "");
+
+
+                Element route = (Element)drivingDirection.getElementsByTagName("route").item(0);
+                assertTrue(route.hasAttributes());
+
+                attributes = route.getAttributes();
+                attr = (Attr)attributes.item(0);
+                assertEquals(attr.getName(), "distanceToTravel");
+                assertEquals(attr.getValue(), "500m");
+
+                attr = (Attr)attributes.item(1);
+                assertEquals(attr.getName(), "finalStep");
+                assertEquals(attr.getValue(), "false");
+
+                attr = (Attr)attributes.item(2);
+                assertEquals(attr.getName(), "id");
+                assertEquals(attr.getValue(), "0");
+
+            }
+        });
+    }
+
+    public void testAttributes2() throws Exception {
+        DOMTestUtil.execute(new DOMTestUtil.Test() {
+            public void execute(DocumentBuilderFactory dbf) throws Exception {
+                Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(
+                        "<root><child xmlns=\"\"/></root>")));
+                Element element = (Element)doc.getDocumentElement().getFirstChild();
+                assertTrue(element.hasAttributes());
+            }
+        });
+    }
 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/attributetest.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/attributetest.xml?rev=987949&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/attributetest.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/attributetest.xml Sun Aug 22 21:24:26 2010
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='utf-8'?>
+<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-739587016">
+  <GetDirectionsResponse xmlns="http://www.example.org/webservices/">
+    <GetDirectionsResult>
+      <drivingdirections xmlns="">
+        <route distanceToTravel="500m" finalStep="false" id="0">Head south on Grove St</route>       
+      </drivingdirections>
+    </GetDirectionsResult>
+  </GetDirectionsResponse>
+</soapenv:Body>

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/resources/attributetest.xml
------------------------------------------------------------------------------
    svn:eol-style = native