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

java.lang.Object
  extended by com.unitedinternet.portal.selenium.utils.logging.XmlResultFormatter
All Implemented Interfaces:
LoggingResultsFormatter

public class XmlResultFormatter
extends java.lang.Object
implements LoggingResultsFormatter

Formats all logging events as XML. Alternate formatter for logging. Be sure to pass an encoding-aware writer together with encoding name to the 2 parameters constuctor.

Author:
Mirko Friedenhagen

Constructor Summary
XmlResultFormatter(java.io.Writer myResultsWriter)
          Write results to the specified writer.
XmlResultFormatter(java.io.Writer myResultsWriter, java.lang.String myResultFileEncoding)
          Write results with an arbitrary encoding.
 
Method Summary
 void booleanCommandLogEvent(LoggingBean loggingBean)
          Formats an selenium command which has an boolean result.
 void commandLogEvent(LoggingBean loggingBean)
          Formats an selenium command.
 void commentLogEvent(LoggingBean loggingBean)
          Format a comment.
 void footerLogEvent()
          Like formatHeader() but here after all commands have been formatted.
 java.lang.String generateFilenameForAutomaticScreenshot(java.lang.String baseName)
          Generate an absolute filename for taking screenshots in case of an error (eg. timed out wait).
 java.lang.String getAutomaticScreenshotPath()
          Path to the (filesystem-)location where screenshot should be saved.
 java.lang.String getScreenShotBaseUri()
          Base URI to be linked to in the result.
 void headerLogEvent(TestMetricsBean metricsBean)
          Whatever the formatter wants to do before any command will be formatted.
 void methodLogEvent(LoggingBean loggingBean)
          Formats a Log Event for a complete Test Method.
 void setAutomaticScreenshotPath(java.lang.String automaticScreenshotPath)
          Path to the (filesystem-)location where screenshot should be saved.
 void setScreenShotBaseUri(java.lang.String screenShotBaseUri)
          Set a special uri for screenshots.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlResultFormatter

public XmlResultFormatter(java.io.Writer myResultsWriter)
Write results to the specified writer. Note: encoding ISO-8859-1 is assumed It is recommended to use the 2-parameter constructor.

Parameters:
myResultsWriter - where results will be written in "ISO-8859-1" encoding

XmlResultFormatter

public XmlResultFormatter(java.io.Writer myResultsWriter,
                          java.lang.String myResultFileEncoding)
Write results with an arbitrary encoding. Be sure to create the writer with the correct encoding Note: resultFileEncoding is only used to set a corresponding meta-tag in the resulting HTML-file For Example: new BufferedWriter(new OutputStreamWriter(new FileOutputStream("myResultFile.html"), "UTF-8")

Parameters:
myResultsWriter - writer with resultFileEncoding set. See also Example above
myResultFileEncoding - any encoding supported by the running jvm
Method Detail

booleanCommandLogEvent

public void booleanCommandLogEvent(LoggingBean loggingBean)
Formats an selenium command which has an boolean result. Important: At this state no information whether an false or true result was or is expected by the test using this formatter. So an false result may be "green" for the test. Therefore all log-events here are logged as green. e.g. selenium commands like isElementPresent

Specified by:
booleanCommandLogEvent in interface LoggingResultsFormatter
Parameters:
loggingBean - containing all informations for logging a selenium command

commandLogEvent

public void commandLogEvent(LoggingBean loggingBean)
Formats an selenium command.

Specified by:
commandLogEvent in interface LoggingResultsFormatter
Parameters:
loggingBean - containing all informations for logging a selenium command

commentLogEvent

public void commentLogEvent(LoggingBean loggingBean)
Format a comment. Comments may be issued between commands by the loggingCommandProcessor, like a new method has been entered by the test.

Specified by:
commentLogEvent in interface LoggingResultsFormatter
Parameters:
loggingBean - loggingBean containing the comment to be logged.

methodLogEvent

public void methodLogEvent(LoggingBean loggingBean)
Formats a Log Event for a complete Test Method. The Logging Bean may contain several child beans holding the information of the single selenium commands.

Specified by:
methodLogEvent in interface LoggingResultsFormatter
Parameters:
loggingBean - containing all informations for logging a test method and its commands

footerLogEvent

public void footerLogEvent()
Like formatHeader() but here after all commands have been formatted.

Specified by:
footerLogEvent in interface LoggingResultsFormatter

generateFilenameForAutomaticScreenshot

public java.lang.String generateFilenameForAutomaticScreenshot(java.lang.String baseName)
Generate an absolute filename for taking screenshots in case of an error (eg. timed out wait).

Specified by:
generateFilenameForAutomaticScreenshot in interface LoggingResultsFormatter
Parameters:
baseName - middle part of the name to be enhanced by whatever the implementation wants to
Returns:
absolute path for screenshot to be taken

getAutomaticScreenshotPath

public java.lang.String getAutomaticScreenshotPath()
Path to the (filesystem-)location where screenshot should be saved. Will be used by generateFilenameForAutomaticScreenshot()

Specified by:
getAutomaticScreenshotPath in interface LoggingResultsFormatter
Returns:
current location path

getScreenShotBaseUri

public java.lang.String getScreenShotBaseUri()
Base URI to be linked to in the result. Screenshots may be linked with an http or similar prefix to be easier accessible in whatever reporting frontend is used later

Specified by:
getScreenShotBaseUri in interface LoggingResultsFormatter
Returns:
the current base-uri for screenshots

headerLogEvent

public void headerLogEvent(TestMetricsBean metricsBean)
Whatever the formatter wants to do before any command will be formatted.

Specified by:
headerLogEvent in interface LoggingResultsFormatter
Parameters:
metricsBean - metrics gathered during test-run

setAutomaticScreenshotPath

public void setAutomaticScreenshotPath(java.lang.String automaticScreenshotPath)
Path to the (filesystem-)location where screenshot should be saved. Will be used by generateFilenameForAutomaticScreenshot()

Specified by:
setAutomaticScreenshotPath in interface LoggingResultsFormatter
Parameters:
automaticScreenshotPath - location (only path) to where screenshots should be saved

setScreenShotBaseUri

public void setScreenShotBaseUri(java.lang.String screenShotBaseUri)
Set a special uri for screenshots.

Specified by:
setScreenShotBaseUri in interface LoggingResultsFormatter
Parameters:
screenShotBaseUri - the new uri for screenshots


Copyright © 2009. All Rights Reserved.