File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
main/java/org/springframework/ws/pox/dom
test/java/org/springframework/ws/pox/dom Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 2626import javax .xml .transform .dom .DOMSource ;
2727import javax .xml .transform .stream .StreamResult ;
2828
29+ import org .w3c .dom .Document ;
30+ import org .w3c .dom .Element ;
31+ import org .w3c .dom .NodeList ;
32+
2933import org .springframework .util .Assert ;
3034import org .springframework .ws .pox .PoxMessage ;
3135import org .springframework .ws .transport .TransportConstants ;
3236import org .springframework .ws .transport .TransportOutputStream ;
3337import org .springframework .xml .namespace .QNameUtils ;
34- import org .w3c .dom .Document ;
35- import org .w3c .dom .Element ;
3638
3739/**
3840 * Implementation of the <code>PoxMessage</code> interface that is based on a DOM Document.
@@ -69,6 +71,10 @@ public Document getDocument() {
6971 }
7072
7173 public Result getPayloadResult () {
74+ NodeList children = document .getChildNodes ();
75+ for (int i = 0 ; i < children .getLength (); i ++) {
76+ document .removeChild (children .item (i ));
77+ }
7278 return new DOMResult (document );
7379 }
7480
Original file line number Diff line number Diff line change 2323import javax .xml .transform .TransformerFactory ;
2424
2525import org .custommonkey .xmlunit .XMLTestCase ;
26+ import org .w3c .dom .Document ;
27+
2628import org .springframework .xml .transform .StringResult ;
2729import org .springframework .xml .transform .StringSource ;
28- import org .w3c .dom .Document ;
2930
3031public class DomPoxMessageTest extends XMLTestCase {
3132
@@ -53,6 +54,15 @@ public void testGetPayload() throws Exception {
5354 assertXMLEqual (content , stringResult .toString ());
5455 }
5556
57+ public void testGetPayloadResultTwice () throws Exception {
58+ String content = "<element xmlns=\" http://www.springframework.org/spring-ws\" />" ;
59+ transformer .transform (new StringSource (content ), message .getPayloadResult ());
60+ transformer .transform (new StringSource (content ), message .getPayloadResult ());
61+ StringResult stringResult = new StringResult ();
62+ transformer .transform (message .getPayloadSource (), stringResult );
63+ assertXMLEqual (content , stringResult .toString ());
64+ }
65+
5666 public void testWriteTo () throws Exception {
5767 String content = "<root xmlns='http://www.springframework.org/spring-ws'>" + "<child/></root>" ;
5868 StringSource source = new StringSource (content );
You can’t perform that action at this time.
0 commit comments