1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml.env;
18
19
20 import junit.framework.Test;
21 import junit.framework.TestCase;
22 import junit.framework.TestSuite;
23
24 public class StopWatchTest extends TestCase {
25
26 public StopWatchTest(String testName) {
27 super(testName);
28 }
29
30 public static Test suite() {
31 return new TestSuite(StopWatchTest.class);
32 }
33
34 public static void main(String args[]) {
35 String[] testCaseName = { StopWatchTest.class.getName()};
36 junit.textui.TestRunner.main(testCaseName);
37 }
38
39 private StopWatch stopWatch;
40
41 /***
42 * Set up instance variables required by this test case.
43 */
44 public void setUp() {
45 stopWatch = new StopWatch();
46 }
47
48 /***
49 * Tear down instance variables required by this test case.
50 */
51 public void tearDown() {
52 stopWatch = null;
53 }
54
55 public void testStopWatch() {
56 assertEquals("reset", stopWatch.getCurrentState());
57 stopWatch.fireEvent(StopWatch.EVENT_START);
58 assertEquals("running", stopWatch.getCurrentState());
59 stopWatch.fireEvent(StopWatch.EVENT_SPLIT);
60 assertEquals("paused", stopWatch.getCurrentState());
61 stopWatch.fireEvent(StopWatch.EVENT_UNSPLIT);
62 assertEquals("running", stopWatch.getCurrentState());
63 stopWatch.fireEvent(StopWatch.EVENT_STOP);
64 assertEquals("stopped", stopWatch.getCurrentState());
65 stopWatch.fireEvent(StopWatch.EVENT_RESET);
66 assertEquals("reset", stopWatch.getCurrentState());
67 }
68
69 }
70