    1   /*
    2    * Copyright 2006 The Apache Software Foundation.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    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  }