Jbpm test

本文提供了一个使用jbpm框架进行流程测试的基本示例,包括流程部署、启动、检查流程状态及流程结束的验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

package com.test;
import junit.framework.TestCase;

import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;


public class HelloTest extends TestCase  {
	ProcessEngine processEngine = null;  
	 String deployId = null;  
	 //主要是用来发布流程  
	 RepositoryService repositoryService = null;  
	 //主要用来启动流程,执行流程  
	 ExecutionService executionService = null;  
	 
	 protected void setUp() {  
		 processEngine = new Configuration().buildProcessEngine();  
		 repositoryService = processEngine.getRepositoryService();  
		 executionService = processEngine.getExecutionService();  
		 //将定义的流程配置文件部署到数据库中  
		 deployId = repositoryService.createDeployment().addResourceFromClasspath("test.jpdl.xml").deploy();  
		 System.out.println("---"+deployId);
		 
	  }  
     protected void tearDown() {  
    // repositoryService.deleteDeploymentCascade(deployId);  
   
     }  
   
     public void testEndHelloWorld() {  
         //启动流程实例  
         ProcessInstance processInstance =executionService.startProcessInstanceByKey("william");
        		 // executionService.startProcessInstanceByKey("test");  
         //启动流程后我们的流程会自动进入到state1活动,并处在等待状态  
         assertTrue(processInstance.isActive("state1"));  
//         String pid = processInstance.getId();  
//         //让state1活动继续往下执行,并进入结束活动,流程结束  
//         processInstance = executionService.signalExecutionById(pid);  
//         assertTrue(processInstance.isEnded());  
     } 
     
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值