ca.intelliware.amakihi.validator
Class BaseReturnValueValidator

java.lang.Object
  |
  +--ca.intelliware.amakihi.validator.BaseReturnValueValidator
All Implemented Interfaces:
ResponseValidationStrategy
Direct Known Subclasses:
ExactReturnValueValidator, SampleReturnValueValidator

public abstract class BaseReturnValueValidator
extends java.lang.Object
implements ResponseValidationStrategy


Inner Class Summary
 class BaseReturnValueValidator.MatchResult
           
 class BaseReturnValueValidator.NonMatchResult
           
 class BaseReturnValueValidator.PerfectMatchResult
           
 
Field Summary
protected  java.lang.Boolean containsTextRule
           
static int PRECEDENCE_ALL_MATCH
           
static int PRECEDENCE_CHILD_ELEMENT_COUNT_DOESNT_MATCH
           
static int PRECEDENCE_ELEMENT_AND_ATTRIBUTES_MATCH_BUT_TEXT_DOESNT
           
static int PRECEDENCE_ELEMENT_DOESNT_MATCH
           
static int PRECEDENCE_ELEMENT_MATCH_BUT_ATTRIBUTE_DOESNT
           
static java.lang.String RULE_CONTAINS_TEXT
           
static java.lang.String RULE_DONT_START_AT_TOP
           
static java.lang.String RULE_DONT_VALIDATE_ATTRIBUTES
           
static java.lang.String RULE_EXACT_TEXT
           
static java.lang.String RULE_START_AT_TOP
           
static java.lang.String RULE_VALIDATE_ATTRIBUTES
           
 
Constructor Summary
BaseReturnValueValidator()
           
 
Method Summary
 void addRule(java.lang.String rule)
           
protected  java.lang.String createBranchSummary(org.w3c.dom.Element expected, org.w3c.dom.Attr[] attributes)
          Generates a string description of the current branch of the XML tree.
protected  java.lang.String createBranchSummary(org.w3c.dom.Node node, org.w3c.dom.Attr[] attributes)
           
protected abstract  BaseReturnValueValidator.MatchResult elementsAreEqual(org.w3c.dom.Element expected, org.w3c.dom.Element actual)
           
protected  org.w3c.dom.Attr[] findUnmatchedAttributesIfRequired(org.w3c.dom.Element expected, org.w3c.dom.Element actual)
          Find a list of all attributes in expected that either doesn't exist in actual, or that has a different value than in actual.
protected  boolean isElementNodeOrNonWhiteSpaceTextNode(org.w3c.dom.Node node)
           
 boolean isRequiredSimplyToContainText()
          The rule "exactText" is set by default.
 boolean isRequiredToStartAtTop()
          The rule "startAtTop" is set by default.
 boolean isRequiredToValidateAttributes()
          The rule "dontValidateAttributes" is set by default.
protected  java.lang.String renderAsStringExcludingTopNode(org.w3c.dom.Node node)
           
protected  void setRequiredSimplyToContainText(boolean flag)
           
protected  void setRequiredToStartAtTop(boolean flag)
           
protected  void setRequiredToValidateAttributes(boolean flag)
           
 void validate(org.w3c.dom.Element actual, org.w3c.dom.Element expected)
           
protected  void validateOutputStartAnywhere(org.w3c.dom.Element expected, org.w3c.dom.Element actual)
           
protected  void validateOutputStartAtTop(org.w3c.dom.Element expected, org.w3c.dom.Element actual)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RULE_START_AT_TOP

public static final java.lang.String RULE_START_AT_TOP

RULE_DONT_START_AT_TOP

public static final java.lang.String RULE_DONT_START_AT_TOP

RULE_VALIDATE_ATTRIBUTES

public static final java.lang.String RULE_VALIDATE_ATTRIBUTES

RULE_DONT_VALIDATE_ATTRIBUTES

public static final java.lang.String RULE_DONT_VALIDATE_ATTRIBUTES

RULE_CONTAINS_TEXT

public static final java.lang.String RULE_CONTAINS_TEXT

RULE_EXACT_TEXT

public static final java.lang.String RULE_EXACT_TEXT

