You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/11/01 19:45:59 UTC
svn commit: r1404719 -
/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Author: dkulp
Date: Thu Nov 1 18:45:59 2012
New Revision: 1404719
URL: http://svn.apache.org/viewvc?rev=1404719&view=rev
Log:
Add testcase for CXF-4608
Modified:
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=1404719&r1=1404718&r2=1404719&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java (original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java Thu Nov 1 18:45:59 2012
@@ -33,8 +33,10 @@ import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.BindingProvider;
@@ -60,6 +62,7 @@ import org.apache.cxf.binding.soap.saaj.
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.jaxws.DispatchImpl;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.testutil.common.TestUtil;
@@ -858,6 +861,36 @@ public class DispatchClientServerTest ex
assertNotNull(streamSourceResp3);
assertTrue("Expected: " + expected, XMLUtils.toString(streamSourceResp3).contains(expected3));
}
+ @Test
+ public void testStAXSourcePAYLOAD() throws Exception {
+
+ URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+ assertNotNull(wsdl);
+
+ SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
+ assertNotNull(service);
+
+ Dispatch<StAXSource> disp = service.createDispatch(PORT_NAME, StAXSource.class, Service.Mode.PAYLOAD);
+ disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:"
+ + greeterPort
+ + "/SOAPDispatchService/SoapDispatchPort");
+
+ // Test request-response
+ InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralSOAPBodyReq.xml");
+ InputSource inputSource = new InputSource(is);
+ inputSource.setPublicId(getClass()
+ .getResource("resources/GreetMeDocLiteralSOAPBodyReq.xml").toString());
+ inputSource.setSystemId(inputSource.getPublicId());
+ StAXSource staxSourceReq = new StAXSource(StaxUtils.createXMLStreamReader(inputSource));
+ assertNotNull(staxSourceReq);
+ Source resp = disp.invoke(staxSourceReq);
+ assertNotNull(resp);
+ assertTrue(resp instanceof StAXSource);
+ String expected = "Hello TestSOAPInputMessage";
+ String actual = StaxUtils.toString(StaxUtils.read(resp));
+ assertTrue("Expected: " + expected, actual.contains(expected));
+ }
class TestSOAPMessageHandler implements AsyncHandler<SOAPMessage> {