Package nz.ac.waikato.modeljunit

Examples of nz.ac.waikato.modeljunit.FsmException


    }

    for (Field field : fsm.getFields()) {
      if (field.isAnnotationPresent(Time.class)) {
        if (time_ != null) {
          throw new FsmException("multiple @Time fields in model: " + fsm.getName());
        }
        if (field.getType() == int.class) {
          time_ = field;
        }
        else {
          throw new FsmException("@Time field " + field.getName()
              + " must be of type int.");
        }
      }
      else if (field.isAnnotationPresent(Timeout.class)) {
        if (verifyTimeout(field, fsm)) {
          timeouts_.add(field);
        }
      }
    }
    if (time_ == null) {
      throw new FsmException("No @Time field in TimedFsmModel " + fsm.getName());
    }
  }
View Full Code Here


   */
  private boolean verifyTimeout(Field field, Class<?> fsm)
  {
    // Timeouts must be integers
    if (field.getType() != int.class) {
      throw new FsmException("Timeout field " + field.getName()
          + "-Timeouts must be of type int");
      //return false;
    }

    // Action name must correspond to an action method
    // TODO: relax this to allow it to be a non-action void method?
    //       Or allow the @Action to have a 'timeout-only' flag?
    String actionName = field.getAnnotation(Timeout.class).value();
    for (Method method : fsm.getMethods()) {
      if (method.isAnnotationPresent(Action.class)) {
        if (method.getName().equals(actionName)) {
          return true;
        }
      }
    }

    // no corresponding action
    throw new FsmException("Timeout: " + field.getName()
        + "-No corresponding action was found");
    //return false;
  }
View Full Code Here

          + m.getName()
          + " - state changed from "
          + fsmState_ + " to " + fsmModel_.getState()
          + " when only time changed.  "
          + "Use Timeouts to control time dependant states.";
      throw new FsmException(failmsg);
    }

    Transition done = new TimedTransition(startTime, fsmState_, m.getName(),
        newState);
    fsmSequence_.add(done);
View Full Code Here

    }
    try {
      time_.setInt(getModel(), value);
    }
    catch (Exception ex) {
      throw new FsmException("error setting @Time field in model "
          + getModel().getClass().getName() + " - make sure it is public",
          ex);
    }
  }
View Full Code Here

          }
        }
      }
    }
    catch (IllegalAccessException ex) {
      throw new FsmException("@Timeout fields must be public");
    }
    return lowest;
  }
View Full Code Here

    Field field = timeouts_.get(timeoutIndex);
    try {
      return field.getInt(getModel());
    }
    catch (IllegalArgumentException e) {
      throw new FsmException("bad @Timeout field: " + field.getName(), e);
    }
    catch (IllegalAccessException e) {
      throw new FsmException("cannot read @Timeout field: " + field.getName(), e);
    }
  }
View Full Code Here

    Field field = timeouts_.get(timeoutIndex);
    try {
      field.setInt(getModel(), value);
    }
    catch (IllegalArgumentException e) {
      throw new FsmException("bad @Timeout field: " + field.getName(), e);
    }
    catch (IllegalAccessException e) {
      throw new FsmException("cannot write to @Timeout field: " + field.getName(), e);
    }
  }
View Full Code Here

TOP

Related Classes of nz.ac.waikato.modeljunit.FsmException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.