Java_activiti5_ rookie also come to learn Activiti5 workflow _ JUnit Unit Test (iv)

Source: Internet
Author: User

1 /**Activitispringjuinittest.java2 * Author: Feng Mengwao ^_^3 * dates:2015 Year September 2 afternoon 2:16:544 * Class:activiti's Junit test5  */6 //Specify the run environment to use for spring's test package (Spring-test.jar)7@RunWith (Springjunit4classrunner.class)8 //inject some configuration information9@ContextConfiguration (locations= "Classpath:applicationConfig.xml") Ten  Public classActivitispringjuinittest { One      A@Autowired//Injection Run service class -     PrivateRuntimeservice Runtimeservice; -      the@Autowired//Inject task service class -     PrivateTaskservice Taskservice; -      - @Autowired +@Rule//inject some rules -     Privateactivitirule Activitispringrule; +      A @Test at@Deployment//Deployment -      Public voidactivititest () { -         //To start a process instance based on key -Runtimeservice.startprocessinstancebykey ("Myprocess"); -         //get a single task -Task task =taskservice.createtaskquery (). Singleresult (); in         //assert that the task name is "My task" -Assert.assertequals ("My Task", Task.getname ()); to         //Complete the Task + Taskservice.complete (Task.getname ()); -         /** the * Summary: The simple unit test ends here!  * * Note: The correct use of the drug annotation class $ * Problems encountered:Panax Notoginseng * caused by:java.lang.classnotfoundexception:org.junit.assume$assumptionviolatedexcept Ion - * This is usually caused by the Spring-text package conflict with the JUnit package, and it's no problem to change JUnit to a lower version ^_^ the          */ +     } A } the  +  -<!--Applicationconfig.xml-- $<?xml version= "1.0" encoding= "UTF-8"?> $<beans xmlns= "Http://www.springframework.org/schema/beans" -Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" -xmlns:context= "Http://www.springframework.org/schema/context" thexmlns:tx= "Http://www.springframework.org/schema/tx" -xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans.xsdWuyihttp//Www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsd thehttp//Www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.1.xsd"> -      Wu<!--configuring data sources- -<bean id= "DataSource"class= "Org.springframework.jdbc.datasource.SimpleDriverDataSource" > About<property name= "Driverclass" value= "Com.mysql.jdbc.Driver"/> $<property name= "url" value= "jdbc:mysql://localhost:3306/db_activiti?useunicode=true&amp;characterencoding =utf-8 "/> -<property name= "username" value= "root"/> -<property name= "Password" value= "root"/> -</bean> A  +<!--Configuring the data source transaction manager- the<bean id= "TransactionManager"class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" > -<property name= "DataSource" ref= "DataSource"/> <!--reference the data source above-- $</bean> the      the<!--Configuring the process engine configuration class Note: This is the class with Org.activiti.spring.SpringProcessEngineConfiguration-- the<bean id= "Processengineconfiguration"class= "Org.activiti.spring.SpringProcessEngineConfiguration" > the<property name= "DataSource" ref= "DataSource"/> -<property name= "TransactionManager" ref= "TransactionManager"/> in<property name= "Databaseschemaupdate" value= "true"/> the<property name= "Jobexecutoractivate" value= "false"/> the<property name= "Creatediagramondeploy" value= "false"/> <!--whether to generate a process definition picture-- About</bean> the      the<!--configuration Process engine factory-- the<bean id= "Processengine"class= "Org.activiti.spring.ProcessEngineFactoryBean" > +<property name= "processengineconfiguration" ref= "Processengineconfiguration"/> -</bean> the     Bayi<!--configuration Inject some services-- the<bean id= "Repositoryservice" factory-bean= "Processengine" factory-method= "Getrepositoryservice"/> the<bean id= "Runtimeservice" factory-bean= "Processengine" factory-method= "Getruntimeservice"/> -<bean id= "Taskservice" factory-bean= "Processengine" factory-method= "Gettaskservice"/> -<bean id= "Historyservice" factory-bean= "Processengine" factory-method= "Gethistoryservice"/> the<bean id= "Managementservice" factory-bean= "Processengine" factory-method= "Getmanagementservice"/> the      the<!--Configure Activiti rules-- the<bean id= "Activitirule"class= "Org.activiti.engine.test.ActivitiRule" > -<property name= "Processengine" ref= "Processengine"/> the</bean> the      the</beans>

Java_activiti5_ rookie also come to learn Activiti5 workflow _ JUnit Unit Test (iv)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.