KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > xpath > GetLinkStatusTest


1 package org.jbpm.bpel.data.xpath;
2
3 import junit.framework.TestCase;
4
5 import org.jaxen.Context;
6 import org.jaxen.ContextSupport;
7 import org.jaxen.SimpleVariableContext;
8
9 import org.jbpm.context.def.ContextDefinition;
10 import org.jbpm.graph.def.ProcessDefinition;
11 import org.jbpm.graph.exe.ProcessInstance;
12 import org.jbpm.graph.exe.Token;
13
14 import org.jbpm.bpel.exe.LinkInstance;
15
16 /**
17  * @author Juan Cantú
18  * @version $Revision: 1.1 $ $Date: 2005/05/24 16:43:35 $
19  */

20 public class GetLinkStatusTest extends TestCase {
21
22   private Context context;
23   
24   private LinkInstance positive;
25   private LinkInstance negative;
26   private LinkInstance unset;
27   
28   protected void setUp() throws Exception JavaDoc {
29     // process and context
30
ProcessDefinition pd = new ProcessDefinition();
31     pd.addDefinition(new ContextDefinition());
32     ProcessInstance pi = new ProcessInstance(pd);
33     Token rootToken = pi.getRootToken();
34     
35     positive = LinkInstance.create(rootToken, "positive");
36     positive.setReached(Boolean.TRUE);
37
38     negative = LinkInstance.create(rootToken, "negative");
39     negative.setReached(Boolean.FALSE);
40     
41     unset = LinkInstance.create(rootToken, "unset");
42     
43     // jaxen context
44
ContextSupport sup = new ContextSupport();
45     SimpleVariableContext simpleContext = new SimpleVariableContext();
46     
47     simpleContext.setVariableValue("positive", positive.getReached());
48     simpleContext.setVariableValue("negative", negative.getReached());
49     simpleContext.setVariableValue("unset", unset.getReached());
50     
51     sup.setVariableContext(simpleContext);
52     context = new Context(sup);
53   }
54
55   public void testEvaluatePositiveLink() throws Exception JavaDoc {
56     assertSame(positive.getReached(), GetLinkStatusFunction.evaluate("positive", context));
57   }
58   
59   public void testEvaluateNegativeLink() throws Exception JavaDoc {
60     assertSame(negative.getReached(), GetLinkStatusFunction.evaluate("negative", context));
61   }
62   
63   public void testEvaluateUnsetLink() throws Exception JavaDoc {
64     assertSame(unset.getReached(), GetLinkStatusFunction.evaluate("unset", context));
65   }
66 }
67
Popular Tags