1 package org.jbpm.bpel.exe; 2 3 import org.jbpm.graph.exe.Token; 4 5 import org.jbpm.bpel.def.Flow; 6 import org.jbpm.bpel.def.Receive; 7 8 12 public class FlowExeTest extends AbstractExeTestCase { 13 Flow flow; 14 Receive receiveA; 15 Receive receiveB; 16 Receive receiveC; 17 18 String xml = 19 "<flow>" + 20 " <receive name='a' partnerLink='aPartner' operation='o'/>" + 21 " <receive name='b' partnerLink='aPartner' operation='o'/>" + 22 " <receive name='c' partnerLink='aPartner' operation='o'/>" + 23 "</flow>"; 24 25 public void testInitialFirstScenario() throws Exception { 26 flow = (Flow) readActivity(xml, true); 27 setRootBlock(flow); 28 validateInitial("a", "b", "c"); 29 } 30 31 public void testInitialSecondScenario() throws Exception { 32 flow = (Flow) readActivity(xml, true); 33 setRootBlock(flow); 34 validateInitial("b", "a", "c"); 35 } 36 37 public void testInitialThirdScenario() throws Exception { 38 flow = (Flow) readActivity(xml, true); 39 setRootBlock(flow); 40 validateInitial("c", "a", "b"); 41 } 42 43 public void testNestedFirstScenario() throws Exception { 44 flow = (Flow) readActivity(xml, false); 45 setNestedBlock(flow); 46 validateNested("a", "b", "c"); 47 } 48 49 public void testNestedSecondScenario() throws Exception { 50 flow = (Flow) readActivity(xml, false); 51 setNestedBlock(flow); 52 validateNested("b", "a", "c"); 53 } 54 55 public void testNestedThirdScenario() throws Exception { 56 flow = (Flow) readActivity(xml, false); 57 setNestedBlock(flow); 58 validateNested("c", "a", "b"); 59 } 60 61 public void initActivities(String a, String b, String c, boolean initial) { 62 receiveA = (Receive) flow.getNode(a); 63 if(initial) receiveA.setCreateInstance(true); 64 receiveB = (Receive) flow.getNode(b); 65 receiveC = (Receive) flow.getNode(c); 66 } 67 68 public void validateInitial(String a, String b, String c) { 69 initActivities(a, b, c, true); 70 Token parent = startInitial(receiveA.getReceiver()); 71 72 Token tokenA = parent.getChild(receiveA.getName()); 73 assertSame( flow.getEnd() , tokenA.getNode() ); 75 76 Token tokenB = parent.getChild(receiveB.getName()); 79 Token tokenC = parent.getChild(receiveC.getName()); 80 81 assertReceiveAndAdvance(tokenB, receiveB, flow.getEnd()); 83 84 assertReceiveAndComplete(tokenC, receiveC); 86 } 87 88 public void validateNested(String a, String b, String c) { 89 initActivities(a, b, c, false); 90 Token startToken = startNested(); 91 92 Token tokenA = startToken.getChild(a); 95 Token tokenB = startToken.getChild(b); 96 Token tokenC = startToken.getChild(c); 97 98 assertReceiveAndAdvance(tokenA, receiveA, flow.getEnd()); 100 101 assertReceiveAndAdvance(tokenB, receiveB, flow.getEnd()); 103 104 assertReceiveAndComplete(tokenC, receiveC); 106 } 107 } 108 | Popular Tags |