1 package org.jbpm.bpel.exe; 2 3 import javax.xml.namespace.QName ; 4 5 import org.jbpm.graph.exe.Token; 6 7 import org.jbpm.bpel.data.def.SchemaTypeInfo; 8 import org.jbpm.bpel.data.def.VariableDefinition; 9 import org.jbpm.bpel.data.exe.VariableInstance; 10 import org.jbpm.bpel.def.Receive; 11 import org.jbpm.bpel.def.While; 12 import org.jbpm.bpel.xml.BpelConstants; 13 14 18 public class WhileExeTest extends AbstractExeTestCase { 19 VariableInstance condition; 20 While whileBlock; 21 Receive receive; 22 23 String xml = 24 "<while>" + 25 "<condition>$condition</condition>" + 26 " <receive name='receive' partnerLink='aPartner' operation='o'/>" + 27 "</while>"; 28 29 public void setUp() throws Exception { 30 super.setUp(); 31 whileBlock = (While) readActivity(xml, false); 32 setNestedBlock(whileBlock); 33 34 receive = (Receive) whileBlock.getNode("receive"); 35 Token root = pi.getRootToken(); 36 VariableDefinition conditionDefinition = new VariableDefinition(); 37 conditionDefinition.setName("condition"); 38 conditionDefinition.setTypeInfo(new SchemaTypeInfo(new QName (BpelConstants.NS_XML_SCHEMA, "boolean"))); 39 condition = conditionDefinition.createInstance(root); 40 } 41 42 public void testFalseCondition() { 43 condition.setValue(Boolean.FALSE); 44 Token startToken = startNested(); 45 46 assertReceiveDisabled(startToken, receive); 47 assertCompleted(startToken); 48 } 49 50 public void testTrueCondition() { 51 condition.setValue(Boolean.TRUE); 52 Token startToken = startNested(); 53 54 assertReceiveAndAdvance(startToken, receive, receive); 56 condition.setValue(Boolean.FALSE); 58 assertReceiveAndComplete(startToken, receive); 59 } 60 } 61 | Popular Tags |