Author: darran.lofthouse(a)jboss.com
Date: 2009-07-20 13:07:25 -0400 (Mon, 20 Jul 2009)
New Revision: 10367
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2703.xml
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
Log:
[JBPAPP-2279] Node.getElementsByTagName() only works with name local part.
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-20
16:59:59 UTC (rev 10366)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-20
17:07:25 UTC (rev 10367)
@@ -741,7 +741,20 @@
public NodeList getElementsByTagName(String name)
{
- return new NodeListImpl(DOMUtils.getChildElements(this, name, true));
+ Iterator nodes = DOMUtils.getChildElements(this, (QName)null, true);
+
+ List filtered = new LinkedList();
+
+ while (nodes.hasNext())
+ {
+ Element current = (Element)nodes.next();
+ if (current.getTagName().equals(name))
+ {
+ filtered.add(current);
+ }
+ }
+
+ return new NodeListImpl(filtered.iterator());
}
public String getAttributeNS(String namespaceURI, String localName)
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-07-20
16:59:59 UTC (rev 10366)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-07-20
17:07:25 UTC (rev 10367)
@@ -159,11 +159,10 @@
// JBWS-2704
public void testGetElementByTagNameNS_Wildcard() throws Exception
{
- InputStream is = new
File("resources/common/soap/bws2704.xml").toURL().openStream();
+ InputStream is = new
File("resources/common/soap/jbws2704.xml").toURL().openStream();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage(null, is);
SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
-
NodeList nodes = envelope.getElementsByTagNameNS("*",
"String_1");
assertEquals("String_1 nodes", 2, nodes.getLength());
assertEquals("String_1(0) text content", "Value_1",
nodes.item(0).getTextContent());
@@ -191,10 +190,30 @@
nodes = envelope.getElementsByTagNameNS("http://org.jboss.ws/testNS2",
"String_1");
assertEquals("http://org.jboss.ws/testNS2 String_1 nodes", 1,
nodes.getLength());
assertEquals("http://org.jboss.ws/testNS2 String_1(0) text content",
"Value_2", nodes.item(0).getTextContent());
+ }
+
+ // JBWS-2703
+ public void testGetElementByTagName() throws Exception
+ {
+ InputStream is = new
File("resources/common/soap/jbws2703.xml").toURL().openStream();
+ MessageFactory messageFactory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = messageFactory.createMessage(null, is);
+ SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
+
+ NodeList nodeList;
+ nodeList = envelope.getElementsByTagName("soapenv:Header");
+ assertEquals("soapenv:Header nodes.", 1, nodeList.getLength());
+ nodeList = envelope.getElementsByTagName("soapenv:Body");
+ assertEquals("soapenv:Body nodes.", 1, nodeList.getLength());
+ nodeList = envelope.getElementsByTagName("jbw:echo");
+ assertEquals("jbw:echo nodes.", 1, nodeList.getLength());
+ nodeList = envelope.getElementsByTagName("arg0");
+ assertEquals("arg0 nodes.", 2, nodeList.getLength());
+ assertEquals("arg0 text content", "111",
nodeList.item(0).getTextContent());
+ assertEquals("arg0 text content", "222",
nodeList.item(1).getTextContent());
}
-
//
http://jira.jboss.com/jira/browse/JBWS-773
public void testGetNamespaceURI() throws Exception
{
Copied:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2703.xml
(from rev 10364,
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2703.xml)
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2703.xml
(rev 0)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/common/soap/jbws2703.xml 2009-07-20
17:07:25 UTC (rev 10367)
@@ -0,0 +1,13 @@
+<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:jbw='http://ws.jboss.org/jbws2703'>
+ <soapenv:Header>
+ <jbw:myvalue>
+ <arg0>111</arg0>
+ </jbw:myvalue>
+ </soapenv:Header>
+ <soapenv:Body>
+ <jbw:echo>
+ <arg0>222</arg0>
+ </jbw:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
+