1 package org.jbpm.bpel.exe.flow; 2 3 import org.jbpm.graph.exe.Token; 4 5 import org.jbpm.bpel.def.Flow; 6 import org.jbpm.bpel.def.Receive; 7 import org.jbpm.bpel.def.Sequence; 8 import org.jbpm.bpel.exe.AbstractExeTestCase; 9 10 14 public class DPE1ExampleTest extends AbstractExeTestCase { 15 private Flow flow; 16 private Sequence s; 17 private Receive a; 18 private Receive b; 19 private Receive c; 20 private Receive x; 21 private Receive y; 22 23 29 30 public void initActivities() { 31 s = (Sequence) flow.getNode("S"); 32 a = (Receive) s.getNode("A"); 33 b = (Receive) s.getNode("B"); 34 c = (Receive) s.getNode("C"); 35 x = (Receive) flow.getNode("X"); 36 y = (Receive) flow.getNode("Y"); 37 } 38 39 43 public void testFail() throws Exception { 44 flow = (Flow) readActivity(getClass().getResource("DPE1-Example.bpel"), false); 45 flow.setSuppressJoinFailure(Boolean.FALSE); 46 setNestedBlock(flow); 47 initActivities(); 48 49 Token startToken = startNested(); 50 51 Token tokenS = findToken(startToken, a); 54 Token tokenX = findToken(startToken, x); 55 Token tokenY = findToken(startToken, y); 56 57 assertReceiveAndAdvance( tokenS, a, b ); 59 assertReceiveDisabled( tokenS, b ); 61 62 assertReceiveAndAdvance( tokenX, x, flow.getEnd() ); 64 65 try { 66 y.messageReceived(y.getReceiver(), null, tokenY); 68 } 69 catch(RuntimeException e) { 70 assertReceiveDisabled( tokenS, b ); 71 return; 72 } 73 fail("y must throw an error since join condition at b fails"); 74 } 75 76 public void testInitialFail() throws Exception { 77 flow = (Flow) readActivity(getClass().getResource("DPE1-Example.bpel"), true); 78 flow.setSuppressJoinFailure(Boolean.FALSE); 79 setRootBlock(flow); 80 initActivities(); 81 a.setCreateInstance(true); 82 83 Token startToken = startInitial(a.getReceiver()); 84 85 Token tokenS = findToken(startToken, b); 87 assertNotNull( tokenS ); 88 assertReceiveDisabled( tokenS, b ); 90 91 Token tokenX = findToken(startToken, x); 94 Token tokenY = findToken(startToken, y); 95 96 assertReceiveAndAdvance( tokenX, x, flow.getEnd() ); 98 99 try { 100 y.messageReceived(y.getReceiver(), null, tokenY); 102 } 103 catch(RuntimeException e) { 104 assertReceiveDisabled( tokenS, b ); 105 return; 106 } 107 fail("y must throw an error since join condition at b fails"); 108 } 109 110 113 114 public void testSuppress() throws Exception { 115 flow = (Flow) readActivity(getClass().getResource("DPE1-Example.bpel"), false); 116 flow.setSuppressJoinFailure(Boolean.TRUE); 117 setNestedBlock(flow); 118 initActivities(); 119 120 Token startToken = startNested(); 121 122 Token tokenS = findToken(startToken, a); Token tokenX = findToken(startToken, x); Token tokenY = findToken(startToken, y); 128 assertReceiveAndAdvance( tokenS, a, b ); 130 assertReceiveDisabled( tokenS, b ); 132 133 assertReceiveAndAdvance( tokenX, x, flow.getEnd() ); 135 assertReceiveAndAdvance( tokenY, y, flow.getEnd() ); 137 138 assertReceiveDisabled( tokenS, b ); 140 assertReceiveAndComplete( tokenS, c ); 142 } 143 144 145 146 public void testInitialSuppress() throws Exception { 147 flow = (Flow) readActivity(getClass().getResource("DPE1-Example.bpel"), true); 148 flow.setSuppressJoinFailure(Boolean.TRUE); 149 setRootBlock(flow); 150 initActivities(); 151 152 a.setCreateInstance(true); 153 Token startToken = startInitial(a.getReceiver()); 154 Token tokenS = findToken(startToken, b); 156 assertSame( b, tokenS.getNode() ); 157 assertReceiveDisabled( tokenS, b ); 159 160 Token tokenX = findToken(startToken, x); 163 Token tokenY = findToken(startToken, y); 164 165 assertReceiveAndAdvance( tokenX, x, flow.getEnd() ); 167 assertReceiveAndAdvance( tokenY, y, flow.getEnd() ); 169 170 assertReceiveDisabled( tokenS, b ); 172 assertReceiveAndComplete( tokenS, c ); 174 } 175 } 176 | Popular Tags |