国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Java_Activiti5_菜鳥也來學Activiti5工作流_之JUnit單元測試(四)

2019-11-14 15:40:59
字體:
來源:轉載
供稿:網友
 1 /**ActivitiSPRingJuinitTest.java 2  * author : 馮孟活 ^_^ 3  * dates  : 2015年9月2日 下午2:16:54 4  * class   : activiti 之 Junit 測試 5  */ 6 // 指定運行環境要用到spring的測試包(spring-test.jar) 7 @RunWith(SpringJUnit4ClassRunner.class) 8 // 注入一些配置信息 9 @ContextConfiguration(locations="classpath:applicationConfig.xml") 10 public class ActivitiSpringJuinitTest {11     12     @Autowired // 注入運行服務類13     private RuntimeService runtimeService;14     15     @Autowired // 注入任務服務類16     private TaskService taskService;17     18     @Autowired19     @Rule // 注入一些規則20     private ActivitiRule activitiSpringRule;21     22     @Test 23     @Deployment // 部署24     public void activitiTest(){25         // 根據key來啟動流程實例26         runtimeService.startProcessInstanceByKey("myProcess");27         // 獲取單個任務28         Task task = taskService.createTaskQuery().singleResult();29         // 斷言任務名稱就是 "My Task"30         Assert.assertEquals("My Task",task.getName());31         // 完成任務32         taskService.complete(task.getName());33         /**34          * 總結:簡單的單元測試到此為止!35          *             注意:藥正確使用 注解類36          *                     遇到的問題:37          *                     Caused by: java.lang.ClassNotFoundException: org.junit.Assume$AssumptionViolatedException38          *                     這一般是spring-text包與junit包沖突引起,把junit改低版本就沒有問題了^_^39          */40     }41 }42 43 44 <!-- applicationConfig.xml -->45 <?xml version="1.0" encoding="UTF-8"?>46 <beans xmlns="http://www.springframework.org/schema/beans"47     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"48     xmlns:context="http://www.springframework.org/schema/context"49     xmlns:tx="http://www.springframework.org/schema/tx"50     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd51         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd52         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">53     54     <!-- 配置數據源 -->55     <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">56         <property name="driverClass" value="com.MySQL.jdbc.Driver"/>57         <property name="url" value="jdbc:mysql://localhost:3306/db_activiti?useUnicode=true&amp;characterEncoding=utf-8"/>58         <property name="username" value="root"/>59         <property name="passWord" value="root"/>60     </bean>61 62     <!-- 配置數據源事務管理器 -->63     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">64         <property name="dataSource" ref="dataSource"/> <!-- 引用上面的數據源 -->65     </bean>66     67     <!-- 配置流程引擎配置類 注意:這是用 org.activiti.spring.SpringProcessEngineConfiguration 這個類-->68     <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">69         <property name="dataSource" ref="dataSource"/>70         <property name="transactionManager" ref="transactionManager" />71         <property name="databaseSchemaUpdate" value="true" />72         <property name="jobExecutorActivate" value="false" />73         <property name="createDiagramOnDeploy" value="false" /> <!-- 是否生成流程定義圖片 -->74     </bean>75     76     <!-- 配置流程引擎工廠 -->77     <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">78         <property name="processEngineConfiguration" ref="processEngineConfiguration" />79     </bean>80     81     <!-- 配置注入一些服務 -->82     <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/>83     <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService"/>84     <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />85     <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />86     <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />87     88     <!-- 配置activiti的規則 -->89     <bean id="activitiRule" class="org.activiti.engine.test.ActivitiRule">90         <property name="processEngine" ref="processEngine" />91     </bean>92     93 </beans>

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 班戈县| 乐山市| 三都| 绥江县| 杭锦后旗| 洛浦县| 宁津县| 紫阳县| 巢湖市| 富川| 大悟县| 汶上县| 罗田县| 连山| 宜兰县| 航空| 奉贤区| 琼结县| 广饶县| 香河县| 黔东| 莱阳市| 错那县| 淄博市| 新晃| 海门市| 涞水县| 舞阳县| SHOW| 麦盖提县| 宜兴市| 邹城市| 博野县| 武强县| 台安县| 尚义县| 桃江县| 嘉荫县| 攀枝花市| 益阳市| 奉节县|