Methods Summary |
---|
public void | assertStringInBody(WebResponse response, java.lang.String searchfor, java.lang.String url)assert that the response contains a string
String body=response.getText();
boolean found=body.indexOf(searchfor)>=0;
if(!found) {
String message;
message="failed to find ["+searchfor+"] at "+url;
fail(message);
}
|
protected void | assertStringInBody(WebRequest request, java.lang.String searchfor)assert that a named string is in the request body of the
response to a request
WebResponse response = makeRequest(request);
assertStringInBody(response,searchfor,request.getURL().toString());
|
protected void | assertStringNotInBody(WebResponse response, java.lang.String searchfor, java.lang.String url)assert that a string is not in a response
String body=response.getText();
boolean found=body.indexOf(searchfor)>=0;
if(found) {
String message;
message="unexpectedly found "+searchfor+" at "+url;
fail(message);
}
|
protected void | assertStringNotInBody(WebRequest request, java.lang.String searchfor)assert that a string is not in the response to a request
WebConversation session = new WebConversation();
WebResponse response=session.getResponse(request);
assertStringNotInBody(response,searchfor,
request.getURL().toString());
|
protected void | expectErrorCode(WebRequest request, int errorCode, java.lang.String errorText)here we expect an errorCode other than 200, and look for it
checking for text is omitted as it doesnt work. It would never work on
java1.3, but one may have expected java1.4+ to have access to the
error stream in responses. clearly not
WebConversation session = new WebConversation();
String failureText="Expected error "+errorCode+" from "+request.getURL();
try {
session.getResponse(request);
fail(errorText+" -got success instead");
} catch (HttpException e) {
assertEquals(failureText,errorCode,e.getResponseCode());
/* checking for text omitted as it doesnt work.
if(errorText!=null) {
assertTrue(
"Failed to find "+errorText+" in "+ e.getResponseMessage(),
e.getMessage().indexOf(errorText)>=0);
}
*/
}
|
protected WebResponse | makeRequest(WebRequest request)make a request in a new session
WebConversation session = new WebConversation();
WebResponse response=session.getResponse(request);
return response;
|
public void | setUp()The JUnit setup method
url=System.getProperty(URL_PROPERTY);
assertNotNull(URL_PROPERTY+" not set",url);
HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
HttpUnitOptions.setMatchesIgnoreCase(true);
HttpUnitOptions.setParserWarningsEnabled(true);
|