1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml;
18
19 import junit.framework.Test;
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23 import org.apache.commons.scxml.model.State;
24
25 public class StatusTest extends TestCase {
26
27 public StatusTest(String name) {
28 super(name);
29 }
30
31 public static Test suite() {
32 TestSuite suite = new TestSuite(StatusTest.class);
33 suite.setName("TestStatus");
34 return suite;
35 }
36
37 public static void main(String args[]) {
38 String[] testCaseName = { StatusTest.class.getName()};
39 junit.textui.TestRunner.main(testCaseName);
40 }
41
42 private Status status;
43
44 public void setUp() {
45 status = new Status();
46 }
47
48 public void testIsFinalStateFalse() {
49 State state = new State();
50 state.setIsFinal(false);
51
52 status.getStates().add(state);
53
54 assertFalse(status.isFinal());
55 }
56
57 public void testIsFinalStateHasParent() {
58 State state = new State();
59 state.setIsFinal(true);
60 state.setParent(new State());
61
62 status.getStates().add(state);
63
64 assertFalse(status.isFinal());
65 }
66
67 public void testIsFinalStateHasEvent() {
68 State state = new State();
69 state.setIsFinal(true);
70
71 status.getStates().add(state);
72 status.getEvents().add(new TriggerEvent("name", TriggerEvent.CALL_EVENT));
73
74 assertFalse(status.isFinal());
75 }
76
77 public void testIsFinalState() {
78 State state = new State();
79 state.setIsFinal(true);
80
81 status.getStates().add(state);
82
83 assertTrue(status.isFinal());
84 }
85
86 }