Class WebValidatorBase
java.lang.Object
com.sun.ts.tests.common.webclient.validation.WebValidatorBase
- All Implemented Interfaces:
- ValidationStrategy
- Direct Known Subclasses:
- TokenizedValidator
Base abstract class for WebTestCase validation.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected WebTestCaseThe test case being validatedprotected HttpRequestThis test case's HttpRequestprotected HttpResponseThis test case's HttpResponseprotected static final charUsed to detect 4xx class HTTP errors to allow fail fast situations when 4xx errors are not expected.protected static final charUsed to detect 5xx class HTTP errors to allows fail fast situations when 5xx errors are not expected.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancheckExpectedHeaderswill check the response for the configured expected headers.protected abstract booleancheckGoldenFilecompare the server's response with the configured goldenfile Check the goldenfile If goldenfile is null, return true.protected booleancheckReasonPhrasewill perform comparisons between the configued reason-phrase and that of the response.protected booleancheckSearchStringswill scan the response for the configured strings that are to be expected in the response.protected booleancheckSearchStringsNoCasewill scan the response for the configured case insensitive strings that are to be expected in the response.protected booleancheckStatusCodewill 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 equalprotected booleancheckUnexpectedHeaderswill check the response for the configured unexpected expected headers.protected booleancheckUnexpectedSearchStringswill scan the response for the configured strings that are not expected in the response.protected booleancheckUnorderedSearchStringswill scan the response for the configured strings that are to be expected in the response.protected booleanisEmpty(org.apache.commons.httpclient.Header[] headers) Utility method to determine of the expected or unexpected headers are empty or not.booleanvalidate(WebTestCase testCase) validateWill validate the response against the configured TestCase.
- 
Field Details- 
CLIENT_ERRORprotected 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_ERRORprotected static final char SERVER_ERRORUsed to detect 5xx class HTTP errors to allows fail fast situations when 5xx errors are not expected.- See Also:
 
- 
_resThis test case's HttpResponse
- 
_reqThis test case's HttpRequest
- 
_caseThe test case being validated
 
- 
- 
Constructor Details- 
WebValidatorBasepublic WebValidatorBase()
 
- 
- 
Method Details- 
validatevalidateWill 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:
- validatein interface- ValidationStrategy
 
- 
checkStatusCodecheckStatusCodewill 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
 
- 
checkSearchStringscheckSearchStringswill 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
 
- 
checkSearchStringsNoCasecheckSearchStringsNoCasewill 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
 
- 
checkUnorderedSearchStringscheckUnorderedSearchStringswill 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
 
- 
checkUnexpectedSearchStringscheckUnexpectedSearchStringswill 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
 
- 
checkGoldenfilecheckGoldenFilecompare 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
 
- 
checkReasonPhraseprotected boolean checkReasonPhrase()checkReasonPhrasewill 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
 
- 
checkExpectedHeadersprotected boolean checkExpectedHeaders()checkExpectedHeaderswill 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
 
- 
checkUnexpectedHeadersprotected boolean checkUnexpectedHeaders()checkUnexpectedHeaderswill 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
 
- 
isEmptyprotected boolean isEmpty(org.apache.commons.httpclient.Header[] headers) Utility method to determine of the expected or unexpected headers are empty or not.
 
-