1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml.model;
18
19 import java.net.URL;
20
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24 import junit.textui.TestRunner;
25
26 import org.apache.commons.scxml.SCXMLExecutor;
27 import org.apache.commons.scxml.SCXMLTestHelper;
28 import org.apache.commons.scxml.env.jsp.ELContext;
29 import org.apache.commons.scxml.env.jsp.ELEvaluator;
30 /***
31 * Unit tests {@link org.apache.commons.scxml.model.Assign}.
32 * Unit tests {@link org.apache.commons.scxml.model.Cancel}.
33 * Unit tests {@link org.apache.commons.scxml.model.Else}.
34 * Unit tests {@link org.apache.commons.scxml.model.Elseif}.
35 * Unit tests {@link org.apache.commons.scxml.model.Exit}.
36 * Unit tests {@link org.apache.commons.scxml.model.If}.
37 * Unit tests {@link org.apache.commons.scxml.model.Log}.
38 * Unit tests {@link org.apache.commons.scxml.model.Send}.
39 * Unit tests {@link org.apache.commons.scxml.model.Var}.
40 */
41 public class ActionsTest extends TestCase {
42 /***
43 * Construct a new instance of ActionsTest with
44 * the specified name
45 */
46 public ActionsTest(String name) {
47 super(name);
48 }
49
50 public static Test suite() {
51 TestSuite suite = new TestSuite(ActionsTest.class);
52 suite.setName("SCXML Model Actions Tests");
53 return suite;
54 }
55
56
57 private URL actionsSample;
58 private ELEvaluator evaluator;
59 private ELContext ctx;
60 private SCXMLExecutor exec;
61
62 /***
63 * Set up instance variables required by this test case.
64 */
65 public void setUp() {
66 actionsSample = this.getClass().getClassLoader().
67 getResource("org/apache/commons/scxml/model/actions-test.xml");
68 evaluator = new ELEvaluator();
69 ctx = new ELContext();
70 }
71
72 /***
73 * Tear down instance variables required by this test case.
74 */
75 public void tearDown() {
76 actionsSample = null;
77 evaluator = null;
78 ctx = null;
79 exec = null;
80 }
81
82 /***
83 * Test the implementation
84 */
85 public void testModelActions() {
86 exec = SCXMLTestHelper.getExecutor(actionsSample, ctx, evaluator);
87 ELContext ctx = (ELContext) SCXMLTestHelper.lookupContext(exec,
88 "actionsTest");
89 assertEquals((String) ctx.get("foo"), "foobar");
90 }
91
92 public static void main(String args[]) {
93 TestRunner.run(suite());
94 }
95 }
96