View Javadoc

1   /*
2    * $Id: GWESPatternsTest.java 1537 2011-07-27 15:34:04Z hoheisel $
3    *
4    * Copyright (c) 2005, The K-Wf Grid Consortium
5    * Fraunhofer Institute for Computer Architecture and Software Technology
6    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
7    */
8   
9   package net.kwfgrid.gwes;
10  
11  import junit.framework.Assert;
12  import junit.framework.Test;
13  import junit.framework.TestSuite;
14  import net.kwfgrid.gwes.exception.*;
15  import net.kwfgrid.gworkflowdl.structure.WorkflowFormatException;
16  import org.apache.log4j.Logger;
17  import org.jaxen.JaxenException;
18  import org.jdom.JDOMException;
19  
20  import java.io.IOException;
21  import java.util.List;
22  
23  /**
24   * <code>
25   * maven -Dtestcase=net.kwfgrid.gwes.GWESPatternsTest test:single
26   * </code>
27   *
28   * @author Andreas Hoheisel
29   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
30   * @version $Id: GWESPatternsTest.java 1537 2011-07-27 15:34:04Z hoheisel $
31   */
32  public final class GWESPatternsTest extends LocalGWESAbstractTestCase {
33  
34      static Logger logger = Logger.getLogger(GWESPatternsTest.class);
35  
36      /**
37       * Create the test case.
38       *
39       * @param testName name of the test case
40       */
41      public GWESPatternsTest(String testName) throws LoggingException {
42          super(testName);
43      }
44  
45      /**
46       * @return the suite of tests being tested
47       */
48      public static Test suite() {
49          return new TestSuite(GWESPatternsTest.class);
50      }
51  
52      /**
53       * Test examples/patterns/sequence.gwdl
54       */
55      public void testSequence() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
56          String gworkflowdl = testGWES("examples/patterns/sequence.gwdl", WorkflowStatus.STATUS_COMPLETED);
57          //logger.info(gworkflowdl);
58  
59          // check occurrence sequence
60          String sequence = extractOccurrenceSequence(gworkflowdl);
61          Assert.assertEquals("Occurrence sequence", "A B",sequence);
62  
63          // check tokens
64          List tokens = extractTokenChildElements(gworkflowdl);
65          Assert.assertEquals("Number of Tokens", 1, tokens.size());
66  
67          String[] endB = gwes.getData(workflowID, "end_B", userID);
68          logger.info("end_B[0]:\n" + endB[0]);
69          Assert.assertEquals("Number of Tokens on end_B", 1, endB.length);
70          Assert.assertEquals("end_B[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
71                  "  <string xmlns=\"\">a_out and b_out</string>\r\n" +
72                  "</data>", endB[0]);
73      }
74  
75      /**
76       * Test examples/patterns/parallel-split.gwdl
77       */
78      public void testParallelSplit() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
79          String gworkflowdl = testGWES("examples/patterns/parallel-split.gwdl", WorkflowStatus.STATUS_COMPLETED);
80          //logger.info(gworkflowdl);
81  
82          // check occurrence sequence
83          String sequence = extractOccurrenceSequence(gworkflowdl);
84          Assert.assertEquals("Occurrence sequence", "AND_Split A B",sequence);
85  
86          // check tokens
87          List tokens = extractTokenChildElements(gworkflowdl);
88          Assert.assertEquals("Number of token child elements", 2, tokens.size());
89  
90          String[] endA = gwes.getData(workflowID, "end_A", userID);
91          logger.info("end_A[0]:\n" + endA[0]);
92          Assert.assertEquals("Number of Tokens on end_A", 1, endA.length);
93          Assert.assertEquals("end_A[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
94                  "  <string xmlns=\"\">a_out</string>\r\n" +
95                  "</data>", endA[0]);
96  
97          String[] endB = gwes.getData(workflowID, "end_B", userID);
98          logger.info("end_B[0]:\n" + endB[0]);
99          Assert.assertEquals("Number of Tokens on end_B", 1, endB.length);
100         Assert.assertEquals("end_B[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
101                 "  <string xmlns=\"\">b_out</string>\r\n" +
102                 "</data>", endB[0]);
103     }
104 
105     /**
106      * Test examples/patterns/synchronization.gwdl
107      */
108     public void testSynchronization() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
109         String gworkflowdl = testGWES("examples/patterns/synchronization.gwdl", WorkflowStatus.STATUS_COMPLETED);
110 //        logger.info(gworkflowdl);
111 
112         // check occurrence sequence
113         String sequence = extractOccurrenceSequence(gworkflowdl);
114         Assert.assertEquals("Occurrence sequence", "A B AND_Join",sequence);
115 
116         // check tokens
117         List tokens = extractTokenChildElements(gworkflowdl);
118         Assert.assertEquals("Number of Tokens", 1, tokens.size());
119 
120         String[] end = gwes.getData(workflowID, "end", userID);
121         logger.info("end[0]:\n" + end[0]);
122         Assert.assertEquals("Number of Tokens on end", 1, end.length);
123         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
124                 "  <a xmlns=\"\">a_out</a>\r\n" +
125                 "  <b xmlns=\"\">b_out</b>\r\n" +
126                 "</data>", end[0]);
127     }
128 
129     /**
130      * Test examples/patterns/exclusive-choice.gwdl
131      */
132     public void testExclusiveChoice() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
133         String gworkflowdl = testGWES("examples/patterns/exclusive-choice.gwdl", WorkflowStatus.STATUS_COMPLETED);
134         //logger.info(gworkflowdl);
135 
136         // check occurrence sequence
137         String sequence = extractOccurrenceSequence(gworkflowdl);
138         Assert.assertEquals("Occurrence sequence", "A",sequence);
139 
140         // check tokens
141         List tokens = extractTokenChildElements(gworkflowdl);
142         Assert.assertEquals("Number of Tokens", 1, tokens.size());
143 
144         String[] endA = gwes.getData(workflowID, "end_A", userID);
145         logger.info("end_A[0]:\n" + endA[0]);
146         Assert.assertEquals("Number of Tokens on end_A", 1, endA.length);
147         Assert.assertEquals("end_A[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
148                 "  <string xmlns=\"\">a_out</string>\r\n" +
149                 "</data>", endA[0]);
150 
151         String[] endB = gwes.getData(workflowID, "end_B", userID);
152         Assert.assertEquals("Number of Tokens on end_B", 0, endB.length);
153     }
154 
155     /**
156      * Test examples/patterns/simple-merge.gwdl
157      */
158     public void testSimpleMerge() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
159         String gworkflowdl = testGWES("examples/patterns/simple-merge.gwdl", WorkflowStatus.STATUS_COMPLETED);
160         //logger.info(gworkflowdl);
161 
162         // check occurrence sequence
163         String sequence = extractOccurrenceSequence(gworkflowdl);
164         Assert.assertEquals("Occurrence sequence", "A C",sequence);
165 
166         // check tokens
167         List tokens = extractTokenChildElements(gworkflowdl);
168         Assert.assertEquals("Number of Tokens", 1, tokens.size());
169 
170         String[] endC = gwes.getData(workflowID, "end_C", userID);
171         logger.info("end_C[0]:\n" + endC[0]);
172         Assert.assertEquals("Number of Tokens on end_C", 1, endC.length);
173         Assert.assertEquals("end_C[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
174                 "  <string xmlns=\"\">c_out</string>\r\n" +
175                 "</data>", endC[0]);
176     }
177 
178     /**
179      * Test examples/patterns/multi-choice.gwdl
180      */
181     public void testMultiChoice() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
182         String gworkflowdl = testGWES("examples/patterns/multi-choice.gwdl", WorkflowStatus.STATUS_COMPLETED);
183         //logger.info(gworkflowdl);
184 
185         // check occurrence sequence
186         String sequence = extractOccurrenceSequence(gworkflowdl);
187         Assert.assertEquals("Occurrence sequence", "A_and_B only_B A B B",sequence);
188 
189         // check tokens
190         List tokens = extractTokenChildElements(gworkflowdl);
191         Assert.assertEquals("Number of Tokens", 3, tokens.size());
192 
193         String[] endA = gwes.getData(workflowID, "end_A", userID);
194         Assert.assertEquals("Number of Tokens on end_A", 1, endA.length);
195         logger.info("end_A[0]:\n" + endA[0]);
196         Assert.assertEquals("end_A[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
197                 "  <string xmlns=\"\">a_out</string>\r\n" +
198                 "</data>", endA[0]);
199 
200         String[] endB = gwes.getData(workflowID, "end_B", userID);
201         Assert.assertEquals("Number of Tokens on end_B", 2, endB.length);
202         logger.info("end_B[0]:\n" + endB[0]);
203         logger.info("end_B[1]:\n" + endB[1]);
204         Assert.assertEquals("end_B[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
205                 "  <string xmlns=\"\">b_out</string>\r\n" +
206                 "</data>", endB[0]);
207         Assert.assertEquals("end_B[1]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
208                 "  <string xmlns=\"\">b_out</string>\r\n" +
209                 "</data>", endB[1]);
210     }
211 
212     /**
213      * Test examples/patterns/structured-synchronizing-merge_single.gwdl
214      */
215     public void testStructuredSynchronizingMergeSingle() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
216         String gworkflowdl = testGWES("examples/patterns/structured-synchronizing-merge_single.gwdl", WorkflowStatus.STATUS_COMPLETED);
217         //logger.info(gworkflowdl);
218 
219         // check occurrence sequence
220         String sequence = extractOccurrenceSequence(gworkflowdl);
221         Assert.assertEquals("Occurrence sequence", "A_and_B A B post_AB",sequence);
222 
223         // check tokens
224         List tokens = extractTokenChildElements(gworkflowdl);
225         Assert.assertEquals("Number of token child elements", 2, tokens.size());
226 
227         String[] end = gwes.getData(workflowID, "end", userID);
228         Assert.assertEquals("Number of Tokens on end", 1, end.length);
229         logger.info("end[0]:\n" + end[0]);
230         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
231                 "  <a xmlns=\"\">a_out</a>\r\n" +
232                 "  <b xmlns=\"\">b_out</b>\r\n" +
233                 "</data>", end[0]);
234     }
235 
236     /**
237      * Test examples/patterns/structured-synchronizing-merge.gwdl
238      * ToDo: Fix problem with this testcase (refer to https://bugs.first.fraunhofer.de/browse/GWES-65)
239      */
240 //    public void testStructuredSynchronizingMerge() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException {
241 //        String gworkflowdl = testGWES("examples/patterns/structured-synchronizing-merge.gwdl", GenericWorkflowHandler.STATUS_COMPLETED);
242 //        //logger.info(gworkflowdl);
243 //
244 //        // check occurrence sequence
245 //        String sequence = extractOccurrenceSequence(gworkflowdl);
246 //        Assert.assertEquals("Occurrence sequence", "A_and_B only_B A B B post_B post_AB",sequence);
247 //
248 //        // check tokens
249 //        List tokens = extractTokenChildElements(gworkflowdl);
250 //        Assert.assertEquals("Number of token child elements", 4, tokens.size());
251 //
252 //        String[] end = gwes.getData(workflowID, "end");
253 //        Assert.assertEquals("Number of Tokens on end", 2, end.length);
254 //        logger.info("end[0]:\n" + end[0]);
255 //        logger.info("end[1]:\n" + end[1]);
256 //        Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
257 //                "  <b xmlns=\"\">b_out</b>\r\n" +
258 //                "</data>", end[0]);
259 //        Assert.assertEquals("end[1]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
260 //                "  <a xmlns=\"\">a_out</a>\r\n" +
261 //                "  <b xmlns=\"\">b_out</b>\r\n" +
262 //                "</data>", end[1]);
263 //    }
264 
265     /**
266      * Test examples/patterns/multi-merge.gwdl
267      */
268     public void testMultiMerge() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, StateTransitionException, WorkflowSecurityException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
269         String gworkflowdl = testGWES("examples/patterns/multi-merge.gwdl", WorkflowStatus.STATUS_COMPLETED);
270         //logger.info(gworkflowdl);
271 
272         // check occurrence sequence
273         String sequence = extractOccurrenceSequence(gworkflowdl);
274         Assert.assertEquals("Occurrence sequence", "A B C C",sequence);
275 
276         // check tokens
277         List tokens = extractTokenChildElements(gworkflowdl);
278         Assert.assertEquals("Number of Tokens", 2, tokens.size());
279 
280         String[] endC = gwes.getData(workflowID, "end_C", userID);
281         Assert.assertEquals("Number of Tokens on end_C", 2, endC.length);
282         logger.info("end_C[0]:\n" + endC[0]);
283         logger.info("end_C[1]:\n" + endC[1]);
284         Assert.assertEquals("end_C[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
285                 "  <c_in xmlns=\"\">a_out</c_in>\r\n" +
286                 "</data>", endC[0]);
287         Assert.assertEquals("end_C[1]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
288                 "  <c_in xmlns=\"\">b_out</c_in>\r\n" +
289                 "</data>", endC[1]);
290     }
291 
292     /**
293      * Test examples/patterns/structured-discriminator.gwdl
294      */
295     public void testStructuredDiscriminator() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
296         String gworkflowdl = testGWES("examples/patterns/structured-discriminator.gwdl", WorkflowStatus.STATUS_COMPLETED);
297         //logger.info(gworkflowdl);
298 
299         // check occurrence sequence
300         String sequence = extractOccurrenceSequence(gworkflowdl);
301         Assert.assertEquals("Occurrence sequence", "A B C next release",sequence);
302 
303         // check tokens
304         List tokens = extractTokenChildElements(gworkflowdl);
305         Assert.assertEquals("Number of token child elements", 2, tokens.size());
306 
307         String[] endC = gwes.getData(workflowID, "end_C", userID);
308         Assert.assertEquals("Number of Tokens on end_C", 1, endC.length);
309         logger.info("end_C[0]:\n" + endC[0]);
310         Assert.assertEquals("end_C[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
311                 "  <c_in xmlns=\"\">a_out</c_in>\r\n" +
312                 "</data>", endC[0]);
313 
314         String[] end = gwes.getData(workflowID, "end", userID);
315         Assert.assertEquals("Number of Tokens on end", 1, end.length);
316         logger.info("end[0]:\n" + end[0]);
317         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
318                 "  <i xmlns=\"\">2.0</i>\r\n" +
319                 "</data>", end[0]);
320     }
321 
322     /**
323      * Test examples/patterns/structured-discriminator_b.gwdl
324      */
325     public void testStructuredDiscriminatorB() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
326         String gworkflowdl = testGWES("examples/patterns/structured-discriminator_b.gwdl", WorkflowStatus.STATUS_COMPLETED);
327         //logger.info(gworkflowdl);
328 
329         // check occurrence sequence
330         String sequence = extractOccurrenceSequence(gworkflowdl);
331         Assert.assertEquals("Occurrence sequence", "A B C ignore release",sequence);
332 
333         // check tokens
334         List tokens = extractTokenChildElements(gworkflowdl);
335         Assert.assertEquals("Number of Tokens", 3, tokens.size());
336 
337         String[] endC = gwes.getData(workflowID, "end_C", userID);
338         Assert.assertEquals("Number of Tokens on end_C", 1, endC.length);
339         logger.info("end_C[0]:\n" + endC[0]);
340         Assert.assertEquals("end_C[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
341                 "  <c_in xmlns=\"\">a_out</c_in>\r\n" +
342                 "</data>", endC[0]);
343 
344         String[] end = gwes.getData(workflowID, "end", userID);
345         Assert.assertEquals("Number of Tokens on end", 1, end.length);
346         logger.info("end[0]:\n" + end[0]);
347         Assert.assertEquals("end[0]", "<control>true</control>", end[0]);
348     }
349 
350     /**
351      * Test examples/patterns/structured-discriminator_c.gwdl
352      */
353     public void testStructuredDiscriminatorC() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
354         String gworkflowdl = testGWES("examples/patterns/structured-discriminator_c.gwdl", WorkflowStatus.STATUS_COMPLETED);
355 //        logger.info(gworkflowdl);
356 
357         // check occurrence sequence
358         String sequence = extractOccurrenceSequence(gworkflowdl);
359         Assert.assertEquals("Occurrence sequence", "AND AND B B C C A ignore A ignore",sequence);
360 
361         // check tokens
362         List tokens = extractTokenChildElements(gworkflowdl);
363         Assert.assertEquals("Number of token child elements", 4, tokens.size());
364 
365         String[] endC = gwes.getData(workflowID, "end_C", userID);
366         Assert.assertEquals("Number of Tokens on end_C", 2, endC.length);
367         logger.info("end_C[0]:\n" + endC[0]);
368         Assert.assertEquals("end_C[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
369                 "  <c_in xmlns=\"\">b_out</c_in>\r\n" +
370                 "</data>", endC[0]);
371         logger.info("end_C[1]:\n" + endC[1]);
372         Assert.assertEquals("end_C[1]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
373                 "  <c_in xmlns=\"\">b_out</c_in>\r\n" +
374                 "</data>", endC[1]);
375     }
376 
377     /**
378      * Test examples/patterns/blocking-discriminator.gwdl
379      */
380     public void testBlockingDiscriminator() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
381         String gworkflowdl = testGWES("examples/patterns/blocking-discriminator.gwdl", WorkflowStatus.STATUS_COMPLETED);
382         //logger.info(gworkflowdl);
383 
384         // check occurrence sequence
385         String sequence = extractOccurrenceSequence(gworkflowdl);
386         Assert.assertEquals("Occurrence sequence", "AND B A C ignore release AND B A C ignore release",sequence);
387 
388         // check tokens
389         List tokens = extractTokenChildElements(gworkflowdl);
390         Assert.assertEquals("Number of Tokens", 6, tokens.size());
391 
392         String[] endC = gwes.getData(workflowID, "end_C", userID);
393         Assert.assertEquals("Number of Tokens on end_C", 2, endC.length);
394         logger.info("end_C[0]:\n" + endC[0]);
395         Assert.assertEquals("end_C[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
396                 "  <c_in xmlns=\"\">b_out</c_in>\r\n" +
397                 "</data>", endC[0]);
398         logger.info("end_C[1]:\n" + endC[1]);
399         Assert.assertEquals("end_C[1]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
400                 "  <c_in xmlns=\"\">b_out</c_in>\r\n" +
401                 "</data>", endC[1]);
402 
403         String[] end = gwes.getData(workflowID, "end", userID);
404         Assert.assertEquals("Number of Tokens on end", 2, end.length);
405         logger.info("end[0]:\n" + end[0]);
406         Assert.assertEquals("end[0]", "<control>true</control>", end[0]);
407         logger.info("end[1]:\n" + end[1]);
408         Assert.assertEquals("end[1]", "<control>true</control>", end[1]);
409     }
410 
411     /**
412      * Test examples/patterns/cancelling-discriminator.gwdl
413      */
414     public void testCancellingDiscriminator() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
415         String gworkflowdl = testGWES("examples/patterns/cancelling-discriminator.gwdl", WorkflowStatus.STATUS_COMPLETED);
416         //logger.info(gworkflowdl);
417 
418         // check occurrence sequence
419         String sequence = extractOccurrenceSequence(gworkflowdl);
420         Assert.assertEquals("Occurrence sequence", "A B AND C",sequence);
421 
422         // check tokens
423         List tokens = extractTokenChildElements(gworkflowdl);
424         Assert.assertEquals("Number of token child elements", 1, tokens.size());
425 
426         String[] end = gwes.getData(workflowID, "end", userID);
427         Assert.assertEquals("Number of Tokens on end", 1, end.length);
428         logger.info("end[0]:\n" + end[0]);
429         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
430                 "  <string xmlns=\"\">c_out</string>\r\n" +
431                 "</data>", end[0]);
432     }
433 
434     /**
435      * Test examples/patterns/cancelling-discriminator_2.gwdl
436      */
437     public void testCancellingDiscriminator2() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
438         String gworkflowdl = testGWES("examples/patterns/cancelling-discriminator_2.gwdl", WorkflowStatus.STATUS_COMPLETED);
439         //logger.info(gworkflowdl);
440 
441         // check occurrence sequence
442         String sequence = extractOccurrenceSequence(gworkflowdl);
443         Assert.assertEquals("Occurrence sequence", "B cancel_A A remove_A C",sequence);
444 
445         // check tokens
446         List tokens = extractTokenChildElements(gworkflowdl);
447         Assert.assertEquals("Number of Tokens", 1, tokens.size());
448 
449         String[] end = gwes.getData(workflowID, "end", userID);
450         Assert.assertEquals("Number of Tokens on end", 1, end.length);
451         logger.info("end[0]:\n" + end[0]);
452         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
453                 "  <string xmlns=\"\">c_out</string>\r\n" +
454                 "</data>", end[0]);
455     }
456 
457     /**
458      * Test examples/patterns/cancelling-discriminator_3.gwdl
459      */
460     public void testCancellingDiscriminator3() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
461         String gworkflowdl = testGWES("examples/patterns/cancelling-discriminator_3.gwdl", WorkflowStatus.STATUS_COMPLETED);
462         //logger.info(gworkflowdl);
463 
464         // check occurrence sequence
465         String sequence = extractOccurrenceSequence(gworkflowdl);
466         Assert.assertEquals("Occurrence sequence", "A cancel_B B remove_B C",sequence);
467 
468         // check tokens
469         List tokens = extractTokenChildElements(gworkflowdl);
470         Assert.assertEquals("Number of Tokens", 1, tokens.size());
471 
472         String[] end = gwes.getData(workflowID, "end", userID);
473         Assert.assertEquals("Number of Tokens on end", 1, end.length);
474         logger.info("end[0]:\n" + end[0]);
475         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
476                 "  <string xmlns=\"\">c_out</string>\r\n" +
477                 "</data>", end[0]);
478     }
479 
480     /**
481      * Test examples/patterns/structured-partial-join.gwdl
482      */
483     public void testStructuredPartialJoin() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
484         String gworkflowdl = testGWES("examples/patterns/structured-partial-join.gwdl", WorkflowStatus.STATUS_COMPLETED);
485         //logger.info(gworkflowdl);
486 
487         // check occurrence sequence
488         String sequence = extractOccurrenceSequence(gworkflowdl);
489         Assert.assertEquals("Occurrence sequence", "A B Use_1 Use_2 D C Ignore_3 Release",sequence);
490 
491         // check tokens
492         List tokens = extractTokenChildElements(gworkflowdl);
493         Assert.assertEquals("Number of token child elements", 3, tokens.size());
494 
495         String[] end = gwes.getData(workflowID, "end", userID);
496         Assert.assertEquals("Number of Tokens on end", 1, end.length);
497         logger.info("end[0]:\n" + end[0]);
498         Assert.assertEquals("end[0]", "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
499                 "  <string xmlns=\"\">released</string>\r\n" +
500                 "</data>", end[0]);
501     }
502 
503     /**
504      * Test examples/patterns/combine-tokens.gwdl
505      */
506     public void testCombineTokens() throws JaxenException, IOException, JDOMException, NoSuchWorkflowException, WorkflowSecurityException, StateTransitionException, WorkflowFormatException, InterruptedException, DatabaseException, LoggingException, GWESException {
507         String gworkflowdl = testGWES("examples/patterns/combine-tokens.gwdl", WorkflowStatus.STATUS_COMPLETED);
508 //        logger.info(gworkflowdl);
509 
510         // check occurrence sequence
511         String sequence = extractOccurrenceSequence(gworkflowdl);
512         Assert.assertEquals("Occurrence sequence", "combine_AxB next_A combine_AxB next_A combine_AxB next_A next_B pushback_A pushback_A pushback_A remove_B combine_AxB next_A combine_AxB next_A combine_AxB next_A next_B pushback_A pushback_A pushback_A remove_B remove_A remove_A remove_A f_AxB f_AxB f_AxB f_AxB f_AxB f_AxB",sequence);
513 
514         // check tokens
515         List tokens = extractTokenChildElements(gworkflowdl);
516         Assert.assertEquals("Number of Tokens", 14, tokens.size());
517 
518         String[] end = gwes.getData(workflowID, "AxB_combined", userID);
519         logger.info("AxB_combined[0]:\n" + end[0]);
520         Assert.assertEquals("AxB_combined[0]", createColouredAnimal("red", "rabbit"), end[0]);
521         Assert.assertEquals("AxB_combined[1]", createColouredAnimal("green", "rabbit"), end[1]);
522         Assert.assertEquals("AxB_combined[2]", createColouredAnimal("yellow", "rabbit"), end[2]);
523         Assert.assertEquals("AxB_combined[3]", createColouredAnimal("red", "frog"), end[3]);
524         Assert.assertEquals("AxB_combined[4]", createColouredAnimal("green", "frog"), end[4]);
525         Assert.assertEquals("AxB_combined[5]", createColouredAnimal("yellow", "frog"), end[5]);
526 
527         String[] counter = gwes.getData(workflowID, "counter", userID);
528         Assert.assertEquals("Number of tokens on counter",1,counter.length);
529         logger.info("counter:\n" + counter[0]);
530         Assert.assertEquals("counter[0]","<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
531                 "  <double xmlns=\"\">6.0</double>\r\n" +
532                 "</data>",counter[0]);
533     }
534 
535     private String createColouredAnimal(String colour, String animal) {
536         return "<data xmlns=\"http://www.gridworkflow.org/gworkflowdl\">\r\n" +
537                "  <a xmlns=\"\">"+colour+"</a>\r\n" +
538                "  <b xmlns=\"\">"+animal+"</b>\r\n" +
539                "</data>";
540     }
541 
542     /**
543      * *******************************************************************************************
544      * End of public test classes.
545      * ********************************************************************************************
546      */
547 
548 }