Author: richard.opalka(a)jboss.com
Date: 2010-08-13 09:47:53 -0400 (Fri, 13 Aug 2010)
New Revision: 12812
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java
framework/trunk/testsuite/test/resources/jaxws/endpoint/
framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/
framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/web.xml
framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/wsdl/
framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl
Modified:
framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml
Log:
refactoring Endpoint.publish() tests from jbossws-native to jbosswsframework
Modified: framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml
===================================================================
--- framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml 2010-08-13 13:17:49 UTC
(rev 12811)
+++ framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml 2010-08-13 13:47:53 UTC
(rev 12812)
@@ -998,6 +998,18 @@
</webinf>
</war>
+ <!-- jaxws-endpoint-servlet -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-endpoint-servlet.war"
webxml="${tests.output.dir}/test-resources/jaxws/endpoint/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/endpoint/EndpointServlet.class"
/>
+ <include name="org/jboss/test/ws/jaxws/endpoint/EndpointBean.class"
/>
+ <include name="org/jboss/test/ws/jaxws/endpoint/EndpointInterface.class"
/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/endpoint/WEB-INF">
+ <include name="wsdl/**" />
+ </webinf>
+ </war>
+
<!-- jaxws namespace -->
<war warfile="${tests.output.dir}/test-libs/jaxws-namespace.war"
webxml="${tests.output.dir}/test-resources/jaxws/namespace/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointBean.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.endpoint;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint deployment
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 29-Apr-2005
+ */
+@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.endpoint.EndpointInterface", targetNamespace =
"http://org.jboss.ws/jaxws/endpoint", serviceName =
"EndpointService")
+public class EndpointBean implements EndpointInterface
+{
+ public String echo(String input)
+ {
+ return input;
+ }
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointInterface.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.endpoint;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * Test the JSR-181 annotation: javax.jws.WebService
+ * This interface is only used in the client deployment.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 29-Apr-2005
+ */
+@WebService(targetNamespace = "http://org.jboss.ws/jaxws/endpoint")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface EndpointInterface extends Remote
+{
+ String echo(String input) throws RemoteException;
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointServlet.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.endpoint;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.DOMUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Tests Endpoint deployment in J2EE environment.
+ *
+ * @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+@SuppressWarnings("serial")
+public class EndpointServlet extends HttpServlet
+{
+
+ private Endpoint endpoint1;
+ private Endpoint endpoint2;
+ private static final String TEST_ELEMENT = "<fabrikam:CustomerKey
xmlns:fabrikam='http://example.com/fabrikam'>123456789</fab...;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+
+ endpoint1 = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, new EndpointBean());
+ endpoint1.publish("http://localhost:8081/jaxws-endpoint");
+ endpoint2 =
Endpoint.publish("http://localhost:8081/jaxws-endpoint2/endpoint/long/path",
EndpointBean.class);
+ }
+
+ @Override
+ public void destroy()
+ {
+ endpoint1.stop();
+ endpoint2.stop();
+
+ super.destroy();
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
+ {
+ // Create the port
+ URL wsdlURL =
getServletContext().getResource("/WEB-INF/wsdl/TestService.wsdl");
+ QName qname = new QName("http://org.jboss.ws/jaxws/endpoint",
"EndpointService");
+ Service service = Service.create(wsdlURL, qname);
+ EndpointInterface port =
(EndpointInterface)service.getPort(EndpointInterface.class);
+
+ // Invoke the endpoint
+ String param = req.getParameter("param");
+ String retStr = port.echo(param);
+
+ //Test epr
+
assertEndpointReference(endpoint1.getEndpointReference(DOMUtils.parse(TEST_ELEMENT)),
TEST_ELEMENT);
+ assertEndpointReference(endpoint1.getEndpointReference(W3CEndpointReference.class,
(Element[])null), null);
+
+ // Return the result
+ PrintWriter pw = new PrintWriter(res.getWriter());
+ pw.print(retStr);
+ pw.close();
+ }
+
+ private void assertEndpointReference(EndpointReference epr, String refPar) throws
IOException
+ {
+ Logger.getLogger(this.getClass()).info("epr: "+epr);
+ assert(W3CEndpointReference.class.getName().equals(epr.getClass().getName()));
+ Element endpointReference = DOMUtils.parse(epr.toString());
+ assert("EndpointReference".equals(endpointReference.getNodeName()));
+
assert("http://www.w3.org/2005/08/addressing".equals(endpointRe...;
+ NodeList addresses = endpointReference.getElementsByTagName("Address");
+ assert(addresses.getLength() == 1);
+
assert("http://127.0.0.1:8080/jaxws-endpoint".equals(addresses.item(0).getFirstChild().getNodeValue()));
+ if (refPar != null)
+ {
+ assert(epr.toString().contains(refPar));
+ }
+ }
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/EndpointTestCase.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.endpoint;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Test JAXWS Endpoint deployment
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 29-Apr-2005
+ */
+public class EndpointTestCase extends JBossWSTest
+{
+
+ public static Test suite()
+ {
+ return new TestSetup(new JBossWSTestSetup(EndpointTestCase.class,
"jaxws-endpoint-servlet.war"));
+ }
+
+ public void testWSDLAccess() throws Exception
+ {
+ readWSDL(new URL("http://" + getServerHost() +
":8081/jaxws-endpoint?wsdl"));
+ readWSDL(new URL("http://" + getServerHost() +
":8081/jaxws-endpoint2/endpoint/long/path?wsdl"));
+ }
+
+ public void testClientAccess() throws Exception
+ {
+ // Create the port
+ URL wsdlURL =
getResourceURL("jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl");
+ QName qname = new QName("http://org.jboss.ws/jaxws/endpoint",
"EndpointService");
+ Service service = Service.create(wsdlURL, qname);
+ EndpointInterface port =
(EndpointInterface)service.getPort(EndpointInterface.class);
+
+ String helloWorld = "Hello world!";
+ Object retObj = port.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+
+ public void testServletAccess() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() +
":8080/jaxws-endpoint-servlet?param=hello-world");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("hello-world", br.readLine());
+ }
+
+ private void readWSDL(URL wsdlURL) throws Exception
+ {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
+ assertNotNull(wsdlDefinition);
+ }
+
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,244 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.DHRequest;
+import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.DHResponse;
+import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.Endpoint1Iface;
+import org.jboss.test.ws.jaxws.endpoint.jse.endpoints.Endpoint1Impl;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * Tests endpoint dynamic publishing in JSE environment.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class UsecasesTestCase extends JBossWSTest
+{
+ private static WebServiceFeature[] mtomEnabled = new WebServiceFeature[] { new
MTOMFeature(true) };
+
+ private static int port1 = 8871;
+ private static int port2 = 8872;
+
+ public void testDifferentPortsSameContext() throws Exception
+ {
+ String publishURL1 = "http://" + getServerHost() + ":" + port1
+ "/jaxws-endpoint/";
+ Endpoint endpoint1 = publishEndpoint1(Endpoint1Impl.class, publishURL1);
+
+ String publishURL2 = "http://" + getServerHost() + ":" + port2
+ "/jaxws-endpoint";
+ Endpoint endpoint2 = publishEndpoint2(new Endpoint1Impl(), publishURL2);
+
+ invokeEndpoint1(publishURL1);
+ invokeEndpoint1(publishURL2);
+
+ endpoint1.stop();
+ endpoint2.stop();
+ }
+
+ public void testDifferentPortsNoContext() throws Exception
+ {
+ String publishURL1 = "http://" + getServerHost() + ":" + port1
+ "/";
+ Endpoint endpoint1 = publishEndpoint1(Endpoint1Impl.class, publishURL1);
+
+ String publishURL2 = "http://" + getServerHost() + ":" +
port2;
+ Endpoint endpoint2 = publishEndpoint2(new Endpoint1Impl(), publishURL2);
+
+ invokeEndpoint1(publishURL1);
+ invokeEndpoint1(publishURL2);
+
+ endpoint1.stop();
+ endpoint2.stop();
+ }
+
+ public void testDifferentPortsAndLongPaths() throws Exception
+ {
+ String publishURL1 = "http://" + getServerHost() + ":" + port1
+ "/jaxws-endpoint/endpoint/long/path/";
+ Endpoint endpoint1 = publishEndpoint3(Endpoint1Impl.class, publishURL1);
+
+ String publishURL2 = "http://" + getServerHost() + ":" + port2
+ "/jaxws-endpoint/endpoint/long/path";
+ Endpoint endpoint2 = publishEndpoint1(new Endpoint1Impl(), publishURL2);
+
+ invokeEndpoint1(publishURL1);
+ invokeEndpoint1(publishURL2);
+
+ endpoint1.stop();
+ endpoint2.stop();
+ }
+
+ public void testSamePortsAndAlmostIdenticalLongPaths() throws Exception
+ {
+ String publishURL1 = "http://" + getServerHost() + ":" + port1
+ "/jaxws-endpoint/endpoint/number1/";
+ Endpoint endpoint1 = publishEndpoint2(Endpoint1Impl.class, publishURL1);
+
+ String publishURL2 = "http://" + getServerHost() + ":" + port1
+ "/jaxws-endpoint/endpoint/number11";
+ Endpoint endpoint2 = publishEndpoint3(new Endpoint1Impl(), publishURL2);
+
+ invokeEndpoint2(publishURL1);
+ invokeEndpoint2(publishURL2);
+
+ endpoint1.stop();
+ endpoint2.stop();
+ }
+
+ public void testDifferentPortsAndIdenticalPaths() throws Exception
+ {
+ String publishURL1 = "http://" + getServerHost() + ":" + port1
+ "/jaxws-endpoint/endpoint/number1/";
+ Endpoint endpoint1 = publishEndpoint1(Endpoint1Impl.class, publishURL1);
+
+ String publishURL2 = "http://" + getServerHost() + ":" + port2
+ "/jaxws-endpoint/endpoint/number1";
+ Endpoint endpoint2 = publishEndpoint2(new Endpoint1Impl(), publishURL2);
+
+ invokeEndpoint2(publishURL1);
+ invokeEndpoint2(publishURL2);
+
+ endpoint1.stop();
+ endpoint2.stop();
+ }
+
+ public void testEndpointThrowingException() throws Exception
+ {
+ String publishURL = "http://" + getServerHost() + ":" + port1 +
"/jaxws-endpoint/endpoint/number1";
+ Endpoint endpoint = publishEndpoint3(Endpoint1Impl.class, publishURL);
+ invokeEndpoint3(publishURL);
+ endpoint.stop();
+ }
+
+ public void testEndpointProcessingAttachments() throws Exception
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ String publishURL = "http://" + getServerHost() + ":" +
port1 + "/jaxws-endpoint/endpoint/number1";
+ Endpoint endpoint = publishEndpoint3(Endpoint1Impl.class, publishURL);
+ invokeEndpoint4(publishURL);
+ endpoint.stop();
+ }
+ }
+
+ private Endpoint publishEndpoint1(Object epImpl, String publishURL)
+ {
+ Endpoint endpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, epImpl);
+ endpoint.publish(publishURL);
+ return endpoint;
+ }
+
+ private Endpoint publishEndpoint2(Object epImpl, String publishURL)
+ {
+ Endpoint endpoint = Endpoint.create(epImpl);
+ endpoint.publish(publishURL);
+ return endpoint;
+ }
+
+ private Endpoint publishEndpoint3(Object epImpl, String publishURL)
+ {
+ return Endpoint.publish(publishURL, epImpl);
+ }
+
+ private void invokeEndpoint1(String publishURL) throws Exception
+ {
+ Endpoint1Iface port = this.getProxy(publishURL);
+
+ String helloWorld = "Hello world!";
+ Object retObj = port.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+
+ private void invokeEndpoint2(String publishURL) throws Exception
+ {
+ Endpoint1Iface port = this.getProxy(publishURL);
+
+ String helloWorld = "Hello world!";
+
+ assertEquals(0, port.getCount());
+ Object retObj = port.echo(helloWorld);
+
+ assertEquals(helloWorld, retObj);
+ assertEquals(1, port.getCount());
+
+ port.echo(helloWorld);
+ assertEquals(2, port.getCount());
+ }
+
+ private void invokeEndpoint3(String publishURL) throws Exception
+ {
+ Endpoint1Iface port = this.getProxy(publishURL);
+
+ try
+ {
+ port.getException();
+ fail("Failure expected");
+ }
+ catch (Exception e)
+ {
+ assertEquals("Ooops", e.getMessage());
+ }
+ }
+
+ private void invokeEndpoint4(String publishURL) throws Exception
+ {
+ Endpoint1Iface port = this.getProxy(publishURL, mtomEnabled);
+
+ DataSource ds = new DataSource()
+ {
+ public String getContentType() { return "text/plain"; }
+ public InputStream getInputStream() throws IOException { return new
ByteArrayInputStream("some string".getBytes()); }
+ public String getName() { return "none"; }
+ public OutputStream getOutputStream() throws IOException { return null; }
+ };
+ DataHandler dh = new DataHandler(ds);
+ DHResponse response = port.echoDataHandler(new DHRequest(dh));
+ assertNotNull(response);
+
+ Object content = response.getDataHandler().getContent();
+ assertEquals("Server data", content);
+ String contentType = response.getDataHandler().getContentType();
+ assertEquals("text/plain", contentType);
+ }
+
+ private Endpoint1Iface getProxy(String publishURL) throws Exception
+ {
+ return this.getProxy(publishURL, null);
+ }
+
+ private Endpoint1Iface getProxy(String publishURL, WebServiceFeature[] features)
throws Exception
+ {
+ URL wsdlURL = new URL(publishURL + "?wsdl");
+ QName qname = new
QName("http://org.jboss.ws/jaxws/endpoint/jse/endpoints/",
"Endpoint1Impl");
+ Service service = Service.create(wsdlURL, qname);
+ return (Endpoint1Iface)service.getPort(Endpoint1Iface.class, features);
+ }
+
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHRequest.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse.endpoints;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+(
+ name = "dataRequest",
+ namespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/"
+)
+public class DHRequest
+{
+
+ private DataHandler dataHandler;
+
+ public DHRequest()
+ {
+ }
+
+ public DHRequest(DataHandler dataHandler)
+ {
+ this.dataHandler = dataHandler;
+ }
+
+ @XmlMimeType("text/plain")
+ public DataHandler getDataHandler()
+ {
+ return dataHandler;
+ }
+
+ public void setDataHandler(DataHandler dataHandler)
+ {
+ this.dataHandler = dataHandler;
+ }
+
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/DHResponse.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse.endpoints;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+(
+ name="dataResponse",
+ namespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/"
+)
+public class DHResponse {
+
+
+ private DataHandler dataHandler;
+
+
+ public DHResponse() {
+ }
+
+ public DHResponse(DataHandler dataHandler) {
+ this.dataHandler = dataHandler;
+ }
+
+ @XmlMimeType("text/plain")
+ public DataHandler getDataHandler() {
+ return dataHandler;
+ }
+
+ public void setDataHandler(DataHandler dataHandler) {
+ this.dataHandler = dataHandler;
+ }
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Iface.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse.endpoints;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * Service interface.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+@WebService(targetNamespace =
"http://org.jboss.ws/jaxws/endpoint/jse/endpoints/")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface Endpoint1Iface
+{
+ String echo(String input);
+ int getCount();
+ void getException();
+ DHResponse echoDataHandler(DHRequest request);
+}
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/endpoint/jse/endpoints/Endpoint1Impl.java 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.endpoint.jse.endpoints;
+
+import java.io.IOException;
+
+import javax.activation.DataHandler;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+
+/**
+ * Service implementation.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+@WebService
+(
+ serviceName = "Endpoint1Impl",
+ targetNamespace = "http://org.jboss.ws/jaxws/endpoint/jse/endpoints/",
+ endpointInterface =
"org.jboss.test.ws.jaxws.endpoint.jse.endpoints.Endpoint1Iface"
+)
+@MTOM
+public class Endpoint1Impl implements Endpoint1Iface
+{
+
+ private int count;
+ private boolean initialized;
+
+ public String echo(String input)
+ {
+ count++;
+ return input;
+ }
+
+ @PostConstruct
+ public void init()
+ {
+ this.initialized = true;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ //nothing to do
+ }
+
+ public int getCount()
+ {
+ this.ensureInit();
+ return count;
+ }
+
+ public void getException()
+ {
+ this.ensureInit();
+ throw new WebServiceException("Ooops");
+ }
+
+ public DHResponse echoDataHandler(DHRequest request)
+ {
+ this.ensureInit();
+ DataHandler dataHandler = request.getDataHandler();
+
+ try
+ {
+ if (!dataHandler.getContentType().equals("text/plain"))
+ {
+ throw new WebServiceException("Wrong content type");
+ }
+ if (!dataHandler.getContent().equals("some string"))
+ {
+ throw new WebServiceException("Wrong data");
+ }
+ }
+ catch (IOException e)
+ {
+ throw new WebServiceException(e);
+ }
+
+ DataHandler responseData = new DataHandler("Server data",
"text/plain");
+ return new DHResponse(responseData);
+ }
+
+ private void ensureInit()
+ {
+ if (!this.initialized)
+ throw new IllegalStateException();
+ }
+
+}
Added: framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/web.xml
===================================================================
--- framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/web.xml
(rev 0)
+++ framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/web.xml 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,20 @@
+<?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>TestService</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.endpoint.EndpointServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
Added:
framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl
===================================================================
--- framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl
(rev 0)
+++
framework/trunk/testsuite/test/resources/jaxws/endpoint/WEB-INF/wsdl/TestService.wsdl 2010-08-13
13:47:53 UTC (rev 12812)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<definitions name="EndpointService"
targetNamespace="http://org.jboss.ws/jaxws/endpoint"
xmlns:tns="http://org.jboss.ws/jaxws/endpoint"
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types/>
+ <message name="EndpointInterface_echo">
+ <part name="String_1" type="xsd:string"/>
+ </message>
+ <message name="EndpointInterface_echoResponse">
+ <part name="result" type="xsd:string"/>
+ </message>
+ <portType name="EndpointInterface">
+ <operation name="echo" parameterOrder="String_1">
+ <input message="tns:EndpointInterface_echo"/>
+ <output message="tns:EndpointInterface_echoResponse"/>
+ </operation>
+ </portType>
+ <binding name="EndpointInterfaceBinding"
type="tns:EndpointInterface">
+ <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="rpc"/>
+ <operation name="echo">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"
namespace="http://org.jboss.ws/jaxws/endpoint"/>
+ </input>
+ <output>
+ <soap:body use="literal"
namespace="http://org.jboss.ws/jaxws/endpoint"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="EndpointService">
+ <port name="EndpointInterfacePort"
binding="tns:EndpointInterfaceBinding">
+ <soap:address
location="http://@jboss.bind.address@:8081/jaxws-endpoint"/>
+ </port>
+ </service>
+</definitions>