001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.scxml2.env;
018
019import org.junit.After;
020import org.junit.Assert;
021import org.junit.Before;
022import org.junit.Test;
023
024public class StopWatchTest {
025
026    private StopWatch stopWatch;
027
028    /**
029     * Set up instance variables required by this test case.
030     */
031    @Before
032    public void setUp() throws Exception {
033        stopWatch = new StopWatch();
034    }
035
036    /**
037     * Tear down instance variables required by this test case.
038     */
039    @After
040    public void tearDown() {
041        stopWatch = null;
042    }
043
044    @Test
045    public void testStopWatch() {
046        Assert.assertEquals("reset", stopWatch.getCurrentState());
047        stopWatch.fireEvent(StopWatch.EVENT_START);
048        Assert.assertEquals("running", stopWatch.getCurrentState());
049        stopWatch.fireEvent(StopWatch.EVENT_SPLIT);
050        Assert.assertEquals("paused", stopWatch.getCurrentState());
051        stopWatch.fireEvent(StopWatch.EVENT_UNSPLIT);
052        Assert.assertEquals("running", stopWatch.getCurrentState());
053        stopWatch.fireEvent(StopWatch.EVENT_STOP);
054        Assert.assertEquals("stopped", stopWatch.getCurrentState());
055        stopWatch.fireEvent(StopWatch.EVENT_RESET);
056        Assert.assertEquals("reset", stopWatch.getCurrentState());
057    }
058
059}
060