Class TestExceptionHandler

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, ExceptionHandler, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    @Deprecated
    public class TestExceptionHandler
    extends TypedAtomicActor
    implements ExceptionHandler
    Deprecated.
    This actor tests for exceptions that are expected to occur when running a test model. When an exception is thrown by the model, this actor is invoked. It has two working modes, training mode and non-training mode. If in training mode, this actor handles an exception by recording the exception message. If not in training mode, this actor first compares the previously stored (assumed correct) message to the exception message and then throws an exception if the two messages are not the same. Also, if a test runs to completion without throwing an exception, this actor throws an exception in its wrapup() method. An exception is expected.
    Since:
    Ptolemy II 5.2
    Version:
    $Id$
    Author:
    Haiyang Zheng
    Pt.AcceptedRating:
    Yellow (hyzheng)
    Pt.ProposedRating:
    Yellow (hyzheng)
    • Field Detail

      • trainingMode

        public SharedParameter trainingMode
        Deprecated.
        If true, then collect the exception message and set the correctExceptionMessage parameter with the content of the exception. This parameter is a boolean, and it defaults to false. It is a shared parameter, meaning that changing it for any one instance in a model will change it for all instances in the model.
      • correctExceptionMessage

        public StringParameter correctExceptionMessage
        Deprecated.
        The correct exception message to be compared against.
      • TRAINING_MODE_ERROR_MESSAGE

        public static final java.lang.String TRAINING_MODE_ERROR_MESSAGE
        Deprecated.
        Exception message that is used if we are running under the nightly build and the trainingMode parameter is true.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TestExceptionHandler

        public TestExceptionHandler​(CompositeEntity container,
                                    java.lang.String name)
                             throws NameDuplicationException,
                                    IllegalActionException
        Deprecated.
        Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
        Parameters:
        container - The container.
        name - The name of this actor within the container.
        Throws:
        IllegalActionException - If this actor cannot be contained by the proposed container (see the setContainer() method).
        NameDuplicationException - If the name coincides with an entity already in the container.
    • Method Detail

      • handleException

        public boolean handleException​(NamedObj context,
                                       java.lang.Throwable exception)
                                throws IllegalActionException
        Deprecated.
        Handle an exception thrown in a test. If in training mode, simply record the exception message. If not in training mode, first compare the stored good message against the exception message. If they are the same, do nothing. Otherwise, throw the exception again.
        Specified by:
        handleException in interface ExceptionHandler
        Parameters:
        context - The object in which the error occurred.
        exception - The exception to be handled.
        Returns:
        True if the exception message is the same as the saved message.
        Throws:
        IllegalActionException - If cannot get a valid token from the trainingMode parameter or the exception message is not the same as the stored message.