|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.latka.validators.BaseValidator
org.apache.commons.latka.validators.BaseConditionalValidator
public abstract class BaseConditionalValidator
This subclass of BaseValidator largely removes the need of a validator to know whether a particular test is supposed to succeed or fail. The validate(Response) method becomes final, and the logic is moved into two abstract methods (see Javadocs): assertTrue(Response) and generateBareExceptionMessage().
| Field Summary | |
|---|---|
protected boolean |
_condition
condition to test against |
protected org.apache.log4j.Category |
_log
log4j category for output |
| Fields inherited from class org.apache.commons.latka.validators.BaseValidator |
|---|
_label |
| Constructor Summary | |
|---|---|
BaseConditionalValidator(boolean condition)
A test without a label |
|
BaseConditionalValidator(String label,
boolean condition)
A test with a label |
|
| Method Summary | |
|---|---|
abstract boolean |
assertTrue(Response response)
Return true or false, depending on whether or not the test conditions were met. |
abstract String |
generateBareExceptionMessage()
The BASE exception message for a subclass of BaseConditionalValidator. |
boolean |
getCondition()
Returns whether or not this test is supposed to succeed |
void |
setCondition(boolean condition)
Set whether or not this test is supposed to succeed |
protected void |
throwValidationException()
Automatically generated exception messages, based on the value of getCondition() and generateBareExceptionMessage(). |
void |
validate(Response response)
Final method. |
| Methods inherited from class org.apache.commons.latka.validators.BaseValidator |
|---|
fail, getLabel, setLabel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.apache.log4j.Category _log
protected boolean _condition
| Constructor Detail |
|---|
public BaseConditionalValidator(boolean condition)
condition - Whether the test should evaluate to true or false
public BaseConditionalValidator(String label,
boolean condition)
label - test labelcondition - whether the test should evaluate to true or false| Method Detail |
|---|
public void setCondition(boolean condition)
condition - true if the test should succeedpublic boolean getCondition()
public final void validate(Response response)
throws ValidationException
validate in interface Validatorvalidate in class BaseValidatorresponse - Response from the HTTP server
ValidationException - when a validation fails
public abstract boolean assertTrue(Response response)
throws ValidationException
response - HTTP response
ValidationException - when a validation failspublic abstract String generateBareExceptionMessage()
protected void throwValidationException()
throws ValidationException
ValidationException - generated Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||