Author: richard.opalka(a)jboss.com
Date: 2011-05-10 18:51:53 -0400 (Tue, 10 May 2011)
New Revision: 14352
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/Endpoint.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/EndpointBean.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/JBWS3293DispatchTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/SOAPHandler.java
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/web.xml
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/wsdl/
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/wsdl/TestService.wsdl
Modified:
shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml
Log:
[JBWS-3293] providing test case
Modified: shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml
===================================================================
--- shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml 2011-05-10
21:12:50 UTC (rev 14351)
+++ shared-testsuite/trunk/testsuite/src/test/ant-import/build-jars-jaxws.xml 2011-05-10
22:51:53 UTC (rev 14352)
@@ -1067,6 +1067,14 @@
</webinf>
</war>
+ <!-- jaxws-jbws3293 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws3293.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws3293/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/jbws3293/Endpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/jbws3293/EndpointBean.class"/>
+ </classes>
+ </war>
+
<!-- jaxws-endpoint-servlet -->
<war warfile="${tests.output.dir}/test-libs/jaxws-endpoint-servlet.war"
manifest="${tests.output.dir}/test-resources/jaxws/endpoint/META-INF/MANIFEST.MF"
webxml="${tests.output.dir}/test-resources/jaxws/endpoint/WEB-INF/web.xml">
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/Endpoint.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/Endpoint.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/Endpoint.java 2011-05-10
22:51:53 UTC (rev 14352)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws3293;
+
+import java.util.concurrent.Future;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+@WebService(name = "Endpoint", targetNamespace =
"http://org.jboss.ws/jaxws/jbws3293")
+@SOAPBinding(style = Style.RPC)
+public interface Endpoint
+{
+ @WebMethod(operationName = "echo")
+ public Response<String> echoAsync(@WebParam(name = "String_1") String
string1);
+
+ @WebMethod(operationName = "echo")
+ public Future<?> echoAsync(@WebParam(name = "String_1") String
string1, @WebParam(name = "asyncHandler") AsyncHandler<String>
asyncHandler);
+
+ @WebMethod
+ @WebResult(name = "result")
+ public String echo(@WebParam(name = "String_1") String string1);
+}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/EndpointBean.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/EndpointBean.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/EndpointBean.java 2011-05-10
22:51:53 UTC (rev 14352)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws3293;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+
+@WebService(name = "Endpoint", targetNamespace =
"http://org.jboss.ws/jaxws/jbws3293")
+@SOAPBinding(style = Style.RPC)
+public class EndpointBean
+{
+ @WebMethod
+ @WebResult(name = "result")
+ public String echo(@WebParam(name = "String_1") String msg)
+ {
+ System.out.println("echo: " + msg);
+ return msg;
+ }
+}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/JBWS3293DispatchTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/JBWS3293DispatchTestCase.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/JBWS3293DispatchTestCase.java 2011-05-10
22:51:53 UTC (rev 14352)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws3293;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Response;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.Handler;
+
+import junit.framework.Test;
+
+import org.jboss.ws.common.DOMUtils;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Element;
+
+/**
+ * [JBWS-3293] tests dispatch creation without WSDL.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public class JBWS3293DispatchTestCase extends JBossWSTest
+{
+ private String targetNS = "http://org.jboss.ws/jaxws/jbws3293";
+ private String reqPayload = "<ns2:echo xmlns:ns2='" + targetNS +
"'><String_1>Hello</String_1></ns2:echo>";
+ private Exception handlerException;
+ private boolean asyncHandlerCalled;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS3293DispatchTestCase.class,
"jaxws-jbws3293.war");
+ }
+
+ public void testInvokeAsynch() throws Exception
+ {
+ Source reqObj = new StreamSource(new StringReader(reqPayload));
+ Dispatch dispatch = createDispatch();
+ Response response = dispatch.invokeAsync(reqObj);
+ verifyResponse((Source)response.get(3000, TimeUnit.MILLISECONDS));
+ }
+
+ public void testInvokeAsynchHandler() throws Exception
+ {
+ AsyncHandler handler = new AsyncHandler()
+ {
+ public void handleResponse(Response response)
+ {
+ try
+ {
+ verifyResponse((Source)response.get());
+ asyncHandlerCalled = true;
+ }
+ catch (Exception ex)
+ {
+ handlerException = ex;
+ }
+ }
+ };
+ StreamSource reqObj = new StreamSource(new StringReader(reqPayload));
+ Dispatch dispatch = createDispatch();
+ Future future = dispatch.invokeAsync(reqObj, handler);
+ future.get(1000, TimeUnit.MILLISECONDS);
+
+ if (handlerException != null)
+ throw handlerException;
+
+ assertTrue("Async handler called", asyncHandlerCalled);
+ }
+
+ private void installHandler(final Dispatch dispatch)
+ {
+ List<Handler> handlers = dispatch.getBinding().getHandlerChain();
+ handlers.add(new SOAPHandler());
+ dispatch.getBinding().setHandlerChain(handlers);
+ }
+
+ private Dispatch createDispatch() throws MalformedURLException
+ {
+ QName serviceName = new QName(targetNS, "EndpointBeanService");
+ QName portName = new QName(targetNS, "EndpointPort");
+ Service service = Service.create(serviceName);
+ service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, "http://" +
getServerHost() + ":8080/jaxws-jbws3293");
+ Dispatch dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+ installHandler(dispatch);
+ return dispatch;
+ }
+
+ private void verifyResponse(Source result) throws IOException
+ {
+ Element docElement = DOMUtils.sourceToElement(result);
+ Element retElement = DOMUtils.getFirstChildElement(docElement);
+ assertEquals("result", retElement.getNodeName());
+ assertEquals("Hello modified in handler", retElement.getTextContent());
+ }
+
+}
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/SOAPHandler.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/SOAPHandler.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws3293/SOAPHandler.java 2011-05-10
22:51:53 UTC (rev 14352)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.test.ws.jaxws.jbws3293;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.LogicalMessageContext;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.helper.DOMWriter;
+import org.jboss.ws.WSException;
+import org.jboss.ws.api.handler.GenericSOAPHandler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class SOAPHandler extends GenericSOAPHandler<LogicalMessageContext>
+{
+
+ private static final Logger log = Logger.getLogger(SOAPHandler.class);
+
+ @Override
+ protected boolean handleInbound(final MessageContext msgContext)
+ {
+ log.info("handleInbound()");
+
+ try
+ {
+ SOAPMessageContext smc = (SOAPMessageContext)msgContext;
+ SOAPMessage message = smc.getMessage();
+
+ SOAPBody body = message.getSOAPBody();
+ Document document = body.extractContentAsDocument();
+ Node node = document;
+
+ System.out.println(DOMWriter.printNode(node, true));
+
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node current = nodes.item(i);
+
+ NodeList childNodes = current.getChildNodes();
+ for (int j = 0; j < childNodes.getLength(); j++)
+ {
+ Node currentChildNode = childNodes.item(j);
+ if ("result".equals(currentChildNode.getLocalName()))
+ {
+ currentChildNode.setTextContent(currentChildNode.getTextContent() +
" modified in handler");
+ }
+ }
+ }
+
+ System.out.println(DOMWriter.printNode(node, true));
+
+ // Add document back as removed by call to 'extractContentAsDocument()'
+ body.addDocument(document);
+ message.saveChanges();
+ }
+ catch (SOAPException e)
+ {
+ throw new WSException("Error in Handler", e);
+ }
+
+ log.info("Finished");
+ return true;
+ }
+
+}
Added: shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/web.xml
===================================================================
--- shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/web.xml
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/web.xml 2011-05-10
22:51:53 UTC (rev 14352)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>Endpoint</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.jbws3293.EndpointBean</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Endpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
Added:
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/wsdl/TestService.wsdl
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/wsdl/TestService.wsdl
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws3293/WEB-INF/wsdl/TestService.wsdl 2011-05-10
22:51:53 UTC (rev 14352)
@@ -0,0 +1,44 @@
+<!--
+ This wsdl is only used for client artifact generation
+
+ wsimport -keep -verbose -d ../../../java ./WEB-INF/wsdl/TestService.wsdl
+-->
+<definitions name='EndpointService'
targetNamespace='http://org.jboss.ws/jaxws/jbws3293'
xmlns='http://schemas.xmlsoap.org/wsdl/'
+
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://org.jboss.ws/jaxws/jbws3293'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
+
+ <jaxws:bindings>
+ <jaxws:package name="org.jboss.test.ws.jaxws.jbws3293"/>
+ <jaxws:enableAsyncMapping>true</jaxws:enableAsyncMapping>
+ </jaxws:bindings>
+
+ <message name='Endpoint_echoResponse'>
+ <part name='result' type='xsd:string'/>
+ </message>
+ <message name='Endpoint_echo'>
+ <part name='String_1' type='xsd:string'/>
+ </message>
+ <portType name='Endpoint'>
+ <operation name='echo' parameterOrder='String_1'>
+ <input message='tns:Endpoint_echo'/>
+ <output message='tns:Endpoint_echoResponse'/>
+ </operation>
+ </portType>
+ <binding name='EndpointBinding' type='tns:Endpoint'>
+ <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='echo'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/jaxws/jbws3293'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/jaxws/jbws3293'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='EndpointService'>
+ <port binding='tns:EndpointBinding' name='EndpointPort'>
+ <soap:address
location='http://tdvaio:8080/jaxws-jbws3293/Endpoint'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file