1 package org.jbpm.graph.exe; 2 3 import junit.framework.TestCase; 4 5 import org.jbpm.graph.def.Action; 6 import org.jbpm.graph.def.ActionHandler; 7 import org.jbpm.graph.def.Event; 8 import org.jbpm.graph.def.ProcessDefinition; 9 10 public class RuntimeActionsTest extends TestCase { 11 12 private ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 13 "<process-definition>" + 14 " <start-state name='start'>" + 15 " <transition to='a' />" + 16 " </start-state>" + 17 " <state name='a'>" + 18 " <transition to='a' />" + 19 " </state>" + 20 " <action name='plusplus' class='org.jbpm.graph.exe.RuntimeActionsTest$PlusPlus' />" + 21 "</process-definition>" 22 ); 23 24 private static int count = 0; 25 26 public static class PlusPlus implements ActionHandler { 27 private static final long serialVersionUID = 1L; 28 public void execute(ExecutionContext executionContext) throws Exception { 29 count++; 31 } 32 } 33 34 public void testRuntimeAction() throws Exception { 35 ProcessInstance processInstance = new ProcessInstance(processDefinition); 37 processInstance.signal(); 39 40 assertEquals(0,count); 42 43 Action plusplusAction = processDefinition.getAction("plusplus"); 45 Event enterB = new Event(Event.EVENTTYPE_NODE_ENTER); 46 processDefinition.getNode("a").addEvent(enterB); 47 RuntimeAction runtimeAction = new RuntimeAction(enterB,plusplusAction); 48 processInstance.addRuntimeAction(runtimeAction); 49 50 processInstance.signal(); 52 53 assertEquals(1,count); 55 } 56 } 57 | Popular Tags |