Author: alessio.soldano(a)jboss.com
Date: 2010-09-14 13:08:51 -0400 (Tue, 14 Sep 2010)
New Revision: 12970
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderBeanMessage.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderMessageTestCase.java
Log:
[JBWS-3101] Adding testcase
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderBeanMessage.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderBeanMessage.java 2010-09-14
11:45:27 UTC (rev 12969)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderBeanMessage.java 2010-09-14
17:08:51 UTC (rev 12970)
@@ -21,12 +21,15 @@
*/
package org.jboss.test.ws.jaxws.samples.provider;
+import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
+import org.w3c.dom.NodeList;
+
/**
* Test a Provider<SOAPMessage>
*
@@ -43,6 +46,22 @@
{
public SOAPMessage invoke(SOAPMessage request)
{
+ try
+ {
+ SOAPHeader headers = request.getSOAPHeader();
+ if (headers != null)
+ {
+ NodeList nl =
headers.getElementsByTagNameNS("http://org.jboss.ws/foo",
"returnNullResponse");
+ if (nl != null && nl.getLength() > 0)
+ {
+ return null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
return request;
}
}
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderMessageTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderMessageTestCase.java 2010-09-14
11:45:27 UTC (rev 12969)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/provider/ProviderMessageTestCase.java 2010-09-14
17:08:51 UTC (rev 12970)
@@ -29,12 +29,14 @@
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.Service.Mode;
@@ -61,6 +63,16 @@
" <ns1:somePayload
xmlns:ns1='http://org.jboss.ws/provider'/>" +
" </soap:Body>" +
"</soap:Envelope>";
+
+ private String msgStringForNullResponse =
+ "<soap:Envelope
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ " <soap:Header>" +
+ " <nsh:returnNullResponse
xmlns:nsh='http://org.jboss.ws/foo'/>" +
+ " </soap:Header>" +
+ " <soap:Body>" +
+ " <ns1:somePayload
xmlns:ns1='http://org.jboss.ws/provider'/>" +
+ " </soap:Body>" +
+ "</soap:Envelope>";
public static Test suite()
{
@@ -106,6 +118,23 @@
assertEquals(reqEnv, resEnv);
}
+ public void testProviderMessageNullResponse() throws Exception
+ {
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPMessage reqMsg = msgFactory.createMessage(null, new
ByteArrayInputStream(msgStringForNullResponse.getBytes()));
+
+ URL epURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-provider-message");
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMsg = con.call(reqMsg, epURL);
+ SOAPPart soapPart = resMsg.getSOAPPart();
+ //verify there's either nothing in the reply or at least the response body is
empty
+ if (soapPart != null && soapPart.getEnvelope() != null &&
soapPart.getEnvelope().getBody() != null)
+ {
+ SOAPBody soapBody = soapPart.getEnvelope().getBody();
+ assertFalse(soapBody.getChildElements().hasNext());
+ }
+ }
+
private SOAPMessage getRequestMessage() throws SOAPException, IOException
{
MessageFactory msgFactory = MessageFactory.newInstance();