KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > DescriptorQuirksTestCase


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow;
6
7 import com.opensymphony.workflow.basic.BasicWorkflow;
8
9 import junit.framework.TestCase;
10
11 import java.net.URL JavaDoc;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16
17 /**
18  * DOCUMENT ME!
19  *
20  * @author $author$
21  * @version $Revision: 1.5 $
22  */

23 public class DescriptorQuirksTestCase extends TestCase {
24     //~ Instance fields ////////////////////////////////////////////////////////
25

26     public int counter = 0;
27     private AbstractWorkflow workflow;
28
29     //~ Constructors ///////////////////////////////////////////////////////////
30

31     public DescriptorQuirksTestCase(String JavaDoc s) {
32         super(s);
33     }
34
35     //~ Methods ////////////////////////////////////////////////////////////////
36

37     /**
38      * Test if comments in args are correctly ignored.
39      * @see <a HREF="http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-178">Jira issue WF-178</a>
40      * @throws Exception If error while executing testing
41      */

42     public void testArgComment() throws Exception JavaDoc {
43         counter = 0;
44
45         Map JavaDoc inputs = new HashMap JavaDoc();
46         inputs.put("test", this);
47
48         URL JavaDoc resource = getClass().getResource("/samples/comment-arg.xml");
49         long id = workflow.initialize(resource.toString(), 1, inputs);
50         assertEquals("beanshell script not parsed correctly", 2, counter);
51     }
52
53     /**
54      * Test if functions are executed once in an unconditional-result
55      * @see <a HREF="http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-118">Jira issue WF-118</a>
56      * @throws Exception If error while executing testing
57      */

58     public void testDoubleFunctionExecution() throws Exception JavaDoc {
59         counter = 0;
60
61         long id = workflow.initialize(getClass().getResource("/samples/double.xml").toString(), 1, new HashMap JavaDoc());
62         Map JavaDoc inputs = new HashMap JavaDoc();
63         inputs.put("test", this);
64         workflow.doAction(id, 3, inputs);
65         assertEquals("function executed unexpected number of times", 2, counter);
66     }
67
68     protected void setUp() throws Exception JavaDoc {
69         workflow = new BasicWorkflow("testuser");
70     }
71 }
72
Popular Tags