org.apache.commons.latka
Class XMLReporter

java.lang.Object
  extended by org.apache.commons.latka.AbstractReporter
      extended by org.apache.commons.latka.XMLReporter
All Implemented Interfaces:
LatkaEventListener

public class XMLReporter
extends AbstractReporter
implements LatkaEventListener

This LatkaEventListener will generate an XML report of all tests run during an Latka XML suite. XMLReporter instances are NOT reusable for multiple invocations of the Latka#runTests(Suite, LatkaEventInfo) method.

Version:
$Id: XMLReporter.java 155424 2005-02-26 13:09:29Z dirkv $
Author:
Morgan Delagrange, dIon Gillard

Field Summary
protected  boolean _didSuiteSucceed
           
protected  org.dom4j.Document _doc
          dom4j document produced as output
protected  org.dom4j.DocumentFactory _factory
           
protected  PrintWriter _printWriter
          used for output as tests run
protected  org.dom4j.Element _rootElement
          top level element of dom4j document, a <report> element
 
Fields inherited from class org.apache.commons.latka.AbstractReporter
_log
 
Constructor Summary
XMLReporter()
          Create an XML Reporter, initialising document property, as a new empty report with an unsuccessful suite
 
Method Summary
protected  org.dom4j.Element createRequestElement(RequestEvent event)
          Utility method that converts a RequestEvent object to its corresponding element in the dom4j object.
 org.dom4j.Document getDocument()
          Returns the XML Document produced by this listener
 String getDocumentAsString()
          Returns the test report converted from dom4j to a text string.
 void reportMessage(ReportMessageEvent event)
          Add the message of the provided event to the XML document as a <reportMessage> element with text
 void requestError(RequestEvent event)
          Invoked if a request error occurs.
 void requestFailed(RequestEvent event)
          Invoked if the request failed.
 void requestSkipped(RequestEvent event)
          A skipped request.
 void requestSucceeded(RequestEvent event)
          Invoked if the request succeeds
 void setPrintWriter(PrintWriter writer)
          During the execution, any diagnostic ouput will be sent to the stream designated here.
 void suiteCompleted(SuiteEvent event)
          Invoke when all requests completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_doc

protected org.dom4j.Document _doc
dom4j document produced as output


_rootElement

protected org.dom4j.Element _rootElement
top level element of dom4j document, a <report> element


_printWriter

protected PrintWriter _printWriter
used for output as tests run


_didSuiteSucceed

protected boolean _didSuiteSucceed

_factory

protected org.dom4j.DocumentFactory _factory
Constructor Detail

XMLReporter

public XMLReporter()
Create an XML Reporter, initialising document property, as a new empty report with an unsuccessful suite

Method Detail

getDocument

public org.dom4j.Document getDocument()
Returns the XML Document produced by this listener

Returns:
dom4j representation of the test report

getDocumentAsString

public String getDocumentAsString()
                           throws IOException
Returns the test report converted from dom4j to a text string.

Returns:
the test report as an XML string
Throws:
IOException - if the XML formatter cannot convert the dom4j object to text

requestError

public void requestError(RequestEvent event)
Description copied from interface: LatkaEventListener
Invoked if a request error occurs. A request "error" designates an inability to communicate with the target HTTP server (typically an IOException or a related exception).

Specified by:
requestError in interface LatkaEventListener
Parameters:
event - the event detailing the request in error
See Also:
LatkaEventListener.requestError(RequestEvent)

requestSucceeded

public void requestSucceeded(RequestEvent event)
Description copied from interface: LatkaEventListener
Invoked if the request succeeds

Specified by:
requestSucceeded in interface LatkaEventListener
Parameters:
event - the event detailing the request that succeeded
See Also:
LatkaEventListener.requestSucceeded(RequestEvent)

requestFailed

public void requestFailed(RequestEvent event)
Description copied from interface: LatkaEventListener
Invoked if the request failed. A request "failure" is defined as a request that successfully received a reponse from the server, but that response failed validation (threw a ValidationException).

Specified by:
requestFailed in interface LatkaEventListener
Parameters:
event - the event detailing the request that failed
See Also:
LatkaEventListener.requestFailed(RequestEvent)

requestSkipped

public void requestSkipped(RequestEvent event)
Description copied from interface: LatkaEventListener
A skipped request. Most Latka suites will skip any further requests inside a session upon the first failed request.

Specified by:
requestSkipped in interface LatkaEventListener
Parameters:
event - the event detailing the request that was skipped
See Also:
LatkaEventListener.requestSkipped(RequestEvent)

reportMessage

public void reportMessage(ReportMessageEvent event)
Add the message of the provided event to the XML document as a <reportMessage> element with text

Specified by:
reportMessage in interface LatkaEventListener
Parameters:
event - a ReportMessageEvent

suiteCompleted

public void suiteCompleted(SuiteEvent event)
Description copied from interface: LatkaEventListener
Invoke when all requests completed.

Specified by:
suiteCompleted in interface LatkaEventListener
Parameters:
event - the event detailing the completing Suite
See Also:
LatkaEventListener.suiteCompleted(SuiteEvent)

createRequestElement

protected org.dom4j.Element createRequestElement(RequestEvent event)
Utility method that converts a RequestEvent object to its corresponding element in the dom4j object.

Parameters:
event - the request event sent to the listener
Returns:
the dom4j Element equivalent

setPrintWriter

public void setPrintWriter(PrintWriter writer)
During the execution, any diagnostic ouput will be sent to the stream designated here. If no PrintWriter is set, output will be sent to standard out.

Parameters:
writer - PrintWriter that will receive output generated during the test


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.