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 import java.util.Set;
21
22 import junit.framework.Test;
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25 import junit.textui.TestRunner;
26
27 import org.apache.commons.scxml.SCXMLExecutor;
28 import org.apache.commons.scxml.SCXMLTestHelper;
29 /***
30 * Unit tests for <assign> element, particular the "src" attribute.
31 */
32 public class AssignTest extends TestCase {
33 /***
34 * Construct a new instance of AssignTest with
35 * the specified name
36 */
37 public AssignTest(String name) {
38 super(name);
39 }
40
41 public static Test suite() {
42 TestSuite suite = new TestSuite(AssignTest.class);
43 suite.setName("SCXML Model Assign Tests");
44 return suite;
45 }
46
47
48 private SCXMLExecutor exec;
49
50 /***
51 * Set up instance variables required by this test case.
52 */
53 public void setUp() {
54 URL assignSample = this.getClass().getClassLoader().
55 getResource("org/apache/commons/scxml/model/assign-test.xml");
56 exec = SCXMLTestHelper.getExecutor(assignSample);
57 }
58
59 /***
60 * Tear down instance variables required by this test case.
61 */
62 public void tearDown() {
63 exec = null;
64 }
65
66 /***
67 * Test the implementation
68 */
69 public void testAssignSrc() {
70 Set currentStates = exec.getCurrentStatus().getStates();
71 assertEquals(1, currentStates.size());
72 assertEquals("assign2", ((State)currentStates.iterator().
73 next()).getId());
74 assertTrue(exec.getCurrentStatus().isFinal());
75 }
76
77 public static void main(String args[]) {
78 TestRunner.run(suite());
79 }
80 }
81