com.bitmechanic.maxq.generator
Class HttpUnitTemplateLogic

java.lang.Object
  extended by com.bitmechanic.maxq.generator.TemplateLogic
      extended by com.bitmechanic.maxq.generator.HttpUnitTemplateLogic

public class HttpUnitTemplateLogic
extends TemplateLogic

TemplateLogic variation for generating smart HttpUnit tests.

Version:
$Id: HttpUnitTemplateLogic.java,v 1.3 2005/05/04 12:45:44 rkrzewsk Exp $
Author:
Rafal Krzewski

Nested Class Summary
static class HttpUnitTemplateLogic.InPlaceResponse
          A subclass of WebResponse for parsing pages intercepted by MaxQ proxy.
 
Constructor Summary
HttpUnitTemplateLogic()
           
 
Method Summary
 com.meterware.httpunit.WebForm getFormByParameterNames(com.meterware.httpunit.HTMLSegment page, java.util.Map requestParameters)
          Guesses the submitted form using the names of the POST parameters in the next request.
 java.util.List getForms(com.meterware.httpunit.HTMLSegment page)
          Returns all the forms contained in the given page.
 java.util.List getLinkIds(com.meterware.httpunit.HTMLSegment page, java.lang.String url)
          Returns list of IDs of the links that have hrefs containd in the specified URL.
 java.util.List getLinkTexts(com.meterware.httpunit.HTMLSegment page, java.lang.String url)
          Returns list of texts of the links that have hrefs containd in the specified URL.
 java.util.List getPostButtonId(com.meterware.httpunit.WebForm form)
          Returns list of IDs of the buttons that can possibly submit a form using JavaScript.
 java.util.List getPostButtonIndices(com.meterware.httpunit.WebForm form)
          Returns list of indices of the buttons that can possibly submit a form using JavaScript.
 java.util.List getPostLinkIds(com.meterware.httpunit.HTMLSegment page)
          Returns IDs of all links in the page that execute JavaScript code.
 java.util.List getPostLinkTexts(com.meterware.httpunit.HTMLSegment page)
          Returns texts of all links in the page that execute JavaScript code.
 com.meterware.httpunit.SubmitButton getPostSubmitButton(com.meterware.httpunit.WebForm form, java.util.Map parameters)
          Guesses the clicked submit button in a form, based on the POST parameters in the next request.
 java.util.List getPostSubmitButtonIndices(com.meterware.httpunit.WebForm form)
          Returns the indices of submit buttons present in the form.
 com.meterware.httpunit.HTMLSegment parsePage(java.lang.String url, java.lang.String content)
          Parse a web page using HttpUnit.
 
Methods inherited from class com.bitmechanic.maxq.generator.TemplateLogic
escapeParam, getBaseUrl, getConfig, getRelativeUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUnitTemplateLogic

public HttpUnitTemplateLogic()
Method Detail

parsePage

public com.meterware.httpunit.HTMLSegment parsePage(java.lang.String url,
                                                    java.lang.String content)
                                             throws java.net.MalformedURLException
Parse a web page using HttpUnit.

At the time of writing this requires patched HttpUnit to operate correctly

Parameters:
url - the page URL, required for downloading scripts.
content - the the page content.
Throws:
java.net.MalformedURLException

getLinkIds

public java.util.List getLinkIds(com.meterware.httpunit.HTMLSegment page,
                                 java.lang.String url)
                          throws org.xml.sax.SAXException
Returns list of IDs of the links that have hrefs containd in the specified URL.

Parameters:
page - the page.
url - the url.
Returns:
list of link IDs.
Throws:
org.xml.sax.SAXException - if page traversal fails.

getLinkTexts

public java.util.List getLinkTexts(com.meterware.httpunit.HTMLSegment page,
                                   java.lang.String url)
                            throws org.xml.sax.SAXException
Returns list of texts of the links that have hrefs containd in the specified URL.

Parameters:
page - the page.
url - the url.
Returns:
list of link texts.
Throws:
org.xml.sax.SAXException - if page traversal fails.

getForms

public java.util.List getForms(com.meterware.httpunit.HTMLSegment page)
                        throws org.xml.sax.SAXException
Returns all the forms contained in the given page.

Parameters:
page - the page.
Throws:
org.xml.sax.SAXException - if page traversal fails.

getFormByParameterNames

public com.meterware.httpunit.WebForm getFormByParameterNames(com.meterware.httpunit.HTMLSegment page,
                                                              java.util.Map requestParameters)
                                                       throws org.xml.sax.SAXException
Guesses the submitted form using the names of the POST parameters in the next request.

Parameters:
page - the page
requestParameters - the POST parameters in the next request.
Returns:
a form object, or null if not matched.
Throws:
org.xml.sax.SAXException - if page traversal fails.

getPostSubmitButton

public com.meterware.httpunit.SubmitButton getPostSubmitButton(com.meterware.httpunit.WebForm form,
                                                               java.util.Map parameters)
                                                        throws org.xml.sax.SAXException
Guesses the clicked submit button in a form, based on the POST parameters in the next request.

Parameters:
form - the form.
parameters - the POST parameters in the next request.
Returns:
a submit button object, or null if not matched.
Throws:
org.xml.sax.SAXException - if page traversal fails.

getPostSubmitButtonIndices

public java.util.List getPostSubmitButtonIndices(com.meterware.httpunit.WebForm form)
Returns the indices of submit buttons present in the form.

At the time of writiting this method requires patched HttpUnit to compile

Parameters:
form - the form.
Returns:
indices of all the submit buttons present in the form.

getPostButtonId

public java.util.List getPostButtonId(com.meterware.httpunit.WebForm form)
Returns list of IDs of the buttons that can possibly submit a form using JavaScript.

Parameters:
form - the form.
Returns:
list of button IDs.

getPostButtonIndices

public java.util.List getPostButtonIndices(com.meterware.httpunit.WebForm form)
Returns list of indices of the buttons that can possibly submit a form using JavaScript.

Parameters:
form - the form.
Returns:
list of button indices.

getPostLinkIds

public java.util.List getPostLinkIds(com.meterware.httpunit.HTMLSegment page)
                              throws org.xml.sax.SAXException
Returns IDs of all links in the page that execute JavaScript code.

Parameters:
page - the page.
Returns:
list of link IDs.
Throws:
org.xml.sax.SAXException - if page traversal fails.

getPostLinkTexts

public java.util.List getPostLinkTexts(com.meterware.httpunit.HTMLSegment page)
                                throws org.xml.sax.SAXException
Returns texts of all links in the page that execute JavaScript code.

Parameters:
page - the page.
Returns:
list of link texts.
Throws:
org.xml.sax.SAXException - if page traversal fails.