Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 package org.jbpm.tutorial.action; 2 3 import junit.framework.TestCase; 4 5 import org.jbpm.graph.def.ProcessDefinition; 6 import org.jbpm.graph.exe.ProcessInstance; 7 8 public class ActionTest extends TestCase { 9 10 public void setUp() { 13 MyActionHandler.isExecuted = false; 14 } 15 16 public void testTransitionAction() { 17 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 22 "<process-definition>" + 23 " <start-state>" + 24 " <transition to='s' />" + 25 " </start-state>" + 26 " <state name='s'>" + 27 " <transition to='end'>" + 28 " <action class='org.jbpm.tutorial.action.MyActionHandler' />" + 29 " </transition>" + 30 " </state>" + 31 " <end-state name='end' />" + 32 "</process-definition>" 33 ); 34 35 ProcessInstance processInstance = 37 new ProcessInstance(processDefinition); 38 39 processInstance.signal(); 42 43 assertFalse(MyActionHandler.isExecuted); 45 assertSame(processDefinition.getNode("s"), 48 processInstance.getRootToken().getNode()); 49 50 processInstance.signal(); 55 56 assertTrue(MyActionHandler.isExecuted); 59 } 60 61 public void testNodeActions() { 62 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 63 "<process-definition>" + 64 " <start-state>" + 65 " <transition to='s' />" + 66 " </start-state>" + 67 " <state name='s'>" + 68 " <event type='node-enter'>" + 69 " <action class='org.jbpm.tutorial.action.MyActionHandler' />" + 70 " </event>" + 71 " <event type='node-leave'>" + 72 " <action class='org.jbpm.tutorial.action.MyActionHandler' />" + 73 " </event>" + 74 " <transition to='end'/>" + 75 " </state>" + 76 " <end-state name='end' />" + 77 "</process-definition>" 78 ); 79 80 ProcessInstance processInstance = 81 new ProcessInstance(processDefinition); 82 83 assertFalse(MyActionHandler.isExecuted); 84 processInstance.signal(); 88 assertTrue(MyActionHandler.isExecuted); 89 90 MyActionHandler.isExecuted = false; 92 93 processInstance.signal(); 96 assertTrue(MyActionHandler.isExecuted); 98 } 99 } 100
| Popular Tags
|