1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml2.env;
18
19 import org.junit.After;
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.Test;
23
24 public class StopWatchTest {
25
26 private StopWatch stopWatch;
27
28
29
30
31 @Before
32 public void setUp() throws Exception {
33 stopWatch = new StopWatch();
34 }
35
36
37
38
39 @After
40 public void tearDown() {
41 stopWatch = null;
42 }
43
44 @Test
45 public void testStopWatch() {
46 Assert.assertEquals("reset", stopWatch.getCurrentState());
47 stopWatch.fireEvent(StopWatch.EVENT_START);
48 Assert.assertEquals("running", stopWatch.getCurrentState());
49 stopWatch.fireEvent(StopWatch.EVENT_SPLIT);
50 Assert.assertEquals("paused", stopWatch.getCurrentState());
51 stopWatch.fireEvent(StopWatch.EVENT_UNSPLIT);
52 Assert.assertEquals("running", stopWatch.getCurrentState());
53 stopWatch.fireEvent(StopWatch.EVENT_STOP);
54 Assert.assertEquals("stopped", stopWatch.getCurrentState());
55 stopWatch.fireEvent(StopWatch.EVENT_RESET);
56 Assert.assertEquals("reset", stopWatch.getCurrentState());
57 }
58
59 }
60