流程定义: <?xml version="1.0" encoding="UTF-8"?> <process-definition name='hello'> <start-state name='start'> <transition to='s' name="to_s"/> </start-state> <state name='s'> <transition to='end' name="to_end"> <action class="com.amway.handler.MyActionHandler"></action> </transition> </state> <end-state name='end' /> </process-definition> 测试代码 : package com.amway.test; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import com.amway.handler.MyActionHandler; import junit.framework.TestCase; public class TransitionActionTest extends TestCase { public void setUp() { MyActionHandler.isExecuted = false; } public void testTransitionAction() { ProcessDefinition processDefinition = ProcessDefinition .parseXmlInputStream(this.getClass().getClassLoader() .getResourceAsStream("TransitionAction.xml")); ProcessInstance instance = new ProcessInstance(processDefinition); instance.signal(); this.assertFalse(MyActionHandler.isExecuted); this.assertSame(processDefinition.getNode("s"), instance.getRootToken().getNode()); instance.signal();//这一步流转的时候执行了action,导致isExecuted=true this.assertTrue(MyActionHandler.isExecuted); this.assertSame(processDefinition.getNode("end"),instance.getRootToken().getNode()); } }