1 package org.jbpm.tutorial.helloworld; 2 3 import junit.framework.TestCase; 4 5 import org.jbpm.graph.def.ProcessDefinition; 6 import org.jbpm.graph.exe.ProcessInstance; 7 import org.jbpm.graph.exe.Token; 8 9 public class HelloWorldTest extends TestCase { 10 11 public void testHelloWorldProcess() { 12 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 20 "<process-definition>" + 21 " <start-state>" + 22 " <transition to='s' />" + 23 " </start-state>" + 24 " <state name='s'>" + 25 " <transition to='end' />" + 26 " </state>" + 27 " <end-state name='end' />" + 28 "</process-definition>" 29 ); 30 31 ProcessInstance processInstance = 36 new ProcessInstance(processDefinition); 37 38 Token token = processInstance.getRootToken(); 41 42 assertSame(processDefinition.getStartState(), token.getNode()); 45 46 token.signal(); 49 52 assertSame(processDefinition.getNode("s"), token.getNode()); 56 57 token.signal(); 60 63 assertSame(processDefinition.getNode("end"), token.getNode()); 64 } 65 66 67 public void testThreeStateProcess() { 68 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 72 "<process-definition>" + 73 " <start-state>" + 74 " <transition to='phase one' />" + 75 " </start-state>" + 76 " <state name='phase one'>" + 77 " <transition to='phase two' />" + 78 " </state>" + 79 " <state name='phase two'>" + 80 " <transition to='phase three' />" + 81 " </state>" + 82 " <state name='phase three'>" + 83 " <transition to='end' />" + 84 " </state>" + 85 " <end-state name='end' />" + 86 "</process-definition>" 87 ); 88 89 ProcessInstance processInstance = 90 new ProcessInstance(processDefinition); 91 Token token = processInstance.getRootToken(); 92 assertSame(processDefinition.getStartState(), token.getNode()); 93 94 token.signal(); 95 assertSame(processDefinition.getNode("phase one"), token.getNode()); 96 97 token.signal(); 98 assertSame(processDefinition.getNode("phase two"), token.getNode()); 99 100 token.signal(); 101 assertSame(processDefinition.getNode("phase three"), token.getNode()); 102 103 token.signal(); 104 assertSame(processDefinition.getNode("end"), token.getNode()); 105 } 106 } 107 | Popular Tags |