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 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 { 29 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 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 { 56 assertSame(positive.getReached(), GetLinkStatusFunction.evaluate("positive", context)); 57 } 58 59 public void testEvaluateNegativeLink() throws Exception { 60 assertSame(negative.getReached(), GetLinkStatusFunction.evaluate("negative", context)); 61 } 62 63 public void testEvaluateUnsetLink() throws Exception { 64 assertSame(unset.getReached(), GetLinkStatusFunction.evaluate("unset", context)); 65 } 66 } 67 | Popular Tags |