Author: darran.lofthouse(a)jboss.com
Date: 2007-04-25 06:43:25 -0400 (Wed, 25 Apr 2007)
New Revision: 2919
Modified:
branches/dlofthouse/JBWS-1625/jbossws-tests/src/java/org/jboss/test/ws/common/soap/MessageFactoryTestCase.java
Log:
Add test case to test for the double SOAP body content.
Modified:
branches/dlofthouse/JBWS-1625/jbossws-tests/src/java/org/jboss/test/ws/common/soap/MessageFactoryTestCase.java
===================================================================
---
branches/dlofthouse/JBWS-1625/jbossws-tests/src/java/org/jboss/test/ws/common/soap/MessageFactoryTestCase.java 2007-04-25
10:31:04 UTC (rev 2918)
+++
branches/dlofthouse/JBWS-1625/jbossws-tests/src/java/org/jboss/test/ws/common/soap/MessageFactoryTestCase.java 2007-04-25
10:43:25 UTC (rev 2919)
@@ -33,6 +33,7 @@
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.jboss.test.ws.JBossWSTest;
@@ -127,7 +128,7 @@
assertEquals(Constants.NS_SOAP11_ENV, env.getNamespaceURI());
}
- public void testSetContentOnSOAPPart() throws Exception
+ public void testSetContentOnSOAPPart_StreamSource() throws Exception
{
String expMsg =
"<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
@@ -153,6 +154,34 @@
assertEquals(DOMUtils.parse(expMsg), DOMUtils.parse(wasMsg));
}
+ public void testSetContentOnSOAPPart_DOMSource() throws Exception
+ {
+ String expMsg =
+ "<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <soapenv:Header/>" +
+ " <soapenv:Body>" +
+ " <HelloResponse
xmlns='http://helloservice.org/types\'>" +
+ " <argument>responseBean</argument>" +
+ " </HelloResponse>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ MessageFactory factory = new MessageFactoryImpl();
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(expMsg.getBytes());
+ SOAPMessage soapMsg = factory.createMessage(null, inputStream);
+
+ SOAPMessage message = factory.createMessage();
+ message.getSOAPPart().setContent(soapMsg.getSOAPPart().getContent());
+ message.saveChanges();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ message.writeTo(baos);
+ String wasMsg = new String(baos.toByteArray());
+
+ assertEquals(DOMUtils.parse(expMsg), DOMUtils.parse(wasMsg));
+ }
+
// [JBWS-1511] MessageFactory does not preserve comments
public void testPreserveComments() throws Exception
{