org.apache.commons.latka.validators
Class RegexpValidator
java.lang.Object
org.apache.commons.latka.validators.BaseValidator
org.apache.commons.latka.validators.BaseConditionalValidator
org.apache.commons.latka.validators.RegexpValidator
- All Implemented Interfaces:
- Validator
public class RegexpValidator
- extends BaseConditionalValidator
- implements Validator
Perform regular expression matches on the body of
the HTTP response. Setting the "condition" attribute
of the test indicates whether or not a match
is expected. If the server returns a null
(e.g. in the case of an empty HEAD response), the
validator will always fail, regardless of the setting
of the "condition" attribute.
- Version:
- $Id: RegexpValidator.java 155424 2005-02-26 13:09:29Z dirkv $
- Author:
- Morgan Delagrange, dIon Gillard
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_pattern
protected String _pattern
_ignoreCase
protected boolean _ignoreCase
BARE_EXCEPTION_MESSAGE
protected static final String BARE_EXCEPTION_MESSAGE
- See Also:
- Constant Field Values
RegexpValidator
public RegexpValidator()
RegexpValidator
public RegexpValidator(String label)
RegexpValidator
public RegexpValidator(String label,
String pattern,
boolean cond,
boolean ignoreCase)
setPattern
public void setPattern(String pattern)
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
assertTrue
public boolean assertTrue(Response response)
throws ValidationException
- Description copied from class:
BaseConditionalValidator
- Return true or false, depending on whether or not
the test conditions were met. This
is regardless of the value of getCondition(),
which is handled elsewhere.
Note: this method
should _only_ throw ValidationExceptions under
exceptional circumstances (e.g. invalid regular
expressions, IOExceptions, etc). A successful test
should only return true or false.
- Specified by:
assertTrue
in class BaseConditionalValidator
- Parameters:
response
- HTTP response
- Returns:
- true if the test conditions were met, false otherwise
- Throws:
ValidationException
- when a validation fails
generateBareExceptionMessage
public String generateBareExceptionMessage()
- Description copied from class:
BaseConditionalValidator
- The BASE exception message for a subclass of
BaseConditionalValidator. Expect that the String
"EXPECTED" or "DID NOT EXPECT" will be prepended to
this message, depending on the value of getCondition().
For example, if you are validator attempts to match
regular expression x, this methods should
generate something like " TO MATCH REGULAR EXPRESSION
x.".
- Specified by:
generateBareExceptionMessage
in class BaseConditionalValidator
- Returns:
- bare exception message, to which will be prepended
"EXPECTED" or "DID NOT EXPECT"
Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.