[Webtest] Bug in Canoo - Server error 500 happens invisibly
John Willemin
webtest@lists.canoo.com
Tue, 06 May 2003 15:37:53 -0400
I noticed that for some reason my test was mysteriously dying after
clicking a link. I had to debug the Canoo stuff for a while to figure out why.
It turns out that one of my page changes had broken the JSP I was working
on, so it was not compiling, and was sending back code 500.
The below fixes the problem. All you have to do is add a catch for
httpunit's HttpInternalErrorException. There might be other errors that can
get thrown from conversation.getResponse() but this is the only one I've
tripped so far.
I can either drop this in myself (if you want to give me write access) or
you can do it... whichever.. it's not a difficult fix :)
My reasoning is that if 404's get caught and displayed, there's no reason
not to do 500's. Also, I don't think the tests should ever silently exit
when there's an error condition.
Thanks for your time,
John Willemin
protected WebResponse gotoTarget(Context context, String url,
WebRequest request) {
WebResponse resp = null;
try {
installHtmlErrorHandlerIfNeeded(context);
if (request != null && url == null)
{
logText(context, "-> gotoTarget(by request): " + request);
resp = getResponse(context, request);
}
else if (url != null && request == null) {
logText(context, "-> gotoTarget(by url): " + url);
resp = getResponse(context, url);
System.err.println( "got response!" );
} else {
throw new IllegalStateException("Either request or url
must be set!");
}
} catch (AuthorizationRequiredException are) {
throw new StepFailedException("Authorization required for
page: " + (request == null ? url : request.toString()), this);
} catch (HttpNotFoundException hnfe) {
throw new StepFailedException(getStepId(context) + ": Page not
found: " + (request == null ? url : request.toString()), this);
} catch (HttpInternalErrorException hiee) {
throw new StepFailedException(getStepId(context) + ": 500
Internal Error: " + (request == null ? url : request.toString()), this);