public static HtmlPage loadIndex() { System.out.println("Loading Index..."); try { return wc.getPage("http://torn.com/index.php"); } catch (FailingHttpStatusCodeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
/** @throws Exception if the test fails */ @Test public void testConstructorWithWebResponse() throws Exception { final List<NameValuePair> emptyList = Collections.emptyList(); final WebResponseData webResponseData = new WebResponseData( ArrayUtils.EMPTY_BYTE_ARRAY, HttpStatus.SC_NOT_FOUND, "not found", emptyList); final WebResponse webResponse = new WebResponseImpl(webResponseData, URL_FIRST, HttpMethod.GET, 10); final FailingHttpStatusCodeException e = new FailingHttpStatusCodeException(webResponse); assertEquals(webResponse, e.getResponse()); assertEquals(webResponse.getStatusMessage(), e.getStatusMessage()); assertEquals(webResponse.getStatusCode(), e.getStatusCode()); assertTrue( "message doesn't contain failing url", e.getMessage().indexOf(URL_FIRST.toExternalForm()) > -1); }