com.unitedinternet.portal.selenium.utils.logging
Class LoggingCommandProcessor

java.lang.Object
  extended by com.unitedinternet.portal.selenium.utils.logging.LoggingCommandProcessor
All Implemented Interfaces:
com.thoughtworks.selenium.CommandProcessor

public class LoggingCommandProcessor
extends java.lang.Object
implements com.thoughtworks.selenium.CommandProcessor

Logs processed selenium commands (processed via remote-control) with an arbitrary LoggingResultsFormatter. The formatter is responsible for writing logging events. A List of Selenium-Commands can be excluded from logging. Default is "getHtmlSource". Calls to selenium from within com.thoughtworks.selenium.Wait will be filtered and logged only once. Wait should not be the last command in execution (except in error, eg. timeout situation), as there is no way up to now to know that the last Wait is not a timed-out one. TODO selenium calls inside Wait are only logged once (filtered else) make this configurable TODO make name of a "Wait" class configurable TODO (feature) count time taken inside a Wait and logg that, too TODO (feature) add more metrics. currently verification errors can not be reliable counted

Author:
Robert Zimmermann $Id: LoggingCommandProcessor.java 134 2009-01-14 20:44:21Z bobbyde $

Constructor Summary
LoggingCommandProcessor(com.thoughtworks.selenium.CommandProcessor commandProcessor, LoggingResultsFormatter myFormatter)
          Constructor.
LoggingCommandProcessor(java.lang.String serverHost, int serverPort, java.lang.String browserStartCommand, java.lang.String browserUrl, LoggingResultsFormatter myFormatter)
          Will create an HttpCommandProcessor for you.
 
Method Summary
 java.lang.String doCommand(java.lang.String commandName, java.lang.String[] args)
          Extends doCommand, handling special logging commands.
 boolean getBoolean(java.lang.String commandName, java.lang.String[] args)
          
 boolean[] getBooleanArray(java.lang.String commandName, java.lang.String[] args)
          
 java.lang.String[] getExcludedCommands()
          List of Selenium commands to be excluded from logging.
 java.lang.Number getNumber(java.lang.String commandName, java.lang.String[] args)
          
 java.lang.Number[] getNumberArray(java.lang.String commandName, java.lang.String[] args)
          
 java.lang.String getString(java.lang.String commandName, java.lang.String[] args)
          
 java.lang.String[] getStringArray(java.lang.String commandName, java.lang.String[] args)
          
 boolean isLogMethodsAsComments()
           
 boolean isTestFailed()
          Is the current test failed.
static LoggingBean presetLoggingBean(java.lang.String commandName, java.lang.String[] args, java.lang.String result, long cmdStartMillis, long cmdEndMillis)
          Remember any selenium command with its result as an SeleniumLoggingBean.
 void setCallbackNotifier(LoggingNotifier callbackLoggingNotifier, java.lang.Object callbackLoggingInstance)
          Set the call back notifier.
 void setExcludedCommands(java.lang.String[] excludedCommands)
          List of Selenium commands to be excluded from logging Be aware that the defaults will be overwritten.
 void setLogMethodsAsComments(boolean logMethodsAsComments)
           
 void start()
          
 void stop()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingCommandProcessor

public LoggingCommandProcessor(com.thoughtworks.selenium.CommandProcessor commandProcessor,
                               LoggingResultsFormatter myFormatter)
Constructor.

Parameters:
commandProcessor - commandProcessor to be used for communication with selenium
myFormatter - formatter, responsible for formating all loggingEvents and writing them to file, db or whatever.

LoggingCommandProcessor

public LoggingCommandProcessor(java.lang.String serverHost,
                               int serverPort,
                               java.lang.String browserStartCommand,
                               java.lang.String browserUrl,
                               LoggingResultsFormatter myFormatter)
Will create an HttpCommandProcessor for you.

Parameters:
serverHost - - the host name on which the Selenium Server resides
serverPort - - the port on which the Selenium Server is listening
browserStartCommand - - the command string used to launch the browser, e.g. "*firefox" or "c:\\program files\\internet explorer\\iexplore.exe"
browserUrl - - the starting URL including just a domain name. We'll start the browser pointing at the Selenium resources on this URL, e.g. "http://www.google.com" would send the browser to "http://www.google.com/selenium-server/core/RemoteRunner.html"
myFormatter - formatter, responsible for formating all loggingEvents and writing them to file, db or whatever.
Method Detail

doCommand

public java.lang.String doCommand(java.lang.String commandName,
                                  java.lang.String[] args)
Extends doCommand, handling special logging commands. Delegates all other commands to the realcommandProcessor.

Specified by:
doCommand in interface com.thoughtworks.selenium.CommandProcessor

getBoolean

public boolean getBoolean(java.lang.String commandName,
                          java.lang.String[] args)

Specified by:
getBoolean in interface com.thoughtworks.selenium.CommandProcessor

getBooleanArray

public boolean[] getBooleanArray(java.lang.String commandName,
                                 java.lang.String[] args)

Specified by:
getBooleanArray in interface com.thoughtworks.selenium.CommandProcessor

getNumber

public java.lang.Number getNumber(java.lang.String commandName,
                                  java.lang.String[] args)

Specified by:
getNumber in interface com.thoughtworks.selenium.CommandProcessor

getNumberArray

public java.lang.Number[] getNumberArray(java.lang.String commandName,
                                         java.lang.String[] args)

Specified by:
getNumberArray in interface com.thoughtworks.selenium.CommandProcessor

getString

public java.lang.String getString(java.lang.String commandName,
                                  java.lang.String[] args)

Specified by:
getString in interface com.thoughtworks.selenium.CommandProcessor

getStringArray

public java.lang.String[] getStringArray(java.lang.String commandName,
                                         java.lang.String[] args)

Specified by:
getStringArray in interface com.thoughtworks.selenium.CommandProcessor

start

public void start()

Specified by:
start in interface com.thoughtworks.selenium.CommandProcessor

stop

public void stop()

Specified by:
stop in interface com.thoughtworks.selenium.CommandProcessor

getExcludedCommands

public java.lang.String[] getExcludedCommands()
List of Selenium commands to be excluded from logging. Default exclude: getHtmlSource

Returns:
current list of commands to be excluded

setExcludedCommands

public void setExcludedCommands(java.lang.String[] excludedCommands)
List of Selenium commands to be excluded from logging Be aware that the defaults will be overwritten. Combine with an getExcludedCommands to preserve defaults

Parameters:
excludedCommands - list of commands to be excluded

presetLoggingBean

public static LoggingBean presetLoggingBean(java.lang.String commandName,
                                            java.lang.String[] args,
                                            java.lang.String result,
                                            long cmdStartMillis,
                                            long cmdEndMillis)
Remember any selenium command with its result as an SeleniumLoggingBean. This is an convenience method to preset an SeleniumLoggingBean

Parameters:
commandName - the commandName for and from selenium (may be a special one like for comments)
args - 0 to 2 parameters as used by selenium
result - the result from selenium (and RC)
cmdStartMillis - timestamp just before command started
cmdEndMillis - timestamp after command finished
Returns:
preset SeleniumLoggingBean (only preset, as the SeleniumLoggingBean can hold more information)

isTestFailed

public boolean isTestFailed()
Is the current test failed. Only suitable after all commands are processed. But can be called at any time.

Returns:
true if test failed

setCallbackNotifier

public void setCallbackNotifier(LoggingNotifier callbackLoggingNotifier,
                                java.lang.Object callbackLoggingInstance)
Set the call back notifier. If you want to stop notifications set to null.

Parameters:
callbackLoggingNotifier - The call back notifier object
callbackLoggingInstance - The calling instance to notify

isLogMethodsAsComments

public boolean isLogMethodsAsComments()

setLogMethodsAsComments

public void setLogMethodsAsComments(boolean logMethodsAsComments)


Copyright © 2009. All Rights Reserved.