IBM Rational Functional Tester
Version 8.1.1000
IBM Rational Functional Tester API Reference

Project Version 2.3

com.rational.test.ft.services
Class LogExtensionAdapter

java.lang.Object   extended by com.rational.test.ft.services.SimpleLogAdapter
      extended by com.rational.test.ft.services.LogAdapter
          extended by com.rational.test.ft.services.LogExtensionAdapter
All Implemented Interfaces:
ILog, ISimpleLog
Direct Known Subclasses:
ExecutionHistoryLog, HTMLLog, NullLog, TestScriptServicesLog, TextLog

public abstract class LogExtensionAdapter
extends LogAdapter

This is the base class for all Rational Functional Tester log extensions

Implementors should only write the following methods to get the desired log results they wish to design.
public void initLog()
public void closeLog()
public void writeLog(ILogMessage message)

Sample implementation of the subclass is shown below to get the sample text log output of a sample script
Sample Text Log
July 23, 2007 8:30:12 PM IST :Script Name Script1.java Result :INFO Event SCRIPT START headlind Script start [Script1]
Property Name =line_number Property Value =1
Property Name =script_name Property Value =Script1
Property Name =script_id Property Value =Script1.java

July 23, 2007 8:30:12 PM IST :Script Name Script1.java Result :PASS Event SCRIPT END headlind Script end [Script1]
Property Name =line_number Property Value =-1
Property Name =script_name Property Value =Script1
Property Name =script_id Property Value =Script1.java

Sample Implementation
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import com.rational.test.ft.services.ILogMessage;
import com.rational.test.ft.services.LogException;
import com.rational.test.ft.services.LogExtensionAdapter;
import com.rational.test.ft.services.LogMessageProperty;

public class ExampleLog extends LogExtensionAdapter {

private String logName=null;
private String logDirectory=null;
private PrintWriter out=null;

public ExampleLog(String logName) {
 super(logName);
 this.logName=logName;
 this.logDirectory=null;
}

public ExampleLog() {
 super();
 this.logName=null;
 this.logDirectory=null;
}

public void closeLog() {
 try{
   out.close();
 }catch(Exception e)
 
 
 }
}

public void initLog() throws LogException {
 try{
  this.logName=getLogName();
  this.logDirectory=getLogDirectory();
  File logFile=new File(logDirectory,logName+".txt");
  FileOutputStream fos=new FileOutputStream(logFile);
  out=new PrintWriter(fos);
 }catch(IOException e)
 {
 
 }
}

public void writeLog(ILogMessage message) {
 Vector properties=message.getProperties();
  String result=getResult(message);
  String event_type=getEventType(message);
  String headline=getHeadline(message);
  String timestamp=getTimestamp();
  String currentScriptName=getScriptName(message);
  out.println(timestamp + " :Script Name " + currentScriptName + " Result :" + result + " Event " + event_type + " headlind " + headline );
  for(int i=0,size=properties.size();i  {
  LogMessageProperty property =
   (LogMessageProperty) properties.elementAt( i );
  out.println("Property Name =" + property.getName().toString() + " Property Value =" +property.getValue().toString() );
  }
  out.println();
}

private String getResult(ILogMessage message) {
  String result=null;
  switch (message.getResult())
  {
   case LOG_FAILURE : result="FAILURE";break;
   case LOG_PASS : result="PASS";break;
   case LOG_WARNING : result="WARNING";break;
   default: result= "INFO";
 }
 return result;
}

private String getEventType(ILogMessage message) {
  String eventType=null;
  switch(message.getEvent())
  {
   case EVENT_SCRIPT_START : eventType="SCRIPT START";break;
   case EVENT_SCRIPT_END : eventType="SCRIPT END";break;
   case EVENT_VP : eventType="VERIFCATION POINT";break;
   case EVENT_CALL_SCRIPT : eventType = "CALL_SCRIPT"; break;
   case EVENT_APPLICATION_START : eventType="APPLICATION START";break;
   case EVENT_APPLICATION_END : eventType="APPLICATION END";break;
   case EVENT_TIMER_START : eventType="TIMER START";break;
   case EVENT_TIMER_END : eventType= "TIMER END" ;break;
   case EVENT_CONFIGURATION : eventType="CONFIGURATION"; break;
   default : eventType="GENERAL";
 }
 return eventType;
}

private String getHeadline(ILogMessage message) {
  return message.getHeadline();
}

private String getScriptName(ILogMessage message) {
  String scriptName=null;
  Vector properties=message.getProperties();
  for(int i=0,size=properties.size();i  {
   LogMessageProperty property =
   (LogMessageProperty) properties.elementAt( i );
   if(property.getName().equalsIgnoreCase(PROP_SCRIPT_ID))
   {
     scriptName=property.getValue().toString();
   }
  }
  return scriptName;
}
}


Nested Class Summary
protected  class LogExtensionAdapter.ImageMetadata
           
 
Field Summary
protected  float MAX_IMAGE_DIMENSION
           
 
Fields inherited from class com.rational.test.ft.services.LogAdapter
spaceDelimeter
 
Fields inherited from interface com.rational.test.ft.services.ILog
PROP_ACTUAL, PROP_ADDITIONAL_INFO, PROP_APPLICATION, PROP_BASELINE, PROP_BUFFERED_SNAPSHOT, PROP_DATAPOOL_STORE, PROP_ELAPSED_TIME, PROP_EXCEPTION_CONTEXT, PROP_EXCEPTION_MESSAGE, PROP_EXCEPTION_NAME, PROP_EXCEPTION_STACK, PROP_EXPECTED, PROP_FAILURE_DESCRIPTION, PROP_ITERATION_COUNT, PROP_LINENUMBER, PROP_NAME, PROP_SCREEN_SNAPSHOT, PROP_SCRIPT_ID, PROP_SCRIPT_NAME, PROP_SCRIPT_SOURCE_UID, PROP_SIMPLIFIEDSCRIPT_GRPNAME, PROP_SIMPLIFIEDSCRIPT_LINE, PROP_SIMPLIFIEDSCRIPT_LINENUMBER, PROP_TESTCASE_DESCRIPTION, PROP_TESTCASE_NAME, PROP_USER_SCREEN_SNAPSHOT, PROP_VP_TYPE, SCREEN_SNAPSHOT_FILE_BASE, SCREEN_SNAPSHOT_FILE_EXT, SCREEN_SNAPSHOT_FILE_NAME, USER_SCREEN_SNAPSHOT_FILE_BASE, VP_TYPE_ALPHA_NUM, VP_TYPE_CLIPBOARD, VP_TYPE_FILE_COMPARE, VP_TYPE_FILE_EXIST, VP_TYPE_FULL_IMAGE, VP_TYPE_MENU, VP_TYPE_MODULE_EXIST, VP_TYPE_OBJECT_DATA, VP_TYPE_OBJECT_PROP, VP_TYPE_OCR_IMAGE, VP_TYPE_REGION_IMAGE, VP_TYPE_WEBSITE_COMPARE, VP_TYPE_WEBSITE_SCAN, VP_TYPE_WINDOW_EXIST, VP_TYPE_WINDOW_IMAGE
 
Fields inherited from interface com.rational.test.ft.services.ISimpleLog
DISABLE_LOGGING, EVENT_APPLICATION_END, EVENT_APPLICATION_START, EVENT_APPLICATON_ACTION, EVENT_CALL_SCRIPT, EVENT_CONFIGURATION, EVENT_GENERAL, EVENT_SCRIPT_END, EVENT_SCRIPT_START, EVENT_TIMER_END, EVENT_TIMER_START, EVENT_VP, LOG_DISABLE_GUI_ACTION, LOG_ENABLE_GUI_ACTION, LOG_FAILURE, LOG_FAILURES, LOG_FAILURES_WARNINGS, LOG_FAILURES_WARNINGS_PASS, LOG_FAILURES_WARNINGS_PASS_INFO, LOG_INFORMATION, LOG_PASS, LOG_WARNING
 
Constructor Summary
LogExtensionAdapter()
           
LogExtensionAdapter(java.lang.String logName)
           
 
Method Summary
 void applicationStart(java.lang.String name, int status, java.lang.String description, java.lang.String language)
          Writes an application start message into the log.
 void applicationStart(java.lang.String name, java.lang.String language)
          Write an application start message into the log.
 void callScript(java.lang.String name, java.lang.String language)
          Write a call script message into the log
 void close()
          Closes the log, thereby releasing internal resources.
abstract  void closeLog()
          The abstract method that needs to be overridden by sub classes to close their custom logs
 void configuration(java.lang.String language)
          Write the system configuration into the log.
 ILogMessage createApplicationStartMessage(java.lang.String name, int status, java.lang.String description, java.lang.String language)
          Return a application start message.
 ILogMessage createConfigurationMessage(java.lang.String language)
          Create a system configuration message.
 ILogMessage createTestResultMessage(java.lang.String headline, boolean passed, java.lang.String additionalInfo)
          Creates a test result message.
 ILogMessage createTimerEndMessage(java.lang.String name, java.lang.String language)
          Return an end timer message.
 ILogMessage createTimerStartMessage(java.lang.String name, java.lang.String language)
          Return a start timer message.
 ILogMessage createVPMessage(int resultCode, java.lang.String type, java.lang.String name, java.lang.String language)
          Return a verification point message.
 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.
 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.
 java.lang.String getLogFilename()
          Returns the log file for the log.
 java.lang.String getScriptName()
          Return the script name that has initiated the playback of the script
static java.lang.String getTimestamp()
          Gets the current locale timestamp that can be logged
abstract  void initLog()
          The abstract method that needs to be overridden by the sub classes to initialize their custom logs
 void open()
          Opens the log and initializes internal resources.
protected  void persistImage(ILogMessage message)
          Persist the screen snap shot if present in the message
 void scriptEnd(java.lang.String name, java.lang.String language)
          Write a script end message into the log
 void scriptStart(java.lang.String name, java.lang.String language)
          Write a script start message into the log
 void setLogDirectory(java.lang.String logDirectory)
          Sets the directory the log is beging written to.
 void setLogName(java.lang.String log_Name)
          Sets the log name the log is beging written to.
 void timerEnd(java.lang.String name, java.lang.String language)
          Write an end timer message into the log.
 void timerStart(java.lang.String name, java.lang.String language)
          Write a start timer message into the log.
 void write(ILogMessage message)
          Perform internal tasks to write log messages.
 void write(int resultCode, int eventCode, java.lang.String note)
          Perform internal write tasks that should not called by extenders/implementors.
abstract  void writeLog(ILogMessage message)
          The abstract method that needs to be overridden by sub classes to handle the log events in the form of ILogMessage
 
Methods inherited from class com.rational.test.ft.services.LogAdapter
createGUIActionMessage, createMessage, createMessage, createTimerEndMessage, ensureLogDirectory, getCurrentDatapool, getCurrentLogFilter, getCurrentScriptResult, getLastScriptResult, getLogDirectory, getLogName, getLogType, getNextUserSnapshotName, getNextUserSnapshotNumber, getScreenShotFile, getScriptPlaybackParams, getTestResult, getTimerAndEnd, getTimerValue, info, isLoggingEnabled, isLogGuiActionEnabled, logRootException, setCurrentLogFilter, setLogGUIAction, setLogType, setScriptPlaybackParams, setTopResult, shouldBringUpLog, viewerKnowsHowToBringUpComparator, writeGUIAction
 
Methods inherited from class com.rational.test.ft.services.SimpleLogAdapter
openLogViewer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.rational.test.ft.services.ISimpleLog
openLogViewer
 

Field Detail

MAX_IMAGE_DIMENSION

protected final float MAX_IMAGE_DIMENSION
See Also:
Constant Field Values
Constructor Detail

LogExtensionAdapter

public LogExtensionAdapter(java.lang.String logName)

LogExtensionAdapter

public LogExtensionAdapter()
Method Detail

persistImage

protected void persistImage(ILogMessage message)
Persist the screen snap shot if present in the message

Parameters:
message - The message that is to be logged

write

public final void write(ILogMessage message)
Perform internal tasks to write log messages. This method should not called by extenders/implementors. Sub classes can override writeLog to write the log message.

Specified by:
write in interface ISimpleLog
Overrides:
write in class SimpleLogAdapter
Parameters:
message - The message that is to be logged
See Also:
ISimpleLog.LOG_FAILURE, ISimpleLog.LOG_PASS, ISimpleLog.LOG_WARNING, ISimpleLog.LOG_INFORMATION, ISimpleLog.EVENT_SCRIPT_START, ISimpleLog.EVENT_SCRIPT_END, ISimpleLog.EVENT_VP, ISimpleLog.EVENT_CALL_SCRIPT, ISimpleLog.EVENT_APPLICATION_START, ISimpleLog.EVENT_APPLICATION_END, ISimpleLog.EVENT_TIMER_START, ISimpleLog.EVENT_TIMER_END, ISimpleLog.EVENT_CONFIGURATION, ISimpleLog.EVENT_GENERAL

write

public final void write(int resultCode,                         int eventCode,                         java.lang.String note)
Perform internal write tasks that should not called by extenders/implementors. This method should not called by extenders/implementors. Subclasses can override writeLog to write the log message.

Specified by:
write in interface ISimpleLog
Overrides:
write in class SimpleLogAdapter
Parameters:
message - The message that is to be logged
See Also:
ISimpleLog.LOG_FAILURE, ISimpleLog.LOG_PASS, ISimpleLog.LOG_WARNING, ISimpleLog.LOG_INFORMATION, ISimpleLog.EVENT_SCRIPT_START, ISimpleLog.EVENT_SCRIPT_END, ISimpleLog.EVENT_VP, ISimpleLog.EVENT_CALL_SCRIPT, ISimpleLog.EVENT_APPLICATION_START, ISimpleLog.EVENT_APPLICATION_END, ISimpleLog.EVENT_TIMER_START, ISimpleLog.EVENT_TIMER_END, ISimpleLog.EVENT_CONFIGURATION, ISimpleLog.EVENT_GENERAL

setLogDirectory

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

Overrides:
setLogDirectory in class LogAdapter

setLogName

public final void setLogName(java.lang.String log_Name)
Sets the log name the log is beging written to.

Overrides:
setLogName in class LogAdapter

scriptStart

public final void scriptStart(java.lang.String name,                               java.lang.String language)
Write a script start message into the log

Specified by:
scriptStart in interface ILog
Overrides:
scriptStart in class LogAdapter
Parameters:
name - The script name.
language - The language used for the script ( i.e. java )

scriptEnd

public final void scriptEnd(java.lang.String name,                             java.lang.String language)
Write a script end message into the log

Specified by:
scriptEnd in interface ILog
Overrides:
scriptEnd in class LogAdapter
Parameters:
name - The script name.
language - The language used for the script ( i.e. java )

callScript

public final void callScript(java.lang.String name,                              java.lang.String language)
Write a call script message into the log

Specified by:
callScript in interface ILog
Overrides:
callScript in class LogAdapter
Parameters:
name - The script being called.
language - The language used for the script ( i.e. java )

applicationStart

public final void applicationStart(java.lang.String name,                                    java.lang.String language)
Write an application start message into the log.

Specified by:
applicationStart in interface ILog
Overrides:
applicationStart in class LogAdapter
Parameters:
name - The application's name.
language - The language used for the script ( i.e. java )

applicationStart

public final 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
Overrides:
applicationStart in class LogAdapter
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 )
See Also:
ISimpleLog.LOG_WARNING, ISimpleLog.LOG_INFORMATION

