diff --git a/modules/activiti-camel/src/test/java/org/activiti/camel/AsyncProcessTest.java b/modules/activiti-camel/src/test/java/org/activiti/camel/AsyncProcessTest.java new file mode 100644 index 0000000000000000000000000000000000000000..54bb3506de47059952163b5887e4000c3b7ce934 --- /dev/null +++ b/modules/activiti-camel/src/test/java/org/activiti/camel/AsyncProcessTest.java @@ -0,0 +1,40 @@ +/* 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.camel; + +import java.util.List; + +import org.activiti.engine.RuntimeService; +import org.activiti.engine.runtime.Execution; +import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.test.Deployment; +import org.activiti.spring.impl.test.SpringActivitiTestCase; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +@ContextConfiguration("classpath:camel-activiti-context.xml") +public class AsyncProcessTest extends SpringActivitiTestCase { + + @Autowired + RuntimeService runtimeService; + + @Deployment(resources = {"process/async.bpmn20.xml"}) + public void testRunProcess() throws Exception { + ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncCamelProcess"); + List executionList = runtimeService.createExecutionQuery().list(); + assertEquals(3, executionList.size()); + Thread.sleep(4000); + assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()); + } +} diff --git a/modules/activiti-camel/src/test/java/org/activiti/camel/InitDelegate.java b/modules/activiti-camel/src/test/java/org/activiti/camel/InitDelegate.java new file mode 100644 index 0000000000000000000000000000000000000000..608d3a15c2d4a58f66dcf3526cb8dbbdb1dbb6d5 --- /dev/null +++ b/modules/activiti-camel/src/test/java/org/activiti/camel/InitDelegate.java @@ -0,0 +1,13 @@ +package org.activiti.camel; + +import org.activiti.engine.delegate.DelegateExecution; +import org.activiti.engine.delegate.JavaDelegate; + +public class InitDelegate implements JavaDelegate { + + @Override + public void execute(DelegateExecution execution) throws Exception { + execution.setVariable(ActivitiProducer.PROCESS_ID_PROPERTY, execution.getProcessInstanceId()); + } + +} diff --git a/modules/activiti-camel/src/test/java/org/activiti/camel/SleepBean.java b/modules/activiti-camel/src/test/java/org/activiti/camel/SleepBean.java new file mode 100644 index 0000000000000000000000000000000000000000..090782b8db89816c42af8f1506e3b28b4b5db8f8 --- /dev/null +++ b/modules/activiti-camel/src/test/java/org/activiti/camel/SleepBean.java @@ -0,0 +1,10 @@ +package org.activiti.camel; + +import org.apache.camel.Exchange; + +public class SleepBean { + + public void sleep(String body, Exchange exchange) throws Exception { + Thread.sleep(1500); + } +} diff --git a/modules/activiti-camel/src/test/java/org/activiti/camel/route/AsyncCamelRoute.java b/modules/activiti-camel/src/test/java/org/activiti/camel/route/AsyncCamelRoute.java new file mode 100644 index 0000000000000000000000000000000000000000..c0641641f67700d7e3e9f7ddbee2d17f69bc78c5 --- /dev/null +++ b/modules/activiti-camel/src/test/java/org/activiti/camel/route/AsyncCamelRoute.java @@ -0,0 +1,31 @@ +/* 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.camel.route; + +import org.apache.camel.builder.RouteBuilder; + +public class AsyncCamelRoute extends RouteBuilder { + + @Override + public void configure() throws Exception { + + from("activiti:asyncCamelProcess:serviceTaskAsync1?copyVariablesToProperties=true").setHeader("destination", constant("activiti:asyncCamelProcess:receive1")).to("seda:asyncQueue"); + from("seda:asyncQueue").to("bean:sleepBean?method=sleep").to("seda:receiveQueue"); + + from("activiti:asyncCamelProcess:serviceTaskAsync2?copyVariablesToProperties=true").setHeader("destination", constant("activiti:asyncCamelProcess:receive2")).to("seda:asyncQueue2"); + from("seda:asyncQueue2").to("bean:sleepBean?method=sleep").to("seda:receiveQueue"); + + from("seda:receiveQueue").recipientList(header("destination")); + } +} diff --git a/modules/activiti-camel/src/test/resources/camel-activiti-context.xml b/modules/activiti-camel/src/test/resources/camel-activiti-context.xml index 9c05827848d2c9589e1ab9f6403a13403c19dd03..8291458d7ef50711ffa43512fdf730567fbd321a 100644 --- a/modules/activiti-camel/src/test/resources/camel-activiti-context.xml +++ b/modules/activiti-camel/src/test/resources/camel-activiti-context.xml @@ -50,8 +50,14 @@ + + + + + + diff --git a/modules/activiti-camel/src/test/resources/process/async.bpmn20.xml b/modules/activiti-camel/src/test/resources/process/async.bpmn20.xml new file mode 100644 index 0000000000000000000000000000000000000000..f9717ab8424d57bcd1867fcd0f98883aa8dbd2f2 --- /dev/null +++ b/modules/activiti-camel/src/test/resources/process/async.bpmn20.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +