Author: alessio.soldano(a)jboss.com
Date: 2012-06-13 10:32:04 -0400 (Wed, 13 Jun 2012)
New Revision: 16408
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java
Modified:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml
Log:
[JBWS-3513] Adding testcase + fixing existing one to avoid assuming the thread bus is the
deployment one
Modified: stack/cxf/trunk/modules/testsuite/cxf-spring-tests/scripts/cxf-jars-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/scripts/cxf-jars-jaxws.xml 2012-06-13
14:27:55 UTC (rev 16407)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/scripts/cxf-jars-jaxws.xml 2012-06-13
14:32:04 UTC (rev 16408)
@@ -128,7 +128,7 @@
<include name="cxf.xml"/>
</zipfileset>
<manifest>
- <attribute name="Dependencies"
value="org.apache.cxf"/>
+ <attribute name="Dependencies"
value="org.apache.cxf,org.jboss.ws.cxf.jbossws-cxf-server"/>
</manifest>
</war>
Modified:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-06-13
14:27:55 UTC (rev 16407)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-06-13
14:32:04 UTC (rev 16408)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -29,10 +29,11 @@
import javax.jws.soap.SOAPBinding;
import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
import org.apache.cxf.configuration.ConfiguredBeanLocator;
import org.apache.cxf.workqueue.AutomaticWorkQueue;
import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@@ -43,10 +44,10 @@
@WebMethod
public String echo(String input)
{
- Bus bus = BusFactory.getThreadDefaultBus(false);
+ //this is just a verification of a workaround, so going the dirty way...
+ Bus bus =
EndpointAssociation.getEndpoint().getService().getDeployment().getAttachment(BusHolder.class).getBus();
ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
AutomaticWorkQueue queue = locator.getBeanOfType("cxf.default.workqueue",
AutomaticWorkQueue.class);
- //this is just a verification of a workaround, so going the dirty way...
Long qs = null;
try
{
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-06-13
14:27:55 UTC (rev 16407)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-06-13
14:32:04 UTC (rev 16408)
@@ -41,9 +41,14 @@
<!-- jaxws-cxf-bus -->
<war warfile="${tests.output.dir}/test-libs/jaxws-cxf-bus.war"
webxml="${tests.output.dir}/test-resources/jaxws/cxf/bus/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.class"/>
+ <include
name="org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.class"/>
<include name="org/jboss/test/ws/jaxws/cxf/bus/Endpoint.class"/>
<include
name="org/jboss/test/ws/jaxws/cxf/bus/EndpointImpl.class"/>
</classes>
+ <manifest>
+ <attribute name="Dependencies"
value="org.apache.cxf"/>
+ </manifest>
</war>
<!-- jaxws-cxf-bus-ejb3-client -->
<jar
destfile="${tests.output.dir}/test-libs/jaxws-cxf-bus-ejb3-client.jar">
@@ -203,7 +208,7 @@
<include name="**/*" />
</metainf>
<manifest>
- <attribute name="Dependencies"
value="org.apache.cxf"/>
+ <attribute name="Dependencies"
value="org.apache.cxf,org.jboss.ws.cxf.jbossws-cxf-server"/>
</manifest>
</jar>
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpoint.java 2012-06-13
14:32:04 UTC (rev 16408)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.cxf.bus;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService(name = "Endpoint", targetNamespace =
"http://org.jboss.ws/bus")
+public interface ClientEndpoint
+{
+ @WebMethod
+ public String testClient(String input, String host) throws Exception;
+
+ @WebMethod
+ public String testCachedPort(String input, String host) throws Exception;
+
+ @WebMethod
+ public String testCachedService(String input, String host) throws Exception;
+
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointBusTestCase.java 2012-06-13
14:32:04 UTC (rev 16408)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.cxf.bus;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * A test case that verifies a client running inside and endpoint business method
+ * does not use the deployment bus.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 13-Jun-2012
+ *
+ */
+public class ClientEndpointBusTestCase extends JBossWSTest
+{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-cxf-bus/ClientEndpointService/ClientEndpoint";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(ClientEndpointBusTestCase.class,
"jaxws-cxf-bus.war");
+ }
+
+ public void testClient() throws Exception
+ {
+ ClientEndpoint port = getPort();
+ assertEquals("Foo", port.testClient("Foo", getServerHost()));
+ }
+
+ public void testCachedPort() throws Exception
+ {
+ ClientEndpoint port = getPort();
+ assertEquals("Foo", port.testCachedPort("Foo",
getServerHost()));
+ }
+
+ public void testCachedService() throws Exception
+ {
+ ClientEndpoint port = getPort();
+ assertEquals("Foo", port.testCachedService("Foo",
getServerHost()));
+ }
+
+ private ClientEndpoint getPort() throws Exception {
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://org.jboss.ws/bus",
"ClientEndpointService");
+ Service service = Service.create(wsdlURL, serviceName);
+ QName portQName = new QName("http://org.jboss.ws/bus",
"ClientEndpointPort");
+ return (ClientEndpoint) service.getPort(portQName, ClientEndpoint.class);
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/bus/ClientEndpointImpl.java 2012-06-13
14:32:04 UTC (rev 16408)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.cxf.bus;
+
+import java.net.URL;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.BusFactory;
+
+@WebService(name = "ClientEndpoint", serviceName =
"ClientEndpointService", targetNamespace = "http://org.jboss.ws/bus")
+public class ClientEndpointImpl
+{
+ @WebMethod
+ public String testClient(String input, String host) throws Exception
+ {
+ if (BusFactory.getThreadDefaultBus(false) != null) {
+ throw new Exception("Expected null thread default bus, but got " +
BusFactory.getThreadDefaultBus(false));
+ }
+ Endpoint endpoint = getPort(getWsdlURL(host));
+ return endpoint.echo(input);
+ }
+
+ @WebMethod
+ public String testCachedPort(String input, String host) throws Exception
+ {
+ if (BusFactory.getThreadDefaultBus(false) != null) {
+ throw new Exception("Expected null thread default bus, but got " +
BusFactory.getThreadDefaultBus(false));
+ }
+ Endpoint port = getPort(getWsdlURL(host));
+ BusFactory.setThreadDefaultBus(null);
+ return port.echo(input);
+ }
+
+ @WebMethod
+ public String testCachedService(String input, String host) throws Exception
+ {
+ if (BusFactory.getThreadDefaultBus(false) != null) {
+ throw new Exception("Expected null thread default bus, but got " +
BusFactory.getThreadDefaultBus(false));
+ }
+ Service service = getService(getWsdlURL(host));
+ BusFactory.setThreadDefaultBus(null);
+ Endpoint port = getPort(service);
+ return port.echo(input);
+ }
+
+ private static URL getWsdlURL(String host) throws Exception
+ {
+ return new URL("http://" + host +
":8080/jaxws-cxf-bus/EndpointService/Endpoint?wsdl");
+ }
+
+ private static Endpoint getPort(URL wsdlURL)
+ {
+ Service service = getService(wsdlURL);
+ return getPort(service);
+ }
+
+ private static Endpoint getPort(Service service)
+ {
+ QName portQName = new QName("http://org.jboss.ws/bus",
"EndpointPort");
+ return (Endpoint) service.getPort(portQName, Endpoint.class);
+ }
+
+ private static Service getService(URL wsdlURL)
+ {
+ QName serviceName = new QName("http://org.jboss.ws/bus",
"EndpointService");
+ return Service.create(wsdlURL, serviceName);
+ }
+}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-06-13
14:27:55 UTC (rev 16407)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-06-13
14:32:04 UTC (rev 16408)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -23,17 +23,20 @@
import java.util.concurrent.atomic.AtomicInteger;
+import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.WebServiceContext;
import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
import org.apache.cxf.workqueue.AutomaticWorkQueue;
import org.apache.cxf.workqueue.WorkQueueManager;
import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@@ -42,12 +45,15 @@
{
private static AtomicInteger count = new AtomicInteger(0);
+ @Resource
+ WebServiceContext ctx;
+
@WebMethod
public String echo(String input)
{
- Bus bus = BusFactory.getThreadDefaultBus(false);
+ //this is just a verification, so going the dirty way...
+ Bus bus =
EndpointAssociation.getEndpoint().getService().getDeployment().getAttachment(BusHolder.class).getBus();
AutomaticWorkQueue queue =
bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
- //this is just a verification, so going the dirty way...
Long qs = null;
Integer it = null;
try
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml 2012-06-13
14:27:55 UTC (rev 16407)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/bus/WEB-INF/web.xml 2012-06-13
14:32:04 UTC (rev 16408)
@@ -9,8 +9,18 @@
<servlet-class>org.jboss.test.ws.jaxws.cxf.bus.EndpointImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>Ep2Servlet</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.cxf.bus.ClientEndpointImpl</servlet-class>
+ </servlet>
+
<servlet-mapping>
<servlet-name>EpServlet</servlet-name>
<url-pattern>/EndpointService/Endpoint</url-pattern>
</servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Ep2Servlet</servlet-name>
+ <url-pattern>/ClientEndpointService/ClientEndpoint</url-pattern>
+ </servlet-mapping>
</web-app>
\ No newline at end of file