Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created July 23, 2008 18:03
Show Gist options
  • Save defunkt/1835 to your computer and use it in GitHub Desktop.
Save defunkt/1835 to your computer and use it in GitHub Desktop.
try
{
beginAt(atUrl);
}
catch (RuntimeException re)
{
// If we get here, it's possible that we are running on java 1.5 +
// and the server is websphere. in this combination (and only this
// one AFAIK) the HttpUnit client receives a null from
// HttpUrlConnection.getErrorStream() which, according to the JDK javadoc
// is supposed to indicate that there is no error. It certainly means
// nothing can be read from it!
// Unfortunately, when HttpUnit then follows the getInputStream() call
// tree it ends up with an IOException it didn't expect.
// To add insult to injury, this IOException is not set as the cause
// of the RuntimeException jwebunit wraps it in so we just make some small
// efforts to ensure the basis of the
// exception is the 503 we were hoping for.
log.warn("Can't assert 503 response, using crude websphere workaround");
assertTrue(re.getMessage().contains("IOException"));
assertTrue(re.getMessage().contains("503"));
return;
}
WebResponse webResponse = getDialog().getResponse();
assertEquals("expected service unavailable response for url: '" + atUrl + "'",
503, webResponse.getResponseCode());
assertEquals("should be no content for this url: '" + atUrl + "'", 0,
webResponse.getText().length());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment