Author: alessio.soldano(a)jboss.com
Date: 2011-07-19 05:05:22 -0400 (Tue, 19 Jul 2011)
New Revision: 14701
Added:
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointImpl2.java
Modified:
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java
Log:
Updating testcase for deployment of multiple endpoints in the same context
Added:
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointImpl2.java
===================================================================
---
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointImpl2.java
(rev 0)
+++
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointImpl2.java 2011-07-19
09:05:22 UTC (rev 14701)
@@ -0,0 +1,39 @@
+/*
+ * 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.publish;
+
+import javax.jws.WebService;
+
+import org.jboss.logging.Logger;
+
+@WebService(serviceName="EndpointService", portName="EndpointPort",
endpointInterface = "org.jboss.test.ws.publish.Endpoint")
+public class EndpointImpl2
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(EndpointImpl2.class);
+
+ public String echo(String input)
+ {
+ log.info("echo (2): " + input);
+ return input;
+ }
+}
Modified:
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java
===================================================================
---
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java 2011-07-18
18:09:54 UTC (rev 14700)
+++
shared-testsuite/branches/asoldano/testsuite/src/test/java/org/jboss/test/ws/publish/EndpointPublishServlet.java 2011-07-19
09:05:22 UTC (rev 14701)
@@ -26,9 +26,11 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.ServiceLoader;
import javax.servlet.ServletException;
@@ -41,6 +43,7 @@
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.publish.Context;
import org.jboss.wsf.spi.publish.EndpointPublisher;
import org.jboss.wsf.spi.publish.EndpointPublisherFactory;
@@ -58,31 +61,30 @@
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
- Endpoint ep = null;
+ Context ctx = null;
EndpointPublisher publisher = null;
try
{
- //deploy endpoint
+ //deploy endpoints
ClassLoader loader =
ClassLoaderProvider.getDefaultProvider().getWebServiceSubsystemClassLoader();
EndpointPublisherFactory factory =
ServiceLoader.load(EndpointPublisherFactory.class, loader).iterator().next();
publisher = factory.newEndpointPublisher("default-host");
- ep = publisher.publish("org.jboss.test.ws.publish.EndpointImpl",
Thread.currentThread().getContextClassLoader(), "ep-publish-test",
"/pattern");
- System.out.println("State: " + ep.getState());
- System.out.println("Address: " + ep.getAddress());
- System.out.println("TargetBeanClass: " + ep.getTargetBeanClass());
+ Map<String,String> map = new HashMap<String, String>();
+ map.put("/pattern",
"org.jboss.test.ws.publish.EndpointImpl");
+ map.put("/pattern2",
"org.jboss.test.ws.publish.EndpointImpl2");
- //call endpoint
- URL wsdlURL = new
URL("http://localhost:8080/ep-publish-test/pattern?wsdl");
- QName serviceName = new
QName("http://publish.ws.test.jboss.org/",
"EndpointService");
- Service service = Service.create(wsdlURL, serviceName);
- org.jboss.test.ws.publish.Endpoint port =
service.getPort(org.jboss.test.ws.publish.Endpoint.class);
- String result = port.echo("Foo");
- if (!"Foo".equals(result))
- {
- throw new Exception("Expected 'Foo' but got '" + result
+ "'");
+ ctx = publisher.publish("ep-publish-test",
Thread.currentThread().getContextClassLoader(), map);
+ for (Endpoint ep : ctx.getEndpoints()) {
+ System.out.println("State: " + ep.getState());
+ System.out.println("Address: " + ep.getAddress());
+ System.out.println("TargetBeanClass: " + ep.getTargetBeanClass());
}
+ //call endpoint
+ invoke(new
URL("http://localhost:8080/ep-publish-test/pattern?wsdl"));
+ invoke(new
URL("http://localhost:8080/ep-publish-test/pattern2?wsdl"));
+
res.getWriter().print("1");
}
catch (Exception e)
@@ -92,12 +94,12 @@
}
finally
{
- if (ep != null && publisher != null)
+ if (ctx != null && publisher != null)
{
try
{
- //undeploy endpoint
- publisher.destroy(ep);
+ //undeploy endpoints
+ publisher.destroy(ctx);
}
catch (Exception e)
{
@@ -107,4 +109,15 @@
}
}
}
+
+ private static void invoke(URL wsdlURL) throws Exception {
+ QName serviceName = new
QName("http://publish.ws.test.jboss.org/",
"EndpointService");
+ Service service = Service.create(wsdlURL, serviceName);
+ org.jboss.test.ws.publish.Endpoint port =
service.getPort(org.jboss.test.ws.publish.Endpoint.class);
+ String result = port.echo("Foo");
+ if (!"Foo".equals(result))
+ {
+ throw new Exception("Expected 'Foo' but got '" + result +
"'");
+ }
+ }
}