nz.ac.waikato.modeljunit
Interface ModelListener

All Known Subinterfaces:
CoverageMetric
All Known Implementing Classes:
AbstractCoverage, AbstractListener, ActionCoverage, CoverageHistory, GraphListener, StateCoverage, StopOnFailureListener, TransitionCoverage, TransitionPairCoverage, VerboseListener, VisualisationListener

public interface ModelListener

An interface for objects that listen for model events.


Method Summary
 void doneGuard(java.lang.Object state, int action, boolean enabled, int value)
          The Model calls this after each guard evaluation.
 void doneReset(java.lang.String reason, boolean testing)
          The Model calls this after each reset(boolean) action.
 void doneTransition(int action, Transition tr)
          The Model calls this after taking each transition.
 void failure(TestFailureException failure)
          The Model calls this when an action has found an error.
 Model getModel()
          Returns the model that this listener is listening to.
 java.lang.String getName()
          Get the short name that this listener is known by.
 void setModel(Model model)
          Tell the listener which model it is listening to.
 void startAction(java.lang.Object state, int action, java.lang.String name)
          This is called just before an action is about to be executed.
 

Method Detail

getName

java.lang.String getName()
Get the short name that this listener is known by. This name is used to add a listener to a model or a Tester object and to lookup a listener. The name should be a short descriptive noun phrase, all in lowercase, should usually be less than 30 characters, and may contain spaces.


getModel

Model getModel()
Returns the model that this listener is listening to. This may be null if this listener is not yet attached to a model. As another example, the coverage metric within a CoverageHistory object should always have getModel()==null, because it receives events from the CoverageHistory wrapper rather than the model.


setModel

void setModel(Model model)
Tell the listener which model it is listening to.


doneReset

void doneReset(java.lang.String reason,
               boolean testing)
The Model calls this after each reset(boolean) action.

Parameters:
reason - An adjective that describe why the reset was done.
testing - The parameter that was passed to the FsmModel reset call.

doneGuard

void doneGuard(java.lang.Object state,
               int action,
               boolean enabled,
               int value)
The Model calls this after each guard evaluation. Note that this will be called even after an implicit guard (which always returns true) has been evaluated. The enabled boolean says whether the guard of action is enabled or not, while value gives the actual value returned by the guard method (0 for false, 1 for true, or other positive integer values for Markov chain guards).


startAction

void startAction(java.lang.Object state,
                 int action,
                 java.lang.String name)
This is called just before an action is about to be executed. (The guard of that action is known to be true at this point).

Parameters:
state - The current state of the model.
action - The number of the action.
name - The name of the action.

doneTransition

void doneTransition(int action,
                    Transition tr)
The Model calls this after taking each transition.

Parameters:
action - The number of the action just taken.
tr - The transition just taken.

failure

void failure(TestFailureException failure)
The Model calls this when an action has found an error. The failure exception contains lots of information about the test failure. If a listener throws this exception, then the test generation process will stop with this exception. (after all listeners have been notified of the failure).



Copyright © 2009 ModelJUnit Project. All Rights Reserved.