activiti5第六弹 手动任务、接收任务、邮件任务

来源:互联网 发布:手机淘宝红包设置 编辑:程序博客网 时间:2024/06/05 20:50

手动任务和接收任务几乎不在程序中做什么事情---只是在流程的历史中留下一点痕迹,表明流程是走过某些节点的。。。而且这两个任务是无法用taskservice查询到的

但是接收任务比手动任务多一个功能,就是确认功能。。。

activiti.cfg.xml配置

<?xml version="1.0"?><beans default-lazy-init="false"xsi:schemaLocation=" http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://www.springframework.org/schema/beans"><beanclass="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"id="processEngineConfiguration"><property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activi1" /><property name="jdbcDriver" value="com.mysql.jdbc.Driver" /><property name="jdbcUsername" value="root" /><property name="jdbcPassword" value="root" /><property name="databaseSchemaUpdate" value="true" /><property name="jobExecutorActivate" value="true" /><property name="mailServerHost" value="smtp.163.com" />//邮件任务的配置如下<property name="mailServerPort" value="25" /><property name="mailServerUsername" value="15203437412"></property><property name="mailServerPassword" value="你的密码"></property><property name="history" value="full"></property></bean></beans>




首先是流程图:


测试类

package final_activiti.progress;import java.util.List;import org.activiti.engine.impl.test.PluggableActivitiTestCase;import org.activiti.engine.runtime.ProcessInstance;import org.activiti.engine.task.Task;import org.activiti.engine.test.Deployment;import org.junit.Test;public class ManualRecTest extends PluggableActivitiTestCase {@Test@Deployment(resources = "final_activiti/progress/RecAndManulTask.bpmn")public void test() {// 启动流程ProcessInstance pi = runtimeService.startProcessInstanceByKey("processRM");// 查询当前任务List<Task> tasks = taskService.createTaskQuery().list();// 断言通过taskservice是无法查询到这两个任务的assertTrue(tasks.size() == 0);List<ProcessInstance> pis = runtimeService.createProcessInstanceQuery().list();// 断言流程数为1,因为我启动了一个流程,而且这个流程仍然等待着接收任务的确认而未完成assertTrue(pis.size() == 1);// 发出信号给receive任务,让流程继续执行runtimeService.signal(pi.getId());// 流程结束了··所以是0pis = runtimeService.createProcessInstanceQuery().list();assertTrue(pis.size() == 0);// 断言流程结束assertProcessEnded(pi.getId());}}

测试结果是绿条。




邮件任务:邮件任务也很简单,功能当然是发邮件

流程图:


对MAIL TASK 进行相应的配置




测试类:

package final_activiti.progress;import org.activiti.engine.impl.test.PluggableActivitiTestCase;import org.activiti.engine.test.Deployment;import org.junit.Test;public class MailTest extends PluggableActivitiTestCase {@Test@Deployment(resources = "final_activiti/progress/MailTask.bpmn")public void test() {//直接开启流程就好了runtimeService.startProcessInstanceByKey("mail");}}



0 0
原创粉丝点击