diff --git a/modules/activiti-cxf/pom.xml b/modules/activiti-cxf/pom.xml index 13bb89b34564c06c1deead5acf49b8132793c017..71d482c1b71d9f5dbd320ff394d6596a785ee8f2 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 0000000000000000000000000000000000000000..0989543704ab759a6f187aef342e4e73d4aed022 --- /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 0000000000000000000000000000000000000000..d3cc6f9d1a9e2e6f4185a3c9a675ba5449d5d1ad --- /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 0000000000000000000000000000000000000000..06b0c1121dc5db8b8ac99401f705ef65c40fe894 --- /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 0000000000000000000000000000000000000000..a0ca5e6c0a21010eb1c08caf03d2c9e3e728bc63 --- /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 0000000000000000000000000000000000000000..451fd2c1cd21457b81cc17484295aa471aa8a6d9 --- /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 8e30d820e431adbbee93b79c83ee4f206b44765b..2c5cf9aeb2cae470f08a6205ff82838ff6416925 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