KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class Wfp20CancelActivityTest extends TestCase {
9   
10   public static ProcessDefinition cancelProcessDefinition = createCancelProcessDefinition();
11   
12   public static ProcessDefinition createCancelProcessDefinition() {
13     ProcessDefinition pd = new ProcessDefinition(
14       new String JavaDoc[]{"start-state start",
15                    "fork f1",
16                    "state a",
17                    "fork f2",
18                    "state b",
19                    "state c"},
20       new String JavaDoc[]{"start --> f1",
21                    "f1 --a--> a",
22                    "f1 --f2--> f2",
23                    "f2 --b--> b",
24                    "f2 --c--> c"});
25     
26     return pd;
27   }
28   
29   public void testCancelActivityScenario1() {
30     ProcessDefinition pd = cancelProcessDefinition;
31     ProcessInstance pi = new ProcessInstance(pd);
32     pi.signal();
33     Token root = pi.getRootToken();
34     Token tokenA = root.getChild("a");
35     Token tokenF2 = root.getChild("f2");
36     Token tokenF2B = tokenF2.getChild("b");
37     Token tokenF2C = tokenF2.getChild("c");
38     
39     assertFalse( pi.hasEnded() );
40     assertFalse( root.hasEnded() );
41     assertFalse( tokenA.hasEnded() );
42     assertFalse( tokenF2.hasEnded() );
43     assertFalse( tokenF2B.hasEnded() );
44     assertFalse( tokenF2C.hasEnded() );
45     
46     tokenF2B.end();
47
48     assertFalse( pi.hasEnded() );
49     assertFalse( root.hasEnded() );
50     assertFalse( tokenA.hasEnded() );
51     assertFalse( tokenF2.hasEnded() );
52     assertTrue( tokenF2B.hasEnded() );
53     assertFalse( tokenF2C.hasEnded() );
54
55     tokenF2C.end();
56
57     assertFalse( pi.hasEnded() );
58     assertFalse( root.hasEnded() );
59     assertFalse( tokenA.hasEnded() );
60     assertTrue( tokenF2.hasEnded() );
61     assertTrue( tokenF2B.hasEnded() );
62     assertTrue( tokenF2C.hasEnded() );
63
64     tokenA.end();
65
66     assertTrue( pi.hasEnded() );
67     assertTrue( root.hasEnded() );
68     assertTrue( tokenA.hasEnded() );
69     assertTrue( tokenF2.hasEnded() );
70     assertTrue( tokenF2B.hasEnded() );
71     assertTrue( tokenF2C.hasEnded() );
72   }
73
74 }
75
Popular Tags