KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > exe > LinkInstanceTest


1 package org.jbpm.bpel.exe;
2
3 import junit.framework.TestCase;
4
5 import org.jbpm.context.def.ContextDefinition;
6 import org.jbpm.graph.def.ProcessDefinition;
7 import org.jbpm.graph.exe.ExecutionContext;
8 import org.jbpm.graph.exe.ProcessInstance;
9 import org.jbpm.graph.exe.Token;
10
11 import org.jbpm.bpel.def.Activity;
12 import org.jbpm.bpel.def.Empty;
13 import org.jbpm.bpel.def.Link;
14
15 /**
16  * @author Juan Cantú
17  * @version $Revision: 1.3 $ $Date: 2005/05/07 00:03:44 $
18  */

19 public class LinkInstanceTest extends TestCase {
20   
21   Link link;
22   Activity activity;
23   Activity target;
24   Token token;
25   String JavaDoc linkName = "testLink";
26   
27   public void setUp() {
28     ProcessDefinition pd = new ProcessDefinition();
29     pd.addDefinition(new ContextDefinition());
30     ProcessInstance pi = new ProcessInstance(pd);
31     token = pi.getRootToken();
32     activity = new Empty("node");
33     target = new Empty("target");
34     link = new Link(linkName);
35     LinkInstance.create(token, link.getName());
36   }
37
38   public void testExecuteTrue() throws Exception JavaDoc {
39     target.addTarget(link);
40     link.setTransitionCondition(ActivityExeTest.TRUE);
41     link.execute(new ExecutionContext(token));
42     
43     LinkInstance instance =
44       LinkInstance.get(token, link.getName());
45
46     assertEquals( Boolean.TRUE, instance.getReached() );
47   }
48
49   public void testExecuteFalse() throws Exception JavaDoc {
50     target.addTarget(link);
51     link.setTransitionCondition(ActivityExeTest.FALSE);
52     link.execute(new ExecutionContext(token));
53
54     LinkInstance instance =
55       LinkInstance.get(token, link.getName());
56
57     assertEquals( Boolean.FALSE, instance.getReached() );
58   }
59 }
60
Popular Tags