View Javadoc

1   /*
2    * $Id: GWES_HierarchicalTest.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 org.apache.log4j.Logger;
16  import org.jdom.JDOMException;
17  import org.jdom.Element;
18  import org.jaxen.JaxenException;
19  
20  import java.io.*;
21  import java.util.List;
22  
23  import net.kwfgrid.gworkflowdl.structure.WorkflowFormatException;
24  
25  /**
26   *
27   * <code>
28   * maven -Dtestcase=net.kwfgrid.gwes.GWES_HierarchicalTest test:single
29   * </code>
30   *
31   * @author Andreas Hoheisel
32   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
33   * @version $Id: GWES_HierarchicalTest.java 1537 2011-07-27 15:34:04Z hoheisel $
34   */
35  public final class GWES_HierarchicalTest extends LocalGWESAbstractTestCase {
36  
37      /**
38       * log4j logger
39       */
40      static Logger logger = Logger.getLogger(GWES_HierarchicalTest.class);
41  
42      /**
43       * Create the test case.
44       *
45       * @param testName name of the test case
46       */
47      public GWES_HierarchicalTest(String testName) throws LoggingException {
48          super(testName);
49      }
50  
51      /**
52       * @return the suite of tests being tested
53       */
54      public static Test suite() {
55          return new TestSuite(GWES_HierarchicalTest.class);
56      }
57  
58  
59      /**
60       * ///ToDo: test correct enconding of return value (xsd:ArrayOf_soapenc_string)
61       * ///ToDo: test and solve problem with element names as child of tokens with name "workflow" etc.
62       */
63      public void testHierarchicalWorkflow() throws InterruptedException, IOException, WorkflowFormatException, NoSuchWorkflowException, DatabaseException, StateTransitionException, JaxenException, JDOMException, WorkflowSecurityException, LoggingException, GWESException {
64              String gworkflowdl = testGWES("examples/linuxtoolbox/gworkflowdl_hierarchical.xml", WorkflowStatus.STATUS_COMPLETED);
65  
66              // check occurrence sequence
67              String sequence = extractOccurrenceSequence(gworkflowdl);
68              Assert.assertEquals("Occurrence sequence", "workflowInititate workflowStart wait workflowGetData", sequence);
69  
70              // check tokens
71              List tokens = extractTokenChildElements(gworkflowdl);
72              Assert.assertEquals(1, tokens.size());
73  
74              List array = ((Element) tokens.get(0)).getChild("getDataReturn").getChildren();
75  
76              String returnS = ((Element) array.get(0)).getText(); 
77              Assert.assertTrue(returnS.matches("(?s).*:long.*1.*"));
78  
79              String[] data = gwes.getData(workflowID, "end", userID);
80              logger.info("end:\n"+data[0].trim());
81      }
82  
83  }