com.mockrunner.base
Class HTMLOutputModule

java.lang.Object
  extended by com.mockrunner.base.WebTestModule
      extended by com.mockrunner.base.HTMLOutputModule
Direct Known Subclasses:
ActionTestModule, GenericHTMLOutputModule, ServletTestModule, TagTestModule

public abstract class HTMLOutputModule
extends WebTestModule

Base class for modules which produce HTML code as output. These modules have to implement getOutput(). The HTML code is provided in different formats, e.g. as parsed XML documents.


Constructor Summary
HTMLOutputModule(WebMockObjectFactory mockFactory)
           
 
Method Summary
abstract  java.lang.String getOutput()
          Returns the output as a string.
 java.io.BufferedReader getOutputAsBufferedReader()
          Returns the output as a BufferedReader.
 org.jdom.Document getOutputAsJDOMDocument()
          Parses the output with the NekoHTML parser and returns it as a JDOM XML document.
 org.w3c.dom.Document getOutputAsW3CDocument()
          Parses the output with the NekoHTML parser and returns it as a W3C XML document.
 java.lang.String getOutputAsWellformedXML()
          Parses the output with the NekoHTML parser and returns it as fixed, wellformed XML.
 void setCaseSensitive(boolean caseSensitive)
          Set if verifyOutput(java.lang.String), verifyOutputContains(java.lang.String) and verifyOutputRegularExpression(java.lang.String).
 void verifyOutput(java.lang.String expectedOutput)
          Verifies the tag output.
 void verifyOutputContains(java.lang.String expectedOutput)
          Verifies if the output contains the specified data.
 void verifyOutputRegularExpression(java.lang.String expression)
          Verifies if the output matches the specified regular expression.
 
Methods inherited from class com.mockrunner.base.WebTestModule
addRequestParameter, addRequestParameter, addRequestParameter, getRequestAttribute, getRequestParameter, getSessionAttribute, setRequestAttribute, setSessionAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLOutputModule

public HTMLOutputModule(WebMockObjectFactory mockFactory)
Method Detail

getOutput

public abstract java.lang.String getOutput()
Returns the output as a string. Concrete modules implement this method.

Returns:
the output

getOutputAsBufferedReader

public java.io.BufferedReader getOutputAsBufferedReader()
Returns the output as a BufferedReader.

Returns:
the output

getOutputAsW3CDocument

public org.w3c.dom.Document getOutputAsW3CDocument()
Parses the output with the NekoHTML parser and returns it as a W3C XML document. Throws a NestedApplicationException if the output is not parsable. NekoHTML is quite good in fixing sloppy HTML code. If you want to use a different parser configuration, you can use the method XmlUtil.parse(org.apache.xerces.parsers.DOMParser, java.lang.String) to parse the string output yourself. Please note that HTML parsing is not very fast and may slow down your test suite.

Returns:
the output as org.w3c.dom.Document
Throws:
java.lang.RuntimeException - if a parsing error occurs

getOutputAsJDOMDocument

public org.jdom.Document getOutputAsJDOMDocument()
Parses the output with the NekoHTML parser and returns it as a JDOM XML document. Throws a NestedApplicationException if the output is not parsable. NekoHTML is quite good in fixing sloppy HTML code. If you want to use a different parser configuration, you can use the method XmlUtil.parse(org.apache.xerces.parsers.DOMParser, java.lang.String) to parse the string output yourself. Please note that HTML parsing is not very fast and may slow down your test suite.

Returns:
the output as org.jdom.Document
Throws:
java.lang.RuntimeException - if a parsing error occurs

getOutputAsWellformedXML

public java.lang.String getOutputAsWellformedXML()
Parses the output with the NekoHTML parser and returns it as fixed, wellformed XML. Throws a NestedApplicationException if the output is not parsable. NekoHTML is quite good in fixing sloppy HTML code. If you want to use a different parser configuration, you can use the method XmlUtil.parse(org.apache.xerces.parsers.DOMParser, java.lang.String) to parse the string output yourself. Please note that HTML parsing is not very fast and may slow down your test suite.

Returns:
the output as wellformed XML
Throws:
java.lang.RuntimeException - if a parsing error occurs

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Set if verifyOutput(java.lang.String), verifyOutputContains(java.lang.String) and verifyOutputRegularExpression(java.lang.String). should compare case sensitive. Default is true.

Parameters:
caseSensitive - enable or disable case sensitivity

verifyOutput

public void verifyOutput(java.lang.String expectedOutput)
Verifies the tag output.

Parameters:
expectedOutput - the expected output.
Throws:
VerifyFailedException - if verification fails

verifyOutputContains

public void verifyOutputContains(java.lang.String expectedOutput)
Verifies if the output contains the specified data.

Parameters:
expectedOutput - the data
Throws:
VerifyFailedException - if verification fails

verifyOutputRegularExpression

public void verifyOutputRegularExpression(java.lang.String expression)
Verifies if the output matches the specified regular expression.

Parameters:
expression - the data
Throws:
VerifyFailedException - if verification fails