Class WebValidatorBase
- All Implemented Interfaces:
ValidationStrategy
- Direct Known Subclasses:
TokenizedValidator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WebTestCase
The test case being validatedprotected HttpRequest
This test case's HttpRequestprotected HttpResponse
This test case's HttpResponseprotected static final char
Used to detect 4xx class HTTP errors to allow fail fast situations when 4xx errors are not expected.protected static final char
Used to detect 5xx class HTTP errors to allows fail fast situations when 5xx errors are not expected. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkExpectedHeaders
will check the response for the configured expected headers.protected abstract boolean
checkGoldenFile
compare the server's response with the configured goldenfile Check the goldenfileprotected boolean
checkReasonPhrase
will perform comparisons between the configued reason-phrase and that of the response.protected boolean
checkSearchStrings
will scan the response for the configured strings that are to be expected in the response.protected boolean
checkSearchStringsNoCase
will scan the response for the configured case insensitive strings that are to be expected in the response.protected boolean
checkStatusCode
will perform status code comparisons based on the algorithm below Check the HTTP status codeprotected boolean
checkUnexpectedHeaders
will check the response for the configured unexpected expected headers.protected boolean
checkUnexpectedSearchStrings
will scan the response for the configured strings that are not expected in the response.protected boolean
checkUnorderedSearchStrings
will scan the response for the configured strings that are to be expected in the response.protected boolean
isEmpty
(org.apache.commons.httpclient.Header[] headers) Utility method to determine of the expected or unexpected headers are empty or not.boolean
validate
(WebTestCase testCase) validate Will validate the response against the configured TestCase.
-
Field Details
-
CLIENT_ERROR
protected static final char CLIENT_ERRORUsed to detect 4xx class HTTP errors to allow fail fast situations when 4xx errors are not expected.- See Also:
-
SERVER_ERROR
protected static final char SERVER_ERRORUsed to detect 5xx class HTTP errors to allows fail fast situations when 5xx errors are not expected.- See Also:
-
_res
This test case's HttpResponse -
_req
This test case's HttpRequest -
_case
The test case being validated
-
-
Constructor Details
-
WebValidatorBase
public WebValidatorBase()
-
-
Method Details
-
validate
validate Will validate the response against the configured TestCase.- Check the HTTP status-code
- Check the HTTP reason-phrase
- Check for expected headers
- Check from unexpected headers
- Check expected search strings
- Check unexpected search strings
- Check the goldenfile
- Specified by:
validate
in interfaceValidationStrategy
-
checkStatusCode
checkStatusCode
will perform status code comparisons based on the algorithm below- Check the HTTP status code
-
If status code is -1, then return true
-
If test case status code null and response 4xx, return failure, print error; return false
-
If test case status code null and response 5xx, return failure include response body; return false
-
If test case status code null, and response not 4xx or 5xx, return true
-
Test case status code not null, compare it with the response status code; return true if equal
- Returns:
- boolen result of check
- Throws:
IOException
- if an IO error occurs during validation
-
checkSearchStrings
checkSearchStrings
will scan the response for the configured strings that are to be expected in the response.- Check search strings
-
If list of Strings is null, return true.
-
If list of Strings is not null, scan response body. If string is found, return true, otherwise display error and return false.
- Returns:
- boolen result of check
- Throws:
IOException
- if an IO error occurs during validation
-
checkSearchStringsNoCase
checkSearchStringsNoCase
will scan the response for the configured case insensitive strings that are to be expected in the response.- Check search strings
-
If list of Strings is null, return true.
-
If list of Strings is not null, scan response body. If string is found, return true, otherwise display error and return false.
- Returns:
- boolen result of check
- Throws:
IOException
- if an IO error occurs during validation
-
checkUnorderedSearchStrings
checkUnorderedSearchStrings
will scan the response for the configured strings that are to be expected in the response.- Check search strings
-
If list of Strings is null, return true.
-
If list of Strings is not null, scan response body. If string is found, return true, otherwise display error and return false.
- Returns:
- boolen result of check
- Throws:
IOException
- if an IO error occurs during validation
-
checkUnexpectedSearchStrings
checkUnexpectedSearchStrings
will scan the response for the configured strings that are not expected in the response.- Check unexpected search strings
-
If list of Strings is null, return true.
-
If list of Strings is not null, scan response body. If string is not found, return true, otherwise display error and return false.
- Returns:
- boolen result of check
- Throws:
IOException
- if an IO error occurs during validation
-
checkGoldenfile
checkGoldenFile
compare the server's response with the configured goldenfile- Check the goldenfile
-
If goldenfile is null, return true.
-
If goldenfile is not null, compare the goldenfile with the response. If equal, return true, otherwise display error and return false.
- Returns:
- boolen result of check
- Throws:
IOException
- if an IO error occurs during validation
-
checkReasonPhrase
protected boolean checkReasonPhrase()checkReasonPhrase
will perform comparisons between the configued reason-phrase and that of the response.- Check reason-phrase
-
If configured reason-phrase is null, return true.
-
If configured reason-phrase is not null, compare the reason-phrases with the response. If equal, return true, otherwise display error and return false.
- Returns:
- boolen result of check
-
checkExpectedHeaders
protected boolean checkExpectedHeaders()checkExpectedHeaders
will check the response for the configured expected headers.- Check expected headers
-
If there are no expected headers, return true.
-
If there are expected headers, scan the response for the expected headers. If all expected headers are found, return true, otherwise display an error and return false.
- Returns:
- boolen result of check
-
checkUnexpectedHeaders
protected boolean checkUnexpectedHeaders()checkUnexpectedHeaders
will check the response for the configured unexpected expected headers.- Check unexpected headers
-
If there are no configured unexpected headers, return true.
-
If there are configured unexpected headers, scan the response for the unexpected headers. If the headers are not found, return true, otherwise display an error and return false.
- Returns:
- boolen result of check
-
isEmpty
protected boolean isEmpty(org.apache.commons.httpclient.Header[] headers) Utility method to determine of the expected or unexpected headers are empty or not.
-