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