View Javadoc

1   /*
2    * $Id: GWES_ResourceMatcherProraterTest.java 1537 2011-07-27 15:34:04Z hoheisel $
3    *
4    * Copyright (c) 2005-2006, 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 net.kwfgrid.gwes.exception.*;
12  import net.kwfgrid.gworkflowdl.structure.WorkflowFormatException;
13  import org.apache.log4j.Logger;
14  import junit.framework.Test;
15  import junit.framework.TestSuite;
16  import junit.framework.Assert;
17  
18  import java.io.IOException;
19  
20  /**
21   * This test requires the gwes to be configured for accessing the dgrdl XML database.
22   * Invoke this test with maven using:
23   * <p>
24   * <code>
25   * grid-proxy-init<br>
26   * maven -Dtestcase=net.kwfgrid.gwes.GWES_ResourceMatcherProraterTest test:single
27   * </code>
28   * @author Andreas Hoheisel
29   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
30   * @version $Id: GWES_ResourceMatcherProraterTest.java 1537 2011-07-27 15:34:04Z hoheisel $
31   */
32  public final class GWES_ResourceMatcherProraterTest extends LocalGWESAbstractTestCase {
33  
34      /**
35       * log4j logger
36       */
37      static Logger logger = Logger.getLogger(GWES_ResourceMatcherProraterTest.class);
38  
39      private boolean finished;
40  
41      static private final long TIMEOUT = 1000L;
42  
43      public final String userID;
44  
45      GWES gwes;
46  
47      String workflowID;
48  
49  
50      /**
51       * Create the test case.
52       *
53       * @param testName name of the test case
54       */
55      public GWES_ResourceMatcherProraterTest(String testName) throws LoggingException {
56          super(testName);
57          userID = System.getProperty("user.name");
58      }
59  
60      /**
61       * @return the suite of tests being tested
62       */
63      public static Test suite() {
64          return new TestSuite(GWES_ResourceMatcherProraterTest.class);
65      }
66  
67      /**
68       * Test workflow with program execution candidates.
69       */
70      public void testProrater() throws StateTransitionException, IOException, WorkflowFormatException, WorkflowSecurityException, InterruptedException, NoSuchWorkflowException, DatabaseException, LoggingException, GWESException {
71  
72          String gworkflowdl = testGWES("examples/programexecution/concatenateIt_20.xml");
73  
74          String[] data = gwes.getData(workflowID, "d25-27", userID);
75          Assert.assertEquals("number of Tokens on d25-27", 1, data.length);
76          logger.info("d25-27:\n" + data[0].trim());
77          Assert.assertEquals("d27-27 token", "...", data[0]);
78  
79      }
80  
81      /**
82       * Test workflow with program execution candidates.
83       */
84      public void testResourceMatcher() throws StateTransitionException, IOException, WorkflowFormatException, WorkflowSecurityException, InterruptedException, NoSuchWorkflowException, DatabaseException, LoggingException, GWESException {
85  
86          String gworkflowdl = testGWES("examples/programexecution/concatenateIt_10.xml");
87  
88          logger.info(gworkflowdl);
89  
90      }
91  
92      /**
93       * *******************************************************************************************
94       * End of public test classes.
95       * ********************************************************************************************
96       */
97  
98      private String testGWES(String gworkflowdlPath) throws StateTransitionException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, InterruptedException, IOException, DatabaseException, LoggingException, GWESException {
99          String retGWorkflowDL = null;
100 
101         gwes = new GWESEngine();
102 
103         workflowID = gwes.initiate(readfile(gworkflowdlPath), userID);
104         logger.debug("workflowID: " + workflowID);
105         gwes.start(workflowID, userID);
106 
107         waitWorkflowStatus(gwes, workflowID);
108 
109         retGWorkflowDL = gwes.getWorkflowDescription(workflowID, userID);
110         logger.debug("\n" + retGWorkflowDL);
111 
112         return retGWorkflowDL;
113     }
114 
115 }