Author: darran.lofthouse(a)jboss.com
Date: 2009-06-30 12:49:13 -0400 (Tue, 30 Jun 2009)
New Revision: 10268
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2693.xml
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
Log:
[JBWS-2693] Implement Node.setTextContent().
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2009-06-30
15:36:17 UTC (rev 10267)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2009-06-30
16:49:13 UTC (rev 10268)
@@ -657,8 +657,17 @@
public void setTextContent(String textContent) throws DOMException
{
- // FIXME setTextContent
- throw new NotImplementedException("setTextContent");
+ NodeList nodes = getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ removeChild((Node)nodes.item(i));
+ }
+
+ if (textContent != null && textContent.length() > 0)
+ {
+ Node node = domNode.getOwnerDocument().createTextNode(textContent);
+ appendChild(node);
+ }
}
public Object setUserData(String key, Object data, UserDataHandler handler)
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 2009-06-30
15:36:17 UTC (rev 10267)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2009-06-30
16:49:13 UTC (rev 10268)
@@ -22,6 +22,7 @@
package org.jboss.test.ws.common.soap;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.InputStream;
import java.util.Iterator;
@@ -155,7 +156,41 @@
assertEquals(soapFactory.createName("name"), it.next());
assertEquals(soapFactory.createName("species", null,
"http://zoofan.net"), it.next());
}
+
+ public void testSetTextContent() throws Exception
+ {
+ InputStream is =
getResourceURL("common/soap/jbws2693.xml").openStream();
+ MessageFactory messageFactory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = messageFactory.createMessage(null, is);
+ NodeList nl = soapMessage.getSOAPBody().getChildNodes();
+ SOAPElement echo = null;
+ for (int i = 0; i < nl.getLength() && echo == null; i++)
+ {
+ Object current = nl.item(i);
+ if (current instanceof SOAPElement)
+ {
+ echo = (SOAPElement)current;
+ }
+ }
+ nl = echo.getChildNodes();
+ SOAPElement arg0 = null;
+ for (int i = 0; i < nl.getLength() && arg0 == null; i++)
+ {
+ Object current = nl.item(i);
+ if (current instanceof SOAPElement)
+ {
+ arg0 = (SOAPElement)current;
+ }
+ }
+ String value = arg0.getTextContent();
+ assertEquals("Expected value", "123", value);
+
+ arg0.setTextContent("456");
+ value = arg0.getTextContent();
+ assertEquals("Expected value", "456", value);
+ }
+
/** Return the count of iterator elements, rendering the iterator unusable.
*/
private int getIteratorCount(Iterator i)
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2693.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2693.xml
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2693.xml 2009-06-30
16:49:13 UTC (rev 10268)
@@ -0,0 +1,8 @@
+<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:jbw='http://ws.jboss.org/jbws2693'>
+ <soapenv:Header/>
+ <soapenv:Body>
+ <jbw:echo>
+ <arg0>123</arg0>
+ </jbw:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Property changes on:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/soap/jbws2693.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF