Author: alessio.soldano(a)jboss.com
Date: 2012-05-16 11:00:53 -0400 (Wed, 16 May 2012)
New Revision: 16284
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java
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/JBWS3497TestCase.java
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/cxf.xml
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/jbossws-cxf.xml
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/web.xml
Modified:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3497] Adding testcase for workaround
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-05-15
11:19:42 UTC (rev 16283)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/scripts/cxf-jars-jaxws.xml 2012-05-16
15:00:53 UTC (rev 16284)
@@ -114,6 +114,24 @@
</webinf>
</war>
+ <!-- jaxws-cxf-jbws-3497-->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-cxf-jbws3497.war"
webxml="${tests.output.dir}/test-resources/jaxws/cxf/jbws3497/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/jbws3497/Endpoint*.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/cxf/jbws3497/WEB-INF">
+ <include name="jbossws-cxf.xml"/>
+ </webinf>
+ <zipfileset
+ dir="${tests.output.dir}/test-resources/jaxws/cxf/jbws3497/WEB-INF"
+ prefix="WEB-INF/classes">
+ <include name="cxf.xml"/>
+ </zipfileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.apache.cxf"/>
+ </manifest>
+ </war>
+
<!-- jaxws-cxf-jms-api -->
<war warfile="${tests.output.dir}/test-libs/jaxws-cxf-jms-api-as7.war"
needxmlfile='false'>
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java 2012-05-16
15:00:53 UTC (rev 16284)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jbws3497;
+
+import javax.jws.Oneway;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface EndpointOne
+{
+ String echo(String input);
+
+ @Oneway
+ void echoOneWay(String input);
+
+ int getCount();
+}
Added:
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
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-05-16
15:00:53 UTC (rev 16284)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jbws3497;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+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.apache.cxf.workqueue.AutomaticWorkQueueImpl;
+import org.jboss.logging.Logger;
+
+@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public class EndpointOneImpl
+{
+ private static AtomicInteger count = new AtomicInteger(0);
+
+ @WebMethod
+ public String echo(String input)
+ {
+ Bus bus = BusFactory.getThreadDefaultBus(false);
+ ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
+ AutomaticWorkQueueImpl queue =
(AutomaticWorkQueueImpl)locator.getBeanOfType("cxf.default.workqueue",
AutomaticWorkQueue.class);
+ if (queue.getMaxSize() != 10) {
+ throw new RuntimeException("Expected max queue size '10' but got
'" + queue.getMaxSize() + "'!");
+ }
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ count.incrementAndGet();
+ return input;
+ }
+
+ @WebMethod
+ @Oneway
+ public void echoOneWay(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echoOneWay: " + input);
+ count.incrementAndGet();
+ }
+
+ @WebMethod
+ public int getCount()
+ {
+ return count.get();
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java 2012-05-16
15:00:53 UTC (rev 16284)
@@ -0,0 +1,139 @@
+/*
+ * 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.jbws3497;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+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;
+
+/**
+ * [JBWS-3497] Add ability to configure the queue depth on the asynchronous (@Oneway)
work queue.
+ * This testcase basically verifies the initial workaround for the issue works.
+ *
+ * @author alessio.soldano(a)jboss.com
+ *
+ */
+public class JBWS3497TestCase extends JBossWSTest
+{
+ private String endpointOneURL = "http://" + getServerHost() +
":8080/jaxws-cxf-jbws3497/ServiceOne/EndpointOne";
+ private String targetNS = "http://org.jboss.ws.jaxws.cxf/jbws3497";
+
+ private EndpointOne portOne;
+
+ protected int defaultSize = 200;
+
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(JBWS3497TestCase.class,
"jaxws-cxf-jbws3497.war");
+ }
+
+ public void testAccess() throws Exception
+ {
+ initPorts();
+ int count1 = portOne.getCount();
+ Object retObj = portOne.echo("Hello");
+ assertEquals("Hello", retObj);
+ assertEquals(1, portOne.getCount() - count1);
+ }
+
+ //Disabled as there's no easy way for knowing the server is logging WARN messages
saying the @OneWay processing queue is full.
+ //Manually enable this test if willing to check (and try modifying 'queueSize'
value in cxf.xml); otherwise the EndpointOne
+ //implementation simply checks the related AutomaticWorkQueue is properly configured.
+ public void _testConcurrentOneWayInvocations() throws Exception
+ {
+ runConcurrentTests(true);
+ }
+
+ private void runConcurrentTests(boolean oneway) throws Exception
+ {
+ initPorts();
+ final int size = defaultSize;
+ int count1 = portOne.getCount();
+ ExecutorService es = Executors.newFixedThreadPool(size);
+ List<Callable<Boolean>> callables = new
ArrayList<Callable<Boolean>>(size*3);
+ for (int i = 0; i < size*3; i++)
+ {
+ callables.add(new CallableOne(portOne, oneway, i));
+ }
+ List<Future<Boolean>> futures = es.invokeAll(callables);
+ for (Future<Boolean> f : futures)
+ {
+ assertTrue(f.get());
+ }
+ if (oneway) {
+ Thread.sleep(3000);
+ }
+ assertEquals(size*3, portOne.getCount() - count1);
+ }
+
+ private void initPorts() throws MalformedURLException
+ {
+ URL wsdlOneURL = new URL(endpointOneURL + "?wsdl");
+ QName serviceOneName = new QName(targetNS, "ServiceOne");
+ Service serviceOne = Service.create(wsdlOneURL, serviceOneName);
+ portOne = (EndpointOne)serviceOne.getPort(EndpointOne.class);
+ }
+
+ private static class CallableOne implements Callable<Boolean>
+ {
+ private EndpointOne port;
+ private boolean oneway;
+ private int seqNum;
+
+ public CallableOne(EndpointOne port, boolean oneway, int seqNum)
+ {
+ this.port = port;
+ this.oneway = oneway;
+ this.seqNum = seqNum;
+ }
+
+ public Boolean call() throws Exception
+ {
+ String arg = "Foo" + seqNum;
+ if (oneway)
+ {
+ port.echoOneWay(arg);
+ return true;
+ }
+ else
+ {
+ String result = port.echo(arg);
+ return arg.equals(result);
+ }
+ }
+ }
+
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/cxf.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/cxf.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/cxf.xml 2012-05-16
15:00:53 UTC (rev 16284)
@@ -0,0 +1,10 @@
+<beans
xmlns="http://www.springframework.org/schema/beans"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="cxf.default.workqueue"
class="org.apache.cxf.workqueue.AutomaticWorkQueueImpl">
+ <property name="name" value="cxf.default.workqueue"/>
+ <property name="queueSize" value="10"/>
+ </bean>
+
+</beans>
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/jbossws-cxf.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/jbossws-cxf.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/jbossws-cxf.xml 2012-05-16
15:00:53 UTC (rev 16284)
@@ -0,0 +1,11 @@
+<beans
xmlns='http://www.springframework.org/schema/beans'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:beans='http://www.springframework.org/schema/beans'
+
xmlns:jaxws='http://cxf.apache.org/jaxws'
+
xsi:schemaLocation='http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+
http://www.w3.org/2006/07/ws-policy http://www.w3.org/2006/07/ws-policy.xsd
+
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd'>
+
+ <jaxws:endpoint id='EJBEndpointService'
address='http://@jboss.bind.address@:8080/jaxws-cxf-jbws3497/ServiceOne/EndpointOne'
+ implementor='org.jboss.test.ws.jaxws.cxf.jbws3497.EndpointOneImpl'>
+ </jaxws:endpoint>
+
+</beans>
Added:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/jbws3497/WEB-INF/web.xml 2012-05-16
15:00:53 UTC (rev 16284)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
+
+ <servlet>
+ <servlet-name>Ep1Servlet</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.cxf.jbws3497.EndpointOneImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Ep1Servlet</servlet-name>
+ <url-pattern>/ServiceOne/EndpointOne</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file