net.sf.jameleon.plugin.httpunit
Class HtmlPageValidation

java.lang.Object
  extended by org.apache.commons.jelly.TagSupport
      extended by net.sf.jameleon.LocationAwareTagSupport
          extended by net.sf.jameleon.JameleonTagSupport
              extended by net.sf.jameleon.function.FunctionTag
                  extended by net.sf.jameleon.plugin.httpunit.HttpUnitFunctionTag
                      extended by net.sf.jameleon.plugin.httpunit.HtmlPageValidation
All Implemented Interfaces:
BreakPoint, Attributable, Storable, DynaTag, LocationAware, Tag
Direct Known Subclasses:
HtmlTableValidation

public class HtmlPageValidation
extends HttpUnitFunctionTag

Generic page validation for page title, text, and links. This validator does not use the setDefaultVariableValue method because this same tag is likely to be used multiple times in the same test case. This means that the attributes defined in the test case will override any variables predefined in the csv file.

NOTE: This tag uses the context. Normally this is okay, but for generic tags the context should not be used as it limits the user as to what variables they can use. Generic tags should be easy to extend in such a way that they can easily become data-driven.

Tag Name: <hu-page-validation> Type: validation
Tag Name: <html-unit-page-validation> Type: validation

Field Summary
protected  String formNameOrId
          Sets the form name or id for which the form parameters will be compared against.
protected  List imagesNotPresent
          Image that shouldn't be present
protected  List imagesPresent
          Image that needs to be present
protected  List linksNotPresent
          Link that shouldn't be in the response.
protected  List linksPresent
          Link that should be in the response.
protected  boolean stripHtmlComments
          Whether to strip HTML comments or not for textPresent and textNotPresent
protected  List textNotPresent
          Text that shouldn't be in the response.
protected  List textPresent
          Text that should be in the response.
protected  String title
          Title of the page need to be validated.
protected  String titleContains
          Text to be contained in the title.
protected  boolean trimWhitespace
          Whether leading and trailing whitespace should be trimmed from the title on the page before comparing..
protected  boolean validateImageResource
          If set to true validate the image, or images, refer to an existing resource.
protected  boolean validateLinkResource
          If set to true validate the link, or links, point to an existing resource.
protected  boolean validationOccured
           
 
Fields inherited from class net.sf.jameleon.plugin.httpunit.HttpUnitFunctionTag
currentPage, httpUnitFrameName, listener, requestTime, session
 
Fields inherited from class net.sf.jameleon.function.FunctionTag
addt, breakPoint, expectException, expectFailure, fResults, functionDelay, functionId, lastFileWritten, log, NO_DELAY, params, postcondition, precondition, st, state, tct, vpt
 
Fields inherited from class net.sf.jameleon.JameleonTagSupport
attributes, broker, contextVars, fp, unsupportedAttributes
 
Fields inherited from class net.sf.jameleon.LocationAwareTagSupport
columnNumber, elementTagName, lineNumber, scriptFileName
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
HtmlPageValidation()
           
 
Method Summary
protected  void assertResourceValid(String resourceType, WebRequest request)
           
 void setup()
           
 void tearDown()
           
 void testBlock()
           
protected  void validateFormTypes()
           
protected  void validateImagesNotPresent()
           
protected  void validateImagesPresent()
           
protected  void validateLinksNotPresent()
           
protected  void validateLinksPresent()
           
protected  void validateTextNotPresent()
           
protected  void validateTextPresent()
           
 
Methods inherited from class net.sf.jameleon.plugin.httpunit.HttpUnitFunctionTag
assertFormElementPresent, assertFormElementPresent, assertFormElementPresent, assertFormElementPresent, assertFormPresent, assertFormPresent, assertFormPresent, assertFormPresent, assertFormPresent, assertFormPresent, assertImageNotPresent, assertImageNotPresent, assertImageNotPresent, assertImageNotPresent, assertImagePresent, assertImagePresent, assertImagePresent, assertImagePresent, assertLinkPresent, assertLinkPresent, assertLinkPresent, assertLinkPresent, assertLinkPresentInTable, assertLinkPresentInTable, assertLinkPresentInTable, assertOptionDisplayContains, assertOptionDisplayContains, assertOptionDisplayContains, assertOptionDisplayContains, assertOptionDisplayEndsWith, assertOptionDisplayEndsWith, assertOptionDisplayEndsWith, assertOptionDisplayEndsWith, assertOptionDisplayEquals, assertOptionDisplayEquals, assertOptionDisplayEquals, assertOptionDisplayEquals, assertOptionDisplayStartsWith, assertOptionDisplayStartsWith, assertOptionDisplayStartsWith, assertOptionDisplayStartsWith, assertOptionValueEquals, assertOptionValueEquals, assertOptionValueEquals, assertOptionValueEquals, assertTableNotPresent, assertTableNotPresent, assertTableNotPresent, assertTableNotPresent, assertTablePresent, assertTablePresent, assertTablePresent, assertTablePresent, assertTextInputEquals, assertTextInputEquals, assertTextInputEquals, assertTextInputEquals, assertTextNotPresent, assertTextNotPresent, assertTextNotPresent, assertTextNotPresent, assertTextNotPresent, assertTextNotPresent, assertTextNotPresent, assertTextNotPresent, assertTextPresent, assertTextPresent, assertTextPresent, assertTextPresent, assertTextPresent, assertTextPresent, assertTextPresent, assertTextPresent, assertTitleContains, assertTitleContains, assertTitleContains, assertTitleContains, assertTitleEquals, assertTitleEquals, assertTitleEquals, assertTitleEquals, assertTitleEquals, assertTitleEquals, assertTitleEquals, assertTitleEquals, assertTitleNotEquals, assertTitleNotEquals, assertTitleNotEquals, assertTitleNotEquals, beginSession, beginSessionAt, clickButton, clickButtonWithID, clickButtonWithName, clickLink, clickLink, clickLink, clickLinkWithId, clickLinkWithImage, clickLinkWithImageSrc, clickLinkWithText, getBaseUrl, getCurrentPage, getCurrentPageText, getForm, getHttpSession, getImage, getLink, getLinkInTable, getOptionDisplay, getOptionValue, getOptionValueContains, getOptionValueEndsWith, getOptionValueMatches, getOptionValueStartsWith, getResponse, getTable, getTableColumnCells, getTrimmedCellText, pluginTearDown, setFormParameterValueFromContext, setHttpUnitFrameName, setupEnvironment, store, submitForm, submitForm
 