PRECEDENCE_ELEMENT_DOESNT_MATCH

public static final int PRECEDENCE_ELEMENT_DOESNT_MATCH

PRECEDENCE_ELEMENT_MATCH_BUT_ATTRIBUTE_DOESNT

public static final int PRECEDENCE_ELEMENT_MATCH_BUT_ATTRIBUTE_DOESNT

PRECEDENCE_CHILD_ELEMENT_COUNT_DOESNT_MATCH

public static final int PRECEDENCE_CHILD_ELEMENT_COUNT_DOESNT_MATCH

PRECEDENCE_ELEMENT_AND_ATTRIBUTES_MATCH_BUT_TEXT_DOESNT

public static final int PRECEDENCE_ELEMENT_AND_ATTRIBUTES_MATCH_BUT_TEXT_DOESNT

PRECEDENCE_ALL_MATCH

public static final int PRECEDENCE_ALL_MATCH

containsTextRule

protected java.lang.Boolean containsTextRule
Constructor Detail

BaseReturnValueValidator

public BaseReturnValueValidator()
Method Detail

addRule

public void addRule(java.lang.String rule)
             throws ValidationRuleNotSupportedException,
                    InconsistentValidationRuleException
Specified by:
addRule in interface ResponseValidationStrategy

setRequiredToStartAtTop

protected void setRequiredToStartAtTop(boolean flag)
                                throws InconsistentValidationRuleException

isRequiredToStartAtTop

public boolean isRequiredToStartAtTop()
The rule "startAtTop" is set by default. If validation is not required to start at the top, a child of the expected output may match any node (at any level) whithin the actual output.

setRequiredToValidateAttributes

protected void setRequiredToValidateAttributes(boolean flag)
                                        throws InconsistentValidationRuleException

isRequiredToValidateAttributes

public boolean isRequiredToValidateAttributes()
The rule "dontValidateAttributes" is set by default. Attributes are not validated, they are ignored.

setRequiredSimplyToContainText

protected void setRequiredSimplyToContainText(boolean flag)
                                       throws InconsistentValidationRuleException

isRequiredSimplyToContainText

public boolean isRequiredSimplyToContainText()
The rule "exactText" is set by default.

validate

public void validate(org.w3c.dom.Element actual,
                     org.w3c.dom.Element expected)
              throws ValidationException
Specified by:
validate in interface ResponseValidationStrategy
See Also:
ResponseValidationStrategy.validate(Element, Element)

elementsAreEqual

protected abstract BaseReturnValueValidator.MatchResult elementsAreEqual(org.w3c.dom.Element expected,
                                                                         org.w3c.dom.Element actual)

renderAsStringExcludingTopNode

protected java.lang.String renderAsStringExcludingTopNode(org.w3c.dom.Node node)

validateOutputStartAtTop

protected void validateOutputStartAtTop(org.w3c.dom.Element expected,
                                        org.w3c.dom.Element actual)
                                 throws ValidationException

validateOutputStartAnywhere

protected void validateOutputStartAnywhere(org.w3c.dom.Element expected,
                                           org.w3c.dom.Element actual)
                                    throws ValidationException

findUnmatchedAttributesIfRequired

protected org.w3c.dom.Attr[] findUnmatchedAttributesIfRequired(org.w3c.dom.Element expected,
                                                               org.w3c.dom.Element actual)

Find a list of all attributes in expected that either doesn't exist in actual, or that has a different value than in actual.

Returns:
the list of attribute nodes or zero-length array if no unmatched attributes are found or if we aren't required to validate the attributes.

createBranchSummary

protected java.lang.String createBranchSummary(org.w3c.dom.Node node,
                                               org.w3c.dom.Attr[] attributes)

createBranchSummary

protected java.lang.String createBranchSummary(org.w3c.dom.Element expected,
                                               org.w3c.dom.Attr[] attributes)

Generates a string description of the current branch of the XML tree.


isElementNodeOrNonWhiteSpaceTextNode

protected boolean isElementNodeOrNonWhiteSpaceTextNode(org.w3c.dom.Node node)


Copyright 2002 Intelliware Development. All Rights Reserved.