01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow;
06:
07: import com.opensymphony.workflow.basic.BasicWorkflow;
08:
09: import junit.framework.TestCase;
10:
11: import java.net.URL;
12:
13: import java.util.HashMap;
14: import java.util.Map;
15:
16: /**
17: * DOCUMENT ME!
18: */
19: public class DescriptorQuirksTestCase extends TestCase {
20: //~ Instance fields ////////////////////////////////////////////////////////
21:
22: public int counter = 0;
23: private AbstractWorkflow workflow;
24:
25: //~ Constructors ///////////////////////////////////////////////////////////
26:
27: public DescriptorQuirksTestCase(String s) {
28: super (s);
29: }
30:
31: //~ Methods ////////////////////////////////////////////////////////////////
32:
33: /**
34: * Test if comments in args are correctly ignored.
35: * @see <a href="http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-178">Jira issue WF-178</a>
36: * @throws Exception If error while executing testing
37: */
38: public void testArgComment() throws Exception {
39: counter = 0;
40:
41: Map inputs = new HashMap();
42: inputs.put("test", this );
43:
44: URL resource = getClass().getResource(
45: "/samples/comment-arg.xml");
46: long id = workflow.initialize(resource.toString(), 1, inputs);
47: assertEquals("beanshell script not parsed correctly", 2,
48: counter);
49: }
50:
51: /**
52: * Test if comments in args are correctly ignored.
53: * @see <a href="http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-178">Jira issue WF-178</a>
54: * @throws Exception If error while executing testing
55: */
56: public void testArgMultiText() throws Exception {
57: counter = 0;
58:
59: Map inputs = new HashMap();
60: inputs.put("test", this );
61:
62: URL resource = getClass().getResource(
63: "/samples/multitext-arg.xml");
64: long id = workflow.initialize(resource.toString(), 1, inputs);
65: assertEquals("beanshell script not parsed correctly", 2,
66: counter);
67: }
68:
69: /**
70: * Test if functions are executed once in an unconditional-result
71: * @see <a href="http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-118">Jira issue WF-118</a>
72: * @throws Exception If error while executing testing
73: */
74: public void testDoubleFunctionExecution() throws Exception {
75: counter = 0;
76:
77: long id = workflow.initialize(getClass().getResource(
78: "/samples/double.xml").toString(), 1, new HashMap());
79: Map inputs = new HashMap();
80: inputs.put("test", this );
81: workflow.doAction(id, 3, inputs);
82: assertEquals("function executed unexpected number of times", 2,
83: counter);
84: }
85:
86: public void testVariableMutability() throws Exception {
87: long id = workflow.initialize(getClass().getResource(
88: "/samples/variable-modify.xml").toString(), 100, null);
89: }
90:
91: protected void setUp() throws Exception {
92: workflow = new BasicWorkflow("testuser");
93: }
94: }
|