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 24 public class Wfp05SimpleMergeTest extends TestCase { 25 26 private static ProcessDefinition simpleMergeProcessDefinition = createSimpleMergeProcessDefinition(); 27 28 public static ProcessDefinition createSimpleMergeProcessDefinition() { 29 ProcessDefinition pd = new ProcessDefinition( 30 new String []{"start-state start", 31 "state a", 32 "state b", 33 "merge xor", 34 "state c"}, 35 new String []{"start --to a--> a", 36 "start --to b--> b", 37 "a --> xor", 38 "b --> xor", 39 "xor --> c"}); 40 return pd; 41 } 42 43 public void testSimpleMergeScenario1() { 44 ProcessDefinition pd = simpleMergeProcessDefinition; 45 ProcessInstance pi = new ProcessInstance( pd ); 46 pi.signal("to a"); 47 Token root = pi.getRootToken(); 48 assertSame( pd.getNode("a"), root.getNode() ); 49 root.signal(); 50 assertSame( pd.getNode("c"), root.getNode() ); 51 } 52 53 public void testSimpleMergeScenario2() { 54 ProcessDefinition pd = simpleMergeProcessDefinition; 55 ProcessInstance pi = new ProcessInstance( pd ); 56 pi.signal("to b"); 57 Token root = pi.getRootToken(); 58 assertSame( pd.getNode("b"), root.getNode() ); 59 root.signal(); 60 assertSame( pd.getNode("c"), root.getNode() ); 61 } 62 63 private static ProcessDefinition implicitMergeProcessDefinition = createImplicitMergeProcessDefinition(); 64 65 public static ProcessDefinition createImplicitMergeProcessDefinition() { 66 ProcessDefinition pd = new ProcessDefinition( 67 new String []{"start-state start", 68 "state a", 69 "state b", 70 "state c"}, 71 new String []{"start --to a--> a", 72 "start --to b--> b", 73 "a --> c", 74 "b --> c"}); 75 return pd; 76 } 77 78 public void testImplicitMergeScenario1() { 79 ProcessDefinition pd = implicitMergeProcessDefinition; 80 ProcessInstance pi = new ProcessInstance( implicitMergeProcessDefinition ); 81 pi.signal("to a"); 82 Token root = pi.getRootToken(); 83 assertSame( pd.getNode("a"), root.getNode() ); 84 root.signal(); 85 assertSame( pd.getNode("c"), root.getNode() ); 86 } 87 88 public void testImplicitMergeScenario2() { 89 ProcessDefinition pd = implicitMergeProcessDefinition; 90 ProcessInstance pi = new ProcessInstance( implicitMergeProcessDefinition ); 91 pi.signal("to b"); 92 Token root = pi.getRootToken(); 93 assertSame( pd.getNode("b"), root.getNode() ); 94 root.signal(); 95 assertSame( pd.getNode("c"), root.getNode() ); 96 } 97 98 } 99 | Popular Tags |