ca.intelliware.amakihi.fixture
Class BaseReturnValueValidator

java.lang.Object
  |
  +--ca.intelliware.amakihi.fixture.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  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.
 boolean isRequiredSimplyToContainText()
          The rule "exactText" is set by default.
 boolean isRequiredToStartAtTop()
          The rule "startAtTop" is set by default.
 boolean isRequiredToValidateAttributes()
          The rule "validateAttributes" is set by default.
protected abstract  BaseReturnValueValidator.MatchResult nodesAreEqual(org.w3c.dom.Element expected, org.w3c.dom.Element actual)
           
protected  java.lang.String renderAsStringExcludingTopNode(org.w3c.dom.Node node)
           
protected  void saveVariablesIfNeeded(org.w3c.dom.Element expectedReturnValue, org.w3c.dom.Element actualReturnValue, java.util.Hashtable variables)
           
protected  void setRequiredSimplyToContainText(boolean flag)
           
protected  void setRequiredToStartAtTop(boolean flag)
           
protected  void setRequiredToValidateAttributes(boolean flag)
           
 void validate(org.w3c.dom.Element actualOutput, org.w3c.dom.Element expectedOutput, java.util.Hashtable variables)
           
protected  void validateReturnValues(org.w3c.dom.Element expectedReturnValue, org.w3c.dom.Element actualReturnValue)
           
protected  void validateReturnValuesStartAnywhere(org.w3c.dom.Element expectedReturnValue, org.w3c.dom.Element actualReturnValue)
           
protected  void validateReturnValuesStartAtTop(org.w3c.dom.Element expectedReturnValue, org.w3c.dom.Element actualReturnValue)
           
 
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. Validation is not required to start at the top, a child of the expected ReturnValue may match any node (at any level) whitin the actual ReturnValue.

setRequiredToValidateAttributes

protected void setRequiredToValidateAttributes(boolean flag)
                                        throws InconsistentValidationRuleException

isRequiredToValidateAttributes

public boolean isRequiredToValidateAttributes()
The rule "validateAttributes" 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 actualOutput,
                     org.w3c.dom.Element expectedOutput,
                     java.util.Hashtable variables)
              throws ValidationException
Specified by:
validate in interface ResponseValidationStrategy
See Also:
ResponseValidationStrategy.validate(Element, Element, Hashtable)

nodesAreEqual

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

renderAsStringExcludingTopNode

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

saveVariablesIfNeeded

protected void saveVariablesIfNeeded(org.w3c.dom.Element expectedReturnValue,
                                     org.w3c.dom.Element actualReturnValue,
                                     java.util.Hashtable variables)
                              throws org.w3c.dom.DOMException

validateReturnValues

protected void validateReturnValues(org.w3c.dom.Element expectedReturnValue,
                                    org.w3c.dom.Element actualReturnValue)
                             throws ValidationException

validateReturnValuesStartAtTop

protected void validateReturnValuesStartAtTop(org.w3c.dom.Element expectedReturnValue,
                                              org.w3c.dom.Element actualReturnValue)
                                       throws ValidationException

validateReturnValuesStartAnywhere

protected void validateReturnValuesStartAnywhere(org.w3c.dom.Element expectedReturnValue,
                                                 org.w3c.dom.Element actualReturnValue)
                                          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.



Copyright 2002 Intelliware Development. All Rights Reserved.