Guest User

Untitled

a guest
Feb 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. try
  2. {
  3. beginAt(atUrl);
  4. }
  5. catch (RuntimeException re)
  6. {
  7. // If we get here, it's possible that we are running on java 1.5 +
  8. // and the server is websphere. in this combination (and only this
  9. // one AFAIK) the HttpUnit client receives a null from
  10. // HttpUrlConnection.getErrorStream() which, according to the JDK javadoc
  11. // is supposed to indicate that there is no error. It certainly means
  12. // nothing can be read from it!
  13. // Unfortunately, when HttpUnit then follows the getInputStream() call
  14. // tree it ends up with an IOException it didn't expect.
  15. // To add insult to injury, this IOException is not set as the cause
  16. // of the RuntimeException jwebunit wraps it in so we just make some small
  17. // efforts to ensure the basis of the
  18. // exception is the 503 we were hoping for.
  19. log.warn("Can't assert 503 response, using crude websphere workaround");
  20. assertTrue(re.getMessage().contains("IOException"));
  21. assertTrue(re.getMessage().contains("503"));
  22.  
  23. return;
  24. }
  25. WebResponse webResponse = getDialog().getResponse();
  26. assertEquals("expected service unavailable response for url: '" + atUrl + "'",
  27. 503, webResponse.getResponseCode());
  28. assertEquals("should be no content for this url: '" + atUrl + "'", 0,
  29. webResponse.getText().length());
Add Comment
Please, Sign In to add comment