Author: alessio.soldano(a)jboss.com
Date: 2008-10-28 11:37:10 -0400 (Tue, 28 Oct 2008)
New Revision: 8574
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
Log:
[JBWS-2346] SOAPBody.getElementsByTagNameNS() has to be recursive
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2008-10-28
15:34:25 UTC (rev 8573)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2008-10-28
15:37:10 UTC (rev 8574)
@@ -738,7 +738,7 @@
public NodeList getElementsByTagName(String name)
{
- return new NodeListImpl(DOMUtils.getChildElements(this, name));
+ return new NodeListImpl(DOMUtils.getChildElements(this, name, true));
}
public String getAttributeNS(String namespaceURI, String localName)
@@ -764,7 +764,7 @@
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
{
- return new NodeListImpl(DOMUtils.getChildElements(this, new QName(namespaceURI,
localName)));
+ return new NodeListImpl(DOMUtils.getChildElements(this, new QName(namespaceURI,
localName), true));
}
public TypeInfo getSchemaTypeInfo()
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2008-10-28
15:34:25 UTC (rev 8573)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2008-10-28
15:37:10 UTC (rev 8574)
@@ -22,8 +22,11 @@
package org.jboss.test.ws.common.soap;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.util.Iterator;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
@@ -33,6 +36,9 @@
import javax.xml.soap.SOAPMessage;
import org.jboss.wsf.test.JBossWSTest;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Test the SOAPElement
@@ -89,6 +95,33 @@
SOAPElement se2 = (SOAPElement)body.getChildElements().next();
assertEquals(se, se2);
}
+
+ //JBWS-2346
+ public void testGetElementByTagNameNS() throws Exception
+ {
+ InputStream is =
getResourceURL("common/soap/jbws2346.xml").openStream();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(is);
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage msg = factory.createMessage();
+ msg.getSOAPBody().addDocument(doc);
+ SOAPBody body = msg.getSOAPBody();
+ NodeList list = body.getElementsByTagNameNS("http://org.jboss.ws/testNS",
"elementA");
+ assertEquals(1, list.getLength());
+ list = body.getElementsByTagNameNS("http://org.jboss.ws/testNS",
"elementC");
+ assertEquals(2, list.getLength());
+ list = body.getElementsByTagNameNS("http://org.jboss.ws/testNS",
"String_1");
+ StringBuilder sb = new StringBuilder();
+ for (int i=0; i<list.getLength(); i++)
+ {
+ Node n = list.item(i);
+ sb.append(n.getFirstChild().getNodeValue());
+ sb.append(" ");
+ }
+ assertEquals("Strawberry Apple Banana Orange Raspberry ",
sb.toString());
+ }
//
http://jira.jboss.com/jira/browse/JBWS-773
public void testGetNamespaceURI() throws Exception