KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > exe > SuperStateTest


1 package org.jbpm.graph.exe;
2
3 import junit.framework.TestCase;
4
5 import org.jbpm.graph.def.ProcessDefinition;
6
7 public class SuperStateTest extends TestCase {
8
9   public void testTakeSuperStateTransition() {
10     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
11       "<process-definition>" +
12       " <start-state name='start'>" +
13       " <transition to='superstate/insidesuperstate'/>" +
14       " </start-state>" +
15       " <super-state name='superstate'>" +
16       " <state name='insidesuperstate' />" +
17       " <transition to='s' />" +
18       " </super-state>" +
19       " <state name='s' />" +
20       "</process-definition>"
21     );
22     // create the process instance
23
ProcessInstance processInstance = new ProcessInstance(processDefinition);
24     Token token = processInstance.getRootToken();
25     processInstance.signal();
26     assertEquals(processDefinition.findNode("superstate/insidesuperstate"), token.getNode());
27     processInstance.signal();
28     assertEquals(processDefinition.getNode("s"), token.getNode());
29   }
30
31   public void testTransitionToSuperState() {
32     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
33       "<process-definition>" +
34       " <start-state name='start'>" +
35       " <transition to='superstate'/>" +
36       " </start-state>" +
37       " <super-state name='superstate'>" +
38       " <state name='insidesuperstate' />" +
39       " </super-state>" +
40       "</process-definition>"
41     );
42     // create the process instance
43
ProcessInstance processInstance = new ProcessInstance(processDefinition);
44     Token token = processInstance.getRootToken();
45     processInstance.signal();
46     assertEquals(processDefinition.findNode("superstate/insidesuperstate"), token.getNode());
47   }
48
49 }
50
Popular Tags