createApplicationStartMessage

public final 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
Overrides:
createApplicationStartMessage in class LogAdapter
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
Overrides:
timerStart in class LogAdapter
Parameters:
name - The timer name.
language - The language used for the script ( i.e. java )

createTimerStartMessage

public final 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
Overrides:
createTimerStartMessage in class LogAdapter
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
Overrides:
timerEnd in class LogAdapter
Parameters:
name - The timer name.
language - The language used for the script ( i.e. java )

createTimerEndMessage

public final 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
Overrides:
createTimerEndMessage in class LogAdapter
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 final 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
Overrides:
createVPMessage in class LogAdapter
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 final 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
Overrides:
configuration in class LogAdapter
Parameters:
language - The language used for the script ( i.e. java )

createConfigurationMessage

public final 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
Overrides:
createConfigurationMessage in class LogAdapter
Parameters:
language - The language used for the script ( i.e. java )
Returns:
A configuration message. This message has the result, event, and note initialized.

exception

public final 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
Overrides:
exception in class LogAdapter

exception

public final 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
Overrides:
exception in class LogAdapter

createTestResultMessage

public final ILogMessage createTestResultMessage(java.lang.String headline,                                                  boolean passed,                                                  java.lang.String additionalInfo)
Creates a test result message.

Specified by:
createTestResultMessage in interface ILog
Overrides:
createTestResultMessage in class LogAdapter
Parameters:
headline - The headline describing the test
passed - A boolean indicating if the test passed or failed.
additionalInfo - Additional information about the test

