01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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: /**
32: * Unit tests {@link org.apache.commons.scxml.model.Assign}.
33: * Unit tests {@link org.apache.commons.scxml.model.Cancel}.
34: * Unit tests {@link org.apache.commons.scxml.model.Else}.
35: * Unit tests {@link org.apache.commons.scxml.model.Elseif}.
36: * Unit tests {@link org.apache.commons.scxml.model.Exit}.
37: * Unit tests {@link org.apache.commons.scxml.model.If}.
38: * Unit tests {@link org.apache.commons.scxml.model.Log}.
39: * Unit tests {@link org.apache.commons.scxml.model.Send}.
40: * Unit tests {@link org.apache.commons.scxml.model.Var}.
41: */
42: public class ActionsTest extends TestCase {
43: /**
44: * Construct a new instance of ActionsTest with
45: * the specified name
46: */
47: public ActionsTest(String name) {
48: super (name);
49: }
50:
51: public static Test suite() {
52: TestSuite suite = new TestSuite(ActionsTest.class);
53: suite.setName("SCXML Model Actions Tests");
54: return suite;
55: }
56:
57: // Test data
58: private URL actionsSample;
59: private ELEvaluator evaluator;
60: private ELContext ctx;
61: private SCXMLExecutor exec;
62:
63: /**
64: * Set up instance variables required by this test case.
65: */
66: public void setUp() {
67: actionsSample = this .getClass().getClassLoader().getResource(
68: "org/apache/commons/scxml/model/actions-test.xml");
69: evaluator = new ELEvaluator();
70: ctx = new ELContext();
71: }
72:
73: /**
74: * Tear down instance variables required by this test case.
75: */
76: public void tearDown() {
77: actionsSample = null;
78: evaluator = null;
79: ctx = null;
80: exec = null;
81: }
82:
83: /**
84: * Test the implementation
85: */
86: public void testModelActions() {
87: exec = SCXMLTestHelper.getExecutor(actionsSample, ctx,
88: evaluator);
89: ELContext ctx = (ELContext) SCXMLTestHelper.lookupContext(exec,
90: "actionsTest");
91: assertEquals((String) ctx.get("foo"), "foobar");
92: }
93:
94: public static void main(String args[]) {
95: TestRunner.run(suite());
96: }
97: }
|