View Javadoc

1   /*
2    * $Id: GWES_DecisionTest.java 1529 2011-06-22 16:37:19Z 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.Element;
19  import org.jdom.JDOMException;
20  
21  import java.io.IOException;
22  import java.util.List;
23  
24  /**
25   * <code>
26   * maven -Dtestcase=net.kwfgrid.gwes.GWES_DecisionTest test:single
27   * </code>
28   *
29   * @author Andreas Hoheisel
30   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
31   * @version $Id: GWES_DecisionTest.java 1529 2011-06-22 16:37:19Z hoheisel $
32   */
33  public final class GWES_DecisionTest extends LocalGWESAbstractTestCase {
34  
35      /**
36       * log4j logger
37       */
38      static Logger logger = Logger.getLogger(GWES_DecisionTest.class);
39  
40      /**
41       * Create the test case.
42       *
43       * @param testName name of the test case
44       */
45      public GWES_DecisionTest(String testName) throws LoggingException {
46          super(testName);
47      }
48  
49      /**
50       * @return the suite of tests being tested
51       */
52      public static Test suite() {
53          return new TestSuite(GWES_DecisionTest.class);
54      }
55  
56      public void testUnresolvedDecisions() throws DatabaseException, JaxenException, IOException, JDOMException, StateTransitionException, WorkflowFormatException, WorkflowSecurityException, InterruptedException, NoSuchWorkflowException, LoggingException, GWESException {
57          String gworkflowdl = testGWES("examples/controlflow/gworkflowdl_decision.xml", WorkflowStatus.STATUS_SUSPENDED);
58          String sequence = extractOccurrenceSequence(gworkflowdl);
59          Assert.assertEquals("Occurrence sequence", "",sequence);
60          List elements = xpath("/gwdl:workflow/gwdl:transition/gwdl:property[@name='decision.1150795880']", gworkflowdl);
61          Assert.assertEquals(2, elements.size());
62  
63          for (int i = 0; i < elements.size(); i++) {
64              Element element = (Element) elements.get(i);
65              Assert.assertEquals("TAKE_CONFLICT", element.getText());
66          }
67      }
68  
69      public void testDecisionSolvedByPriority() throws DatabaseException, JaxenException, IOException, JDOMException, StateTransitionException, WorkflowFormatException, WorkflowSecurityException, InterruptedException, NoSuchWorkflowException, LoggingException, GWESException {
70          String gworkflowdl = testGWES("examples/controlflow/gworkflowdl_decision_with_priority.xml", WorkflowStatus.STATUS_COMPLETED);
71          /* evaluate results */
72          String sequence = extractOccurrenceSequence(gworkflowdl);
73          Assert.assertEquals("Occurrence sequence", "t2 tend",sequence);
74          List elements = xpath("/gwdl:workflow/gwdl:transition/gwdl:property[@name='decision.1150795880']", gworkflowdl);
75          Assert.assertEquals(0, elements.size());
76      }
77  
78  
79  }