KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > exe > SequenceExeTest


1 package org.jbpm.bpel.exe;
2
3 import org.jbpm.graph.exe.Token;
4
5 import org.jbpm.bpel.def.Receive;
6 import org.jbpm.bpel.def.Sequence;
7
8 /**
9  * @author Juan Cantú
10  * @version $Revision: 1.2 $ $Date: 2005/04/27 20:52:27 $
11  */

12 public class SequenceExeTest extends AbstractExeTestCase {
13   Sequence sequence;
14   Receive receiveA;
15   Receive receiveB;
16   Receive receiveC;
17   
18   public void initActivities() {
19     receiveA = (Receive) sequence.getNode("a");
20     receiveB = (Receive) sequence.getNode("b");
21     receiveC = (Receive) sequence.getNode("c");
22   }
23   
24   public void testInitialSequence() throws Exception JavaDoc {
25     String JavaDoc xml =
26         "<sequence>" +
27         " <receive name='a' createInstance='yes' partnerLink='aPartner' operation='o'/>" +
28         " <receive name='b' partnerLink='aPartner' operation='o'/>" +
29         " <receive name='c' partnerLink='aPartner' operation='o'/>" +
30         "</sequence>";
31     
32     sequence = (Sequence) readActivity(xml, true);
33     setRootBlock(sequence);
34     initActivities();
35     Token token = startInitial(receiveA.getReceiver());
36     assertReceiveAndAdvance(token, receiveB, receiveC);
37     assertReceiveAndComplete(token, receiveC);
38   }
39   
40   public void testNestedSequence() throws Exception JavaDoc {
41     String JavaDoc xml =
42         "<sequence>" +
43         " <receive name='a' partnerLink='aPartner' operation='o'/>" +
44         " <receive name='b' partnerLink='aPartner' operation='o'/>" +
45         " <receive name='c' partnerLink='aPartner' operation='o'/>" +
46         "</sequence>";
47     
48     sequence = (Sequence) readActivity(xml, false);
49     setNestedBlock(sequence);
50     initActivities();
51     Token token = startNested();
52     assertReceiveAndAdvance(token, receiveA, receiveB);
53     assertReceiveAndAdvance(token, receiveB, receiveC);
54     assertReceiveAndComplete(token, receiveC);
55   }
56 }
57
Popular Tags