From df988731b893775d95b26c197d719c45fd2ef075 Mon Sep 17 00:00:00 2001 From: gnt Date: Tue, 19 Oct 2010 14:05:10 +0000 Subject: [PATCH] [ACT-221] Add an integration test for the webservice task solely based on CXF --- modules/activiti-cxf/pom.xml | 10 +++ .../engine/impl/webservice/Counter.java | 61 +++++++++++++++++ .../engine/impl/webservice/CounterImpl.java | 66 +++++++++++++++++++ .../impl/webservice/WebServiceTaskTest.java | 64 ++++++++++++++++++ .../src/test/resources/activiti.properties | 8 +++ ...skTest.testWebServiceInvocation.bpmn20.xml | 50 ++++++++++++++ pom.xml | 15 +++++ 7 files changed, 274 insertions(+) create mode 100644 modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/Counter.java create mode 100644 modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/CounterImpl.java create mode 100644 modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/WebServiceTaskTest.java create mode 100644 modules/activiti-cxf/src/test/resources/activiti.properties create mode 100644 modules/activiti-cxf/src/test/resources/org/activiti/engine/impl/webservice/WebServiceTaskTest.testWebServiceInvocation.bpmn20.xml diff --git a/modules/activiti-cxf/pom.xml b/modules/activiti-cxf/pom.xml index 13bb89b345..71d482c1b7 100644 --- a/modules/activiti-cxf/pom.xml +++ b/modules/activiti-cxf/pom.xml @@ -41,6 +41,16 @@ org.apache.cxf cxf-rt-frontend-jaxws + + com.h2database + h2 + test + + + org.apache.cxf + cxf-rt-transports-http-jetty + test + diff --git a/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/Counter.java b/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/Counter.java new file mode 100644 index 0000000000..0989543704 --- /dev/null +++ b/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/Counter.java @@ -0,0 +1,61 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.activiti.engine.impl.webservice; + +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; + +/** + * A simple Counter WS that starts the counter in -1 + * + * @author Esteban Robles Luna + */ +@WebService +public interface Counter { + + /** + * Increase the counter in 1 + */ + void inc(); + + /** + * Returns the current count + * + * @return the count + */ + @WebResult(name="count") + int getCount(); + + /** + * Resets the counter to 0 + */ + void reset(); + + /** + * Sets the counter to value + * + * @param value the value of the new counter + */ + void setTo(@WebParam(name="value") int value); + + /** + * Returns a formated string composed of prefix + current count + suffix + * + * @param prefix the prefix + * @param suffix the suffix + * @return the formated string + */ + @WebResult(name="prettyPrint") + String prettyPrintCount(@WebParam(name="prefix") String prefix, @WebParam(name="suffix") String suffix); +} diff --git a/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/CounterImpl.java b/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/CounterImpl.java new file mode 100644 index 0000000000..d3cc6f9d1a --- /dev/null +++ b/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/CounterImpl.java @@ -0,0 +1,66 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.activiti.engine.impl.webservice; + +import javax.jws.WebService; + +/** + * An implementation of a Counter WS + * + * @author Esteban Robles Luna + */ +@WebService(endpointInterface = "org.activiti.engine.impl.webservice.Counter", + serviceName = "Counter") +public class CounterImpl implements Counter { + + protected int count; + + public CounterImpl() { + this.count = -1; + } + + /** + * {@inheritDoc} + */ + public int getCount() { + return this.count; + } + + /** + * {@inheritDoc} + */ + public void inc() { + this.count++; + } + + /** + * {@inheritDoc} + */ + public void reset() { + this.setTo(0); + } + + /** + * {@inheritDoc} + */ + public void setTo(int value) { + this.count = value; + } + + /** + * {@inheritDoc} + */ + public String prettyPrintCount(String prefix, String suffix) { + return prefix + this.getCount() + suffix; + } +} \ No newline at end of file diff --git a/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/WebServiceTaskTest.java b/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/WebServiceTaskTest.java new file mode 100644 index 0000000000..06b0c1121d --- /dev/null +++ b/modules/activiti-cxf/src/test/java/org/activiti/engine/impl/webservice/WebServiceTaskTest.java @@ -0,0 +1,64 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.activiti.engine.impl.webservice; + +import org.activiti.engine.impl.test.ActivitiInternalTestCase; +import org.activiti.engine.test.Deployment; +import org.apache.cxf.endpoint.Server; +import org.apache.cxf.interceptor.LoggingInInterceptor; +import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.jaxws.JaxWsServerFactoryBean; + +/** + * An integration test for CXF based web services + * + * @author Guillaume Nodet + */ +public class WebServiceTaskTest extends ActivitiInternalTestCase { + + private Counter counter; + private Server server; + + @Override + protected void initializeProcessEngine() { + super.initializeProcessEngine(); + + counter = new CounterImpl(); + JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); + svrFactory.setServiceClass(Counter.class); + svrFactory.setAddress("http://localhost:63081/counter"); + svrFactory.setServiceBean(counter); + svrFactory.getInInterceptors().add(new LoggingInInterceptor()); + svrFactory.getOutInterceptors().add(new LoggingOutInterceptor()); + server = svrFactory.create(); + server.start(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + server.stop(); + } + + @Deployment + public void testWebServiceInvocation() throws Exception { + + assertEquals(-1, counter.getCount()); + + runtimeService.startProcessInstanceByKey("webServiceInvocation"); + waitForJobExecutorToProcessAllJobs(10000L, 250L); + + assertEquals(0, counter.getCount()); + } + +} diff --git a/modules/activiti-cxf/src/test/resources/activiti.properties b/modules/activiti-cxf/src/test/resources/activiti.properties new file mode 100644 index 0000000000..a0ca5e6c0a --- /dev/null +++ b/modules/activiti-cxf/src/test/resources/activiti.properties @@ -0,0 +1,8 @@ +database=h2 +jdbc.driver=org.h2.Driver +jdbc.url=jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000 +jdbc.username=sa +jdbc.password= +db.schema.strategy=create-drop +job.executor.auto.activate=off +ws.sync.factory=org.activiti.engine.impl.webservice.CxfWebServiceClientFactory diff --git a/modules/activiti-cxf/src/test/resources/org/activiti/engine/impl/webservice/WebServiceTaskTest.testWebServiceInvocation.bpmn20.xml b/modules/activiti-cxf/src/test/resources/org/activiti/engine/impl/webservice/WebServiceTaskTest.testWebServiceInvocation.bpmn20.xml new file mode 100644 index 0000000000..451fd2c1cd --- /dev/null +++ b/modules/activiti-cxf/src/test/resources/org/activiti/engine/impl/webservice/WebServiceTaskTest.testWebServiceInvocation.bpmn20.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + incRequestMessage + incResponseMessage + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8e30d820e4..2c5cf9aeb2 100644 --- a/pom.xml +++ b/pom.xml @@ -219,6 +219,21 @@ cxf-rt-frontend-jaxws 2.1.2 + + org.apache.cxf + cxf-rt-transports-http + 2.1.2 + + + org.apache.cxf + cxf-rt-transports-http-jetty + 2.1.2 + + + org.apache.cxf + cxf-rt-bindings-soap + 2.1.2 + org.mule.transports mule-transport-cxf -- GitLab