com.rational.test.ft.services

Class LogAdapter

  • All Implemented Interfaces:
    ILog, ISimpleLog
    Direct Known Subclasses:
    LogExtensionAdapter


    public class LogAdapter
    extends SimpleLogAdapter
    implements ILog
    The base implementation of the log methods for script playback. NOTE - DO NOT extend this without looking carefully at the result propagation logic - if write gets called and we don't see it, the event will not affect the script!
    • Constructor Detail

      • LogAdapter

        public LogAdapter(java.lang.String logName)
      • LogAdapter

        public LogAdapter()
        Constructor
    • Method Detail

      • setTopResult

        protected void setTopResult(int result)
        set the top result on the results stack. Note that this can make the result worse, but never better. If we set the result failure, we push the result through to ALL results on the result stack.
      • getCurrentScriptResult

        public boolean getCurrentScriptResult()
        Description copied from interface: ILog
        Returns the result of the current script. It returns false if there is any failure and true if there are no failures. The result includes the result of the scripts that this script had called.
        Specified by:
        getCurrentScriptResult in interface ILog
        Returns:
        boolean
      • getLastScriptResult

        public boolean getLastScriptResult()
        Description copied from interface: ILog
        Returns the result of the last script that had ended. It returns false if there is any failure and true if there are no failures. The result includes the result of the scripts that the last script had called. It returns true if no script had ended.
        Specified by:
        getLastScriptResult in interface ILog
        Returns:
        boolean
      • getTestResult

        public boolean getTestResult()
        Description copied from interface: ILog
        Returns the result of the current test. It returns false if there is any failure and true if there are no failures. The result includes the result of all the scripts that are executed in the current run.
        Specified by:
        getTestResult in interface ILog
        Returns:
        boolean
      • getLogDirectory

        public java.lang.String getLogDirectory()
        Returns the directory the log is being written to. This is actually just used by the VP code to decide where to write expected/actual files. Note we may split the concept of "where the log is being written to" and "where VP files should be written" at some later time. The LogAdapter base class returns the datastore log folder for this, so if special handling needs to be done (eg for TM and TSS logs) you should override the method with a real answer. The VP logic does handle null though, and writes expected/actuals to the datastore directory in that case.
        Specified by:
        getLogDirectory in interface ILog
        Since:
        RFT1.0
      • getLogFilename

        public java.lang.String getLogFilename()
        Returns the name of the log filename including the file extension but no directory.
        Specified by:
        getLogFilename in interface ILog
        Since:
        RFT2.0
      • setLogDirectory

        public void setLogDirectory(java.lang.String logDirectory)
        Sets the directory the log is beging written to.
      • setExportLogDirectory

        public void setExportLogDirectory(java.lang.String exportLogDir)
        Sets the directory the export log is beging written to.
      • getExportLogDirectory

        public java.lang.String getExportLogDirectory()
      • setExportReportParam

        public void setExportReportParam(java.lang.String exportReportParam)
        Sets the parameter exportReport.
      • getExportReportParam

        public java.lang.String getExportReportParam()
      • ensureLogDirectory

        public java.lang.String ensureLogDirectory()
        Returns the directory the log is being written to. Ensures that the directory exists, and tries to empty it.
      • info

        public void info(java.lang.String note)
        Writes a simple text informational message into the log.
        Specified by:
        info in interface ILog
        Parameters:
        note - The note to write to the log.
        Since:
        RFT1.0
      • scriptStart

        public void scriptStart(java.lang.String name,
                                IScriptDefinition scriptDef)
        Write a script start message into the log.
        Specified by:
        scriptStart in interface ILog
        Parameters:
        name - The script name.
        language - The language used for the script ( i.e. java )
      • scriptEnd

        public void scriptEnd(java.lang.String name,
                              java.lang.String language)
        Write a script end message into the log.
        Specified by:
        scriptEnd in interface ILog
        Parameters:
        name - The script name.
        language - The language used for the script ( i.e. java )
      • callScript

        public void callScript(java.lang.String name,
                               java.lang.String language)
        Write a calling script message into the log.
        Specified by:
        callScript in interface ILog
        Parameters:
        name - The script being called.
        language - The language used for the script ( i.e. java )
      • applicationStart

        public void applicationStart(java.lang.String name,
                                     java.lang.String language)
        Write an application start message into the log.
        Specified by:
        applicationStart in interface ILog
        Parameters:
        name - The application's name.
        language - The language used for the script ( i.e. java )
      • applicationStart

        public void applicationStart(java.lang.String name,
                                     java.lang.String language,
                                     java.lang.String appType)
        Description copied from interface: ILog
        Writes an application-start message into the log.
        Specified by:
        applicationStart in interface ILog
        Parameters:
        name - The application's name
        language - The language used for the script ( i.e. java )
      • applicationStart

        public void applicationStart(java.lang.String name,
                                     java.lang.String language,
                                     java.lang.String appType,
                                     java.util.List<java.lang.String> appExtraParams)
        Specified by:
        applicationStart in interface ILog
      • applicationStart

        public void applicationStart(java.lang.String name,
                                     int status,
                                     java.lang.String description,
                                     java.lang.String language)
        Writes an application start message into the log.
        Specified by:
        applicationStart in interface ILog
        Parameters:
        name - The application's name
        status - Result of starting the application (@see ISimpleLog.LOG_FAILURE
        description - Additional text for the status (e.g. reason for failure)
        language - The language used for the script ( i.e. java )
        Since:
        RFT1.0
        See Also:
        ISimpleLog.LOG_WARNING, ISimpleLog.LOG_INFORMATION
      • createApplicationStartMessage

        public ILogMessage createApplicationStartMessage(java.lang.String name,
                                                         int status,
                                                         java.lang.String description,
                                                         java.lang.String language)
        Return a application start message. This interface allows the caller to add detailed information and then write the message.
        Specified by:
        createApplicationStartMessage in interface ILog
        Parameters:
        name - The application's name.
        status - Result of starting the application (@see ISimpleLog.LOG_FAILURE
        description - Additional text for the status (e.g. reason for failure)
        language - The language used for the script ( i.e. java )
        Returns:
        An application start message.
        See Also:
        ISimpleLog.LOG_WARNING, ISimpleLog.LOG_INFORMATION
      • createApplicationStartMessage

        public ILogMessage createApplicationStartMessage(java.lang.String symbolicName,
                                                         java.lang.String description,
                                                         java.lang.String language,
                                                         java.lang.String appType,
                                                         java.lang.String executable,
                                                         java.lang.String workingDirectory,
                                                         java.lang.String arguments,
                                                         java.lang.String JvmVersion,
                                                         java.lang.String profile,
                                                         java.lang.String clearCache,
                                                         java.lang.String clearHistory)
        Return a application start message. This interface allows the caller to add detailed information and then write the message.
        Specified by:
        createApplicationStartMessage in interface ILog
        Parameters:
        name - The application's name.
        status - Result of starting the application (@see ISimpleLog.LOG_FAILURE
        description - Additional text for the status (e.g. reason for failure)
        language - The language used for the script ( i.e. java )
        Returns:
        An application start message.
        See Also:
        ISimpleLog.LOG_WARNING, ISimpleLog.LOG_INFORMATION
      • timerStart

        public void timerStart(java.lang.String name,
                               java.lang.String language)
        Write a start timer message into the log.
        Specified by:
        timerStart in interface ILog
        Parameters:
        name - The timer name.
        language - The language used for the script ( i.e. java )
      • getTimerValue

        public double getTimerValue(java.lang.String name)
        gets the timer value for the given timer
        Specified by:
        getTimerValue in interface ILog
        Parameters:
        name - The timer name.
        Returns:
        timerValue The timer value.
      • getTimerAndEnd

        public double getTimerAndEnd(java.lang.String name,
                                     java.lang.String language)
        gets the timer value for the given timer
        Specified by:
        getTimerAndEnd in interface ILog
        Parameters:
        name - The timer name.
        language - The language used for the script ( i.e. java )
        Returns:
        timerValue The timer value.
      • createTimerStartMessage

        public ILogMessage createTimerStartMessage(java.lang.String name,
                                                   java.lang.String language)
        Return a start timer message. This interface allows the caller to add detailed information and then write the message.
        Specified by:
        createTimerStartMessage in interface ILog
        Parameters:
        name - The timer name.
        language - The language used for the script ( i.e. java )
        Returns:
        A timer start message. This message has the result, event, and note initialized.
      • timerEnd

        public void timerEnd(java.lang.String name,
                             java.lang.String language)
        Write an end timer message into the log.
        Specified by:
        timerEnd in interface ILog
        Parameters:
        name - The timer name.
        language - The language used for the script ( i.e. java )
      • timerEnd

        public void timerEnd(java.lang.String name,
                             java.lang.String language,
                             long timerEnd)
        Writes an end-timer message into the log.
        Specified by:
        timerEnd in interface ILog
        Parameters:
        name - The timer name
        language - The language used for the script ( i.e. java )
        timerEnd - The time to end the timer
        Since:
        RFT8.2.1ifix1
      • createTimerEndMessage

        public ILogMessage createTimerEndMessage(java.lang.String name,
                                                 java.lang.String language)
        Return an end timer message. This interface allows the caller to add detailed information and then write the message.
        Specified by:
        createTimerEndMessage in interface ILog
        Parameters:
        name - The timer name.
        language - The language used for the script ( i.e. java )
        Returns:
        A timer end message. This message has the result, event, and note initialized.
      • createTimerEndMessage

        protected ILogMessage createTimerEndMessage(java.lang.String name,
                                                    java.lang.String language,
                                                    double delta)
        Return an end timer message. This interface allows the caller to add detailed information and then write the message.
        Parameters:
        name - The timer name.
        language - The language used for the script ( i.e. java )
        Returns:
        A timer end message. This message has the result, event, and note initialized.
      • createVPMessage

        public ILogMessage createVPMessage(int resultCode,
                                           java.lang.String type,
                                           java.lang.String name,
                                           java.lang.String language)
        Return a verification point message. This method allows the caller to add detailed information and then write the message.
        Specified by:
        createVPMessage in interface ILog
        Parameters:
        resultCode - One of the ILog.LOG_ codes.
        type - One of the VP_TYPE_ codes.
        name - The verification point name.
        language - The language used for the script ( i.e. java )
        Returns:
        A verification point message. This message has the result, event, and note initialized.
      • configuration

        public void configuration(java.lang.String language)
        Write the system configuration into the log. This method reads the configuration from the "system" utility and logs it.
        Specified by:
        configuration in interface ILog
        Parameters:
        language - The language used for the script ( i.e. java )
      • createConfigurationMessage

        public ILogMessage createConfigurationMessage(java.lang.String language)
        Create a system configuration message. This method allows the caller to add detailed information and then write the message.
        Specified by:
        createConfigurationMessage in interface ILog
        Parameters:
        language - The language used for the script ( i.e. java )
        Returns:
        A configuration message. This message has the result, event, and note initialized.
      • createGUIActionMessage

        public ILogMessage createGUIActionMessage(int resultCode,
                                                  java.lang.String method,
                                                  java.lang.String methodSignature,
                                                  java.lang.Object[] args,
                                                  java.lang.String testObjectRole,
                                                  java.lang.String testObjectName)
        Creates a GUI Action message. This method allows the caller to add detailed information and then write the message.
        Specified by:
        createGUIActionMessage in interface ILog
        Parameters:
        resultCode - The Result code PASS/FAILURE/WARNING/INFOMATION
        method - The method that is getting called in the AUT
        methodSignature - The signature of the method
        args - The arguments passed to the method
        testObjectRole - The role of the test object
        testObjectName - The test object name
        Returns:
      • createAssignActionMessage

        public ILogMessage createAssignActionMessage(int resultCode,
                                                     java.lang.String method,
                                                     java.lang.String methodSignature,
                                                     java.lang.Object[] args,
                                                     java.lang.String testObjectRole,
                                                     java.lang.String testObjectName,
                                                     java.lang.Object returnValue,
                                                     java.lang.String propName)
        Creates a GUI Action message. This method allows the caller to add detailed information and then write the message.
        Specified by:
        createAssignActionMessage in interface ILog
        Parameters:
        resultCode - The Result code PASS/FAILURE/WARNING/INFOMATION
        method - The method that is getting called in the AUT
        methodSignature - The signature of the method
        args - The arguments passed to the method
        testObjectRole - The role of the test object
        testObjectName - The test object name
        returnValue - Returned value of the method
        propName - Property name
        Returns:
      • createGUIActionMessage

        public ILogMessage createGUIActionMessage(int resultCode,
                                                  java.lang.String method,
                                                  java.lang.String methodSignature,
                                                  java.lang.Object[] args,
                                                  java.lang.String testObjectRole,
                                                  java.lang.String testObjectName,
                                                  java.awt.image.BufferedImage screenSnapshot)
        Creates a GUI Action message. This method allows the caller to add detailed information and then write the message.
        Specified by:
        createGUIActionMessage in interface ILog
        Parameters:
        resultCode - The Result code PASS/FAILURE/WARNING/INFOMATION
        method - The method that is getting called in the AUT
        methodSignature - The signature of the method
        args - The arguments passed to the method
        testObjectRole - The role of the test object
        testObjectName - The test object name
        screenSnapshot - The screen snapshot.
        Returns:
      • writeGUIAction

        public void writeGUIAction(ILogMessage message)
        Writes an Gui Action message in the log
        Specified by:
        writeGUIAction in interface ILog
        Parameters:
        message - The Gui Action Message
      • exception

        public void exception(java.lang.String note,
                              java.lang.String context,
                              java.lang.String throwableName,
                              java.lang.String throwableMessage,
                              java.lang.String scriptName,
                              int line,
                              java.lang.String stackTrace,
                              java.lang.String language)
        Write an exception message. Include the classname, the detail message and the stack as three separate properties.
        Specified by:
        exception in interface ILog
      • exception

        public void exception(java.lang.String note,
                              java.lang.String context,
                              java.lang.String throwableName,
                              java.lang.String throwableMessage,
                              java.lang.String scriptName,
                              int line,
                              java.lang.String stackTrace,
                              java.lang.String language,
                              java.awt.image.BufferedImage screenSnapshot)
        Write an exception message. Include the classname, the detail message and the stack as three separate properties. Also include a screen snapshot taken at the time of the exception.
        Specified by:
        exception in interface ILog
      • createTestResultMessage

        public ILogMessage createTestResultMessage(java.lang.String headline,
                                                   boolean passed,
                                                   java.lang.String additionalInfo)
        Creates a test result message.
        Specified by:
        createTestResultMessage in interface ILog
        Parameters:
        headline - The headline describing the test
        passed - A boolean indicating if the test passed or failed.
        additionalInfo - Additional information about the test
        Since:
        RFT1.0
      • viewerKnowsHowToBringUpComparator

        public boolean viewerKnowsHowToBringUpComparator()
        This answers yes/no whether the log-viewer associated with this log knows how to bring up our comparator. The answer is true for TSS log, and false otherwise. This is used to decide whether to do our own bring-up-comparator after playback.
        Specified by:
        viewerKnowsHowToBringUpComparator in interface ILog
      • getNextUserSnapshotNumber

        protected int getNextUserSnapshotNumber()
        As the user logs snapshots we need to generate unique names for them. This increases a count used to identify the snapshot file.
      • getNextUserSnapshotName

        protected java.lang.String getNextUserSnapshotName()
        As the user logs snapshots we need to generate unique names for them. This increases a count used to identify the snapshot file and returns the unique name.
      • setLogName

        public void setLogName(java.lang.String log_Name)
      • getLogName

        public java.lang.String getLogName()
      • getScreenShotFile

        protected java.lang.String getScreenShotFile(java.lang.String scriptName)
        As multiple exceptions are caught, unique numbers are needed for the exceptions screensnapshots The method is called by the logs (HTML etc) to obtain the unique name for the exception snapshots.
      • setLogGUIAction

        public void setLogGUIAction(boolean logGuiAction)
        Sets the option to log the GUI Action during playback
        Specified by:
        setLogGUIAction in interface ILog
        Parameters:
        logGuiAction - true if the Gui Action is to be logged
      • isLogGuiActionEnabled

        public boolean isLogGuiActionEnabled(java.lang.String methodName)
        Returns true if Gui Actions are to be logged.
        Specified by:
        isLogGuiActionEnabled in interface ILog
        Returns:
        true if GUI Actions are to be logged.
      • setLogScreenSnapshotAction

        public void setLogScreenSnapshotAction(boolean logSanpShot)
        Sets the option to log the Screen Snapshot for GUI Action during playback
        Specified by:
        setLogScreenSnapshotAction in interface ILog
        Parameters:
        logSanpShot - true if the Screen Snapshot for Gui Action is to be logged
      • isLogScreenSnapshotActionEnabled

        public boolean isLogScreenSnapshotActionEnabled()
        Returns true if Screen Snapshot for Gui Actions are to be logged.
        Specified by:
        isLogScreenSnapshotActionEnabled in interface ILog
        Returns:
        true if Screen Snapshot for GUI Actions are to be logged.
      • setCurrentLogFilter

        public void setCurrentLogFilter(int filterLevel)
        Set the log filter for the playback. If invalid values are given, then the default setting is used
        Specified by:
        setCurrentLogFilter in interface ILog
        Parameters:
        filterLevel - -1 - Disable logging 0 - Log only Failures 1 - Log Failures & Warnings 2 - Log Failures, Warnings & Pass 3 - Log Failures, Warnings, Pass & Information (Default)
      • getCurrentLogFilter

        public final int getCurrentLogFilter()
        Return the current log filter level.
        Specified by:
        getCurrentLogFilter in interface ILog
        Returns:
        The filter level -1 - Disable logging 0 - Log only Failures 1 - Log Failures & Warnings 2 - Log Failures, Warnings & Pass 3 - Log Failures, Warnings, Pass & Information (Default)
      • isLoggingEnabled

        protected boolean isLoggingEnabled(int resultCode,
                                           int eventCode)
        Return true if the resultCode is within the current log filters.
        Parameters:
        resultCode - The resultCode (PASS/WARNING/INFORMATION/FAILURE)
        eventCode - The events to check (APPLICATION_START,SCRIPT_START etc..)
        Returns:
        true if event code is either of SCRIPT_START or SCRIPT_END, or the result is within the current log filter level
      • getCurrentDatapool

        protected DatapoolStore getCurrentDatapool()
      • logRootException

        public final void logRootException(java.lang.String scriptName,
                                           java.lang.String language,
                                           java.lang.String msg,
                                           java.lang.Throwable e,
                                           java.lang.String headline)
        The API can be used if failures occur prior to start of execution of script.
        Specified by:
        logRootException in interface ILog
        Parameters:
        scriptName - The script name
        language - The language used
        msg - The localized message
        e - The Throwable object
      • shouldBringUpLog

        public final boolean shouldBringUpLog()
        Returns true if the log viewer is to be opened at the end of the command line playback.
        Returns:
        true if the log is to be opened, false otherwise
        Since:
        RFT 8.0
        See Also:
        openLogViewer
      • getSimplifiedScriptElement

        public static com.ibm.rational.test.ft.visualscript.TestElement getSimplifiedScriptElement(int ssLine)
      • getSSGroupForLine

        protected static java.lang.String getSSGroupForLine(int ssLine)
      • setLogType

        public void setLogType(java.lang.String logType)
        Set the log type for the Log
        Parameters:
        logType - The log type
      • getLogType

        public final java.lang.String getLogType()
        Return the type for the log
        Specified by:
        getLogType in interface ILog
        Returns:
      • setScriptPlaybackParams

        public void setScriptPlaybackParams(IScriptPlaybackParams scriptPlaybackParams)
        Set the ScriptPlaybackParams
        Parameters:
        scriptPlaybackParams -
      • getScriptPlaybackParams

        public IScriptPlaybackParams getScriptPlaybackParams()
        Get the ScriptPlaybackParams
        Returns:
      • createMessage

        public final ILogMessage createMessage(int resultCode,
                                               int eventCode,
                                               java.lang.String headline)
        Create an instance of a log message specifying the status, event and note. The ILogMessage allows more detailed information to be written to the log file (i.e. name/value pairs)
        Specified by:
        createMessage in interface ISimpleLog
        Overrides:
        createMessage in class SimpleLogAdapter
        Parameters:
        resultCode - One of the LOG_ codes.
        eventCode - One of the EVENT_ codes.
        headline - Simple (one line) description of the message being specified.
      • appendLogProperties

        public final void appendLogProperties(ILogMessage logMessage)
        Custom Log Participants can append log properties to the events they are interested at.
        Parameters:
        logMessage - The LogMessage
      • createLogParticipantMessage

        public final ILogMessage createLogParticipantMessage()
        Create an instance of a log message for custom log participants. The ILogMessage allows more detailed information to be written to the log file (i.e. name/value pairs).
      • processPreGuiAction

        public final void processPreGuiAction(ClientTestObject clientTestObject,
                                              ILogMessage logMessage)
        Custom log Participants can cache properties before any Gui Action takes place on the AUT
        Specified by:
        processPreGuiAction in interface ILog
        Parameters:
        clientTestObject -
        logMessage -
      • processPostGuiAction

        public final void processPostGuiAction(ILogMessage logMessage)
        Custom log Participants can add more properties after any Gui Action takes place on the AUT
        Specified by:
        processPostGuiAction in interface ILog
        Parameters:
        logMessage -
      • getSummaryEvent

        public final ILogMessage getSummaryEvent(java.lang.String key)
        Return the events that are very specific and unique to the execution.
        Parameters:
        key - The Key. Refer ILog documentation
        Returns:
        The ILogMessage for the execution
      • getScriptName

        public final java.lang.String getScriptName()
        Return the script name that has initiated the playback of the script
        Returns:
        The scriptname