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