KickJava   Java API By Example, From Geeks To Geeks.

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


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 Wfp07SynchronizingMergeTest extends TestCase {
9
10   private static ProcessDefinition synchronizingMergeProcessDefinition = createSynchronizingMergeProcessDefinition();
11
12   public static ProcessDefinition createSynchronizingMergeProcessDefinition() {
13     ProcessDefinition pd = Wfp06MultiChoiceTest.createMultiChoiceProcessDefinition();
14     return pd;
15   }
16
17   public void testSynchronizingMergeScenario1() {
18     ProcessDefinition pd = synchronizingMergeProcessDefinition;
19
20     Token root = Wfp06MultiChoiceTest.executeScenario(pd,1);
21     Token tokenB = root.getChild("to b"); // the default token names are extracted from the leaving transitions
22

23     tokenB.signal();
24     assertSame( pd.getNode("end"), root.getNode() );
25     assertSame( pd.getNode("syncmerge"), tokenB.getNode() );
26   }
27
28   public void testSynchronizingMergeScenario2() {
29     ProcessDefinition pd = synchronizingMergeProcessDefinition;
30
31     Token root = Wfp06MultiChoiceTest.executeScenario(pd,2);
32     Token tokenC = root.getChild("to c"); // the default token names are extracted from the leaving transitions
33

34     tokenC.signal();
35     assertSame( pd.getNode("end"), root.getNode() );
36     assertSame( pd.getNode("syncmerge"), tokenC.getNode() );
37   }
38
39   public void testSynchronizingMergeScenario3() {
40     ProcessDefinition pd = synchronizingMergeProcessDefinition;
41
42     Token root = Wfp06MultiChoiceTest.executeScenario(pd,3);
43     Token tokenB = root.getChild("to b"); // the default token names are extracted from the leaving transitions
44
Token tokenC = root.getChild("to c"); // the default token names are extracted from the leaving transitions
45

46     tokenB.signal();
47     assertSame( pd.getNode("multichoice"), root.getNode() );
48     assertSame( pd.getNode("syncmerge"), tokenB.getNode() );
49     assertSame( pd.getNode("c"), tokenC.getNode() );
50
51     tokenC.signal();
52     assertSame( pd.getNode("end"), root.getNode() );
53     assertSame( pd.getNode("syncmerge"), tokenB.getNode() );
54     assertSame( pd.getNode("syncmerge"), tokenC.getNode() );
55   }
56
57   public void testSynchronizingMergeScenario4() {
58     ProcessDefinition pd = synchronizingMergeProcessDefinition;
59
60     Token root = Wfp06MultiChoiceTest.executeScenario(pd,3);
61     Token tokenB = root.getChild("to b"); // the default token names are extracted from the leaving transitions
62
Token tokenC = root.getChild("to c"); // the default token names are extracted from the leaving transitions
63

64     tokenC.signal();
65     assertSame( pd.getNode("multichoice"), root.getNode() );
66     assertSame( pd.getNode("b"), tokenB.getNode() );
67     assertSame( pd.getNode("syncmerge"), tokenC.getNode() );
68
69     tokenB.signal();
70     assertSame( pd.getNode("end"), root.getNode() );
71     assertSame( pd.getNode("syncmerge"), tokenB.getNode() );
72     assertSame( pd.getNode("syncmerge"), tokenC.getNode() );
73   }
74 }
75
Popular Tags