KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > jpdl > patterns > Wfp17DeferredChoiceTest


1 package org.jbpm.jpdl.patterns;
2
3 import junit.framework.*;
4
5 import org.jbpm.graph.def.*;
6 import org.jbpm.graph.exe.*;
7
8 /**
9  * http://is.tm.tue.nl/research/patterns/download/swf/pat_16.swf
10  */

11 public class Wfp17DeferredChoiceTest extends TestCase {
12
13   public static ProcessDefinition deferredChoiceProcessDefinition = createDeferredChoiceProcessDefinition();
14   
15   public static ProcessDefinition createDeferredChoiceProcessDefinition() {
16     ProcessDefinition pd = new ProcessDefinition(
17       new String JavaDoc[]{"start-state start",
18                    "state a",
19                    "state b",
20                    "state c"},
21       new String JavaDoc[]{"start --> a",
22                    "a --to a--> b",
23                    "a --to b--> c"});
24     return pd;
25   }
26
27   public void testDeferredChoiceScenario1() {
28     ProcessDefinition pd = deferredChoiceProcessDefinition;
29
30     ProcessInstance pi = new ProcessInstance( pd );
31     pi.signal();
32     Token root = pi.getRootToken();
33     assertSame( pd.getNode("a"), root.getNode() );
34     root.signal("to a"); // take the transition with name 'to a'
35
assertSame( pd.getNode("b"), root.getNode() );
36   }
37
38   public void testDeferredChoiceScenario2() {
39     ProcessDefinition pd = deferredChoiceProcessDefinition;
40
41     ProcessInstance pi = new ProcessInstance( pd );
42     pi.signal();
43     Token root = pi.getRootToken();
44     assertSame( pd.getNode("a"), root.getNode() );
45     root.signal("to b"); // take the transition with name 'to b'
46
assertSame( pd.getNode("c"), root.getNode() );
47   }
48
49 }
50
Popular Tags