package com.couriousby.bpmb; import java.io.IOException; import java.io.InputStream; import java.util.List; import javax.annotation.Resource; import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; import org.activiti.engine.TaskService; import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.task.Task; import org.junit.Assert; import org.junit.Test; import com.couriousby.service.ProcessService; public class AtivitiTest extends SpringContextTest{ @Resource private RepositoryService repositoryService; @Resource private RuntimeService runtimeService; @Resource TaskService taskService; @Resource ProcessService processService; @Test public void testActiviti() throws Exception { InputStream is = readXmlFile(); Assert.assertNotNull(is); //发布流程 Deployment deployment=repositoryService.createDeployment().addInputStream("bpmn20.xml", is).name("first").deploy(); Assert.assertNotNull(deployment); System.out.println("deployId:" + deployment.getId()); //查询流程定义 ProcessDefinition processDefinition=repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult(); Long businessKey=new Double(1000000*Math.random()).longValue(); //启动流程 runtimeService.startProcessInstanceById(processDefinition.getId(),businessKey.toString()); //查询任务实例 List<Task> taskList=taskService.createTaskQuery().processDefinitionId(processDefinition.getId()).list(); Assert.assertNotNull(taskList==null); Assert.assertTrue(taskList.size()>0); for(Task task:taskList){ System.out.println("task name is " + task.getName() + " ,task key is " + task.getTaskDefinitionKey()); taskService.complete(task.getId()); } processService.getInput( deployment.getId()); } public InputStream readXmlFile() throws IOException{ String filePath="first.bpmn"; return Class.class.getClass().getResource("/"+filePath).openStream(); } }
package com.couriousby.bpmb; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "classpath*:applicationContext*.xml" }) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) @Transactional public class SpringContextTest extends AbstractTransactionalJUnit4SpringContextTests{ @Test public void test() { System.out.println("test..."); System.out.println("we can see tables from databases. "); System.out.println(" " + "\r\n" + "act_ge_bytearray " + "\r\n" + "act_ge_property" + "\r\n" + "act_hi_actinst " + "\r\n" + "act_hi_attachment"+ "\r\n" + "act_hi_comment" + "\r\n" + "act_hi_detail " + "\r\n" + "act_hi_identitylink " + "\r\n" + "act_hi_procinst"+ "\r\n" + "act_hi_taskinst " + "\r\n" + "act_hi_varinst" + "\r\n" + "act_id_group " + "\r\n" + "act_id_info " + "\r\n" + "act_id_membership"+ "\r\n" + "act_id_user " + "\r\n" + "act_re_deployment" + "\r\n" + "act_re_model " + "\r\n" + "act_re_procdef " + "\r\n" + "act_ru_event_subscr"+ "\r\n" + "act_ru_execution " + "\r\n" + "act_ru_identitylink" + "\r\n" + "act_ru_job" + "\r\n" + "act_ru_task " + "\r\n" + "act_ru_variable"+ "\r\n" + ""); System.out.println("test success ,end "); } }
pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.curiousby.activiti.demo</groupId> <artifactId>DemoActiviti</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>DemoActiviti Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <modelVersion>4.0.0</modelVersion> <groupId>com.hotent.demo</groupId> <artifactId>activiti</artifactId> <version>1.0.0-SNAPSHOT</version> <activiti.version>5.19.0</activiti.version> </properties> <dependencies> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-engine</artifactId> <version>${activiti.version}</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring</artifactId> <version>${activiti.version}</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-bpmn-model</artifactId> <version>${activiti.version}</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-bpmn-converter</artifactId> <version>${activiti.version}</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-process-validation</artifactId> <version>${activiti.version}</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-rest</artifactId> <version>${activiti.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.29</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.2.2.RELEASE</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.5</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.6</version> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.7.6</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.6</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> </dependencies> <build> <finalName>DemoActiviti</finalName> </build> </project>
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!