Methods inherited from class net.sf.jameleon.function.FunctionTag
addParam, addRequiredAttribute, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertFalse, assertFalse, assertMethod, assertMethodWithLevel, assertNotNull, assertNotNull, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNotSame, assertNotSame, assertNull, assertNull, assertNull, assertNull, assertRegexMatches, assertRegexMatches, assertRegexMatches, assertRegexMatches, assertSame, assertSame, assertSame, assertSame, assertTextContains, assertTextContains, assertTextContains, assertTextContains, assertTextEndsWith, assertTextEndsWith, assertTextEndsWith, assertTextEndsWith, assertTextStartsWith, assertTextStartsWith, assertTextStartsWith, assertTextStartsWith, assertTrue, assertTrue, assertTrue, assertTrue, checkParamTypes, cleanUp, cleanUpEnvironment, delay, delay, doTag, fail, fail, fail, fail, getFunctionId, getFunctionResults, getMatchingRegexText, getParam, getParamLength, getParams, getParentTags, getSessionTag, getStoreToFileName, getStringOrDefault, getTestCaseTag, getVariable, getVariableAsBoolean, getVariableAsList, getVariableAsString, isBreakPoint, isContextVariableNull, recordFunctionResult, regexMatches, removeFunctionResult, removeVariable, setDefaultVariableValue, setDefaultVariableValue, setExpectException, setExpectFailure, setFunctionDelay, setFunctionId, setUpFunctionResults, setVariable, traceMsg, validate
 
Methods inherited from class net.sf.jameleon.JameleonTagSupport
cleanVariablesInContext, createAttributes, describeAttributes, getAttributeBroker, getAttributes, getAttributeType, getClassAttributes, getFunctionalPoint, getUnsupportedAttributes, loadFunctionalPoint, resetFunctionalPoint, setAttribute, setVariableInContext, testForUnsupportedAttributesCaught
 
Methods inherited from class net.sf.jameleon.LocationAwareTagSupport
getColumnNumber, getElementName, getFileName, getLineNumber, setColumnNumber, setElementName, setFileName, setLineNumber
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
 

Field Detail

title

protected String title
Title of the page need to be validated.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationTitle

titleContains

protected String titleContains
Text to be contained in the title.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationTitleContains

trimWhitespace

protected boolean trimWhitespace
Whether leading and trailing whitespace should be trimmed from the title on the page before comparing..

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationTitleTrimWhitespace

textPresent

protected List textPresent
Text that should be in the response.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationText

textNotPresent

protected List textNotPresent
Text that shouldn't be in the response.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationTextNotPresent

imagesPresent

protected List imagesPresent
Image that needs to be present

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationImage

imagesNotPresent

protected List imagesNotPresent
Image that shouldn't be present

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationImageNotPresent

validateImageResource

protected boolean validateImageResource
If set to true validate the image, or images, refer to an existing resource.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationImageValidate

linksNotPresent

protected List linksNotPresent
Link that shouldn't be in the response.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationLinkNotPresent

linksPresent

protected List linksPresent
Link that should be in the response.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationLink

validateLinkResource

protected boolean validateLinkResource
If set to true validate the link, or links, point to an existing resource.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationLinkValidate

stripHtmlComments

protected boolean stripHtmlComments
Whether to strip HTML comments or not for textPresent and textNotPresent

This attribute is recognized by Jameleon
Default Value: true
Context Name: htmlPageValidationStripComments

formNameOrId

protected String formNameOrId
Sets the form name or id for which the form parameters will be compared against.

This attribute is recognized by Jameleon
Required: false
Context Name: htmlPageValidationFormNameOrId

validationOccured

protected boolean validationOccured
Constructor Detail

HtmlPageValidation

public HtmlPageValidation()
Method Detail

testBlock

public void testBlock()
Overrides:
testBlock in class FunctionTag

setup

public void setup()
Overrides:
setup in class FunctionTag

validateTextPresent

protected void validateTextPresent()

validateTextNotPresent

protected void validateTextNotPresent()

validateLinksNotPresent

protected void validateLinksNotPresent()

validateImagesNotPresent

protected void validateImagesNotPresent()

validateImagesPresent

protected void validateImagesPresent()

validateLinksPresent

protected void validateLinksPresent()

assertResourceValid

protected void assertResourceValid(String resourceType,
                                   WebRequest request)

validateFormTypes

protected void validateFormTypes()

tearDown

public void tearDown()
Overrides:
tearDown in class FunctionTag


Copyright © 2003-2008 Christian Hargraves. All Rights Reserved.