getTimestamp

public static final java.lang.String getTimestamp()
Gets the current locale timestamp that can be logged

Returns:
timeStamp CurrentTimeStamp

open

public void open()
Opens the log and initializes internal resources. Internal method for initializations and not to be used by implementor/extendors Sub classes can override initLog to perform log initialization.

Specified by:
open in interface ISimpleLog
Overrides:
open in class SimpleLogAdapter

close

public void close()
Closes the log, thereby releasing internal resources. It is an Internal method not to be used by implementor/extendors Sub classes can override closeLog when they are done with the log

Specified by:
close in interface ISimpleLog
Overrides:
close in class SimpleLogAdapter

getLogFilename

public java.lang.String getLogFilename()
Returns the log file for the log. It return an empty string. Override the method to return a proper file name

Specified by:
getLogFilename in interface ILog
Overrides:
getLogFilename in class LogAdapter
Returns:
Return an empty string

getScriptName

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

Returns:
The scriptname

initLog

public abstract void initLog()
                      throws LogException
The abstract method that needs to be overridden by the sub classes to initialize their custom logs

Throws:
LogException

closeLog

public abstract void closeLog()
The abstract method that needs to be overridden by sub classes to close their custom logs


writeLog

public abstract void writeLog(ILogMessage message)
The abstract method that needs to be overridden by sub classes to handle the log events in the form of ILogMessage

Parameters:
message - The log Message Structure that contains information of log events and properties