1   /*$Id: ForMultipleFeatureTest.java,v 1.3 2005/04/25 12:13:54 clq2 Exp $
2    * Created on 09-Dec-2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.jes.jobscheduler.impl.groovy;
12  
13  import org.astrogrid.workflow.beans.v1.For;
14  import org.astrogrid.workflow.beans.v1.Script;
15  import org.astrogrid.workflow.beans.v1.Sequence;
16  import org.astrogrid.workflow.beans.v1.Set;
17  import org.astrogrid.workflow.beans.v1.Workflow;
18  
19  /***
20   * @author Noel Winstanley nw@jb.man.ac.uk 09-Dec-2004
21   *
22   */
23  public class ForMultipleFeatureTest extends ForManyFeatureTest {
24  
25      /*** Construct a new ForMultipleFeatureTest
26       * @param name
27       */
28      public ForMultipleFeatureTest(String name) {
29          super(name);
30      }
31  
32      /***
33       * @see org.astrogrid.jes.jobscheduler.impl.groovy.AbstractTestForFeature#buildWorkflow()
34       */
35      protected Workflow buildWorkflow() {
36          Workflow wf = super.createMinimalWorkflow();
37          Set acc = new Set();
38          acc.setVar("acc");
39          acc.setValue("${0}");
40          wf.getSequence().addActivity(acc);
41          
42          For f = new For();
43          f.setVar("i");
44          f.setItems("${1..10}");
45          Sequence seq = new Sequence();
46          f.setActivity(seq);
47          
48          Script sc = new Script();
49          sc.setBody("acc = acc + i");
50          seq.addActivity(sc);
51   
52          Script sc2 = new Script();
53          sc2.setBody("acc = acc + 100");
54          seq.addActivity(sc2);        
55          
56          // need to check that this one is getting executed too.
57          Script sc1 = new Script();
58          sc1.setBody("acc = acc + 10");
59         seq.addActivity(sc1);
60          
61          wf.getSequence().addActivity(f);
62          
63  
64          Script end1 = new Script();
65          end1.setBody("print (acc)"); 
66          wf.getSequence().addActivity(end1);        
67          
68          return wf;        
69      }
70  
71      protected void verifyWorkflow(Workflow result) {
72          assertWorkflowCompleted(result);
73          /*@todo don't care about this for now. - no time, put in later
74          Script body = (Script)((For)result.getSequence().getActivity(1)).getActivity();
75          assertEquals(10,body.getStepExecutionRecordCount());
76          for (int i = 0; i < body.getStepExecutionRecordCount(); i++) {
77              StepExecutionRecord rec = body.getStepExecutionRecord(i);
78              assertEquals(ExecutionPhase.COMPLETED,rec.getStatus());
79              assertTrue(rec.getMessageCount() > 0);        
80          }*/
81          
82          Script end = (Script)result.getSequence().getActivity(2);
83          assertScriptCompletedWithMessage(end,"1155");        
84      }
85  }
86  
87  
88  /* 
89  $Log: ForMultipleFeatureTest.java,v $
90  Revision 1.3  2005/04/25 12:13:54  clq2
91  jes-nww-776-again
92  
93  Revision 1.2.40.1  2005/04/11 13:57:52  nw
94  altered to use fileJobFactory instead of InMemoryJobFactory - more realistic
95  
96  Revision 1.2  2004/12/09 16:39:12  clq2
97  nww_jes_panic
98  
99  Revision 1.1.2.1  2004/12/09 16:11:03  nw
100 fixed for and while loops
101  
102 */