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 13 public class Wfp12ImplicitTerminationTest extends TestCase { 14 15 private static ProcessDefinition implicitTerminationProcessDefinition = createImplicitTerminationDefinition(); 16 17 public static ProcessDefinition createImplicitTerminationDefinition() { 18 ProcessDefinition pd = new ProcessDefinition( 19 new String []{"start-state start", 20 "fork fork", 21 "state b", 22 "state c", 23 "state d", 24 "state e"}, 25 new String []{"start --> fork", 26 "fork --b--> b", 27 "fork --c--> c", 28 "b --> d", 29 "c --> e"}); 30 pd.setTerminationImplicit( true ); 31 return pd; 32 } 33 34 public void testImplicitTerminationScenario1() { 35 ProcessDefinition pd = implicitTerminationProcessDefinition; 36 ProcessInstance pi = new ProcessInstance( pd ); 37 pi.signal(); 38 Token rootToken = pi.getRootToken(); 39 Token tokenB = rootToken.getChild("b"); 40 Token tokenC = rootToken.getChild("c"); 41 42 assertFalse( pi.hasEnded() ); 43 tokenB.signal(); 44 assertFalse( pi.hasEnded() ); 45 tokenC.signal(); 46 assertTrue( pi.hasEnded() ); 47 } 48 49 public void testImplicitTerminationScenario2() { 50 ProcessDefinition pd = implicitTerminationProcessDefinition; 51 ProcessInstance pi = new ProcessInstance( pd ); 52 pi.signal(); 53 Token rootToken = pi.getRootToken(); 54 Token tokenB = rootToken.getChild("b"); 55 Token tokenC = rootToken.getChild("c"); 56 57 assertFalse( pi.hasEnded() ); 58 tokenC.signal(); 59 assertFalse( pi.hasEnded() ); 60 tokenB.signal(); 61 assertTrue( pi.hasEnded() ); 62 } 63 } 64 | Popular Tags |