@Test public void buildStatus() throws Exception { WebResponse webResponse = this.responseBuilder.build(); assertThat(webResponse.getStatusCode(), equalTo(200)); assertThat(webResponse.getStatusMessage(), equalTo("OK")); }
@Test public void buildStatusNotOk() throws Exception { this.response.setStatus(401); WebResponse webResponse = this.responseBuilder.build(); assertThat(webResponse.getStatusCode(), equalTo(401)); assertThat(webResponse.getStatusMessage(), equalTo("Unauthorized")); }
@Test public void buildStatusWithCustomMessage() throws Exception { this.response.sendError(401, "Custom"); WebResponse webResponse = this.responseBuilder.build(); assertThat(webResponse.getStatusCode(), equalTo(401)); assertThat(webResponse.getStatusMessage(), equalTo("Custom")); }
/** * Returns the message associated with the failing status code. * @return the message */ public String getStatusMessage() { return response_.getStatusMessage(); }
/** * Returns the message associated with the failing status code. * @return the message */ public String getStatusMessage() { return response_.getStatusMessage(); }
/** * {@inheritDoc} * The default behavior of this method is to return getStatusMessage() on the wrapped webResponse object. */ @Override public String getStatusMessage() { return wrappedWebResponse_.getStatusMessage(); }
/** * Returns the message associated with the failing status code. * @return the message */ public String getStatusMessage() { return response_.getStatusMessage(); }
/** * {@inheritDoc} * The default behavior of this method is to return getStatusMessage() on the wrapped connection object. */ public String getStatusMessage() { return wrappedWebResponse_.getStatusMessage(); }
/** * {@inheritDoc} * The default behavior of this method is to return getStatusMessage() on the wrapped connection object. */ public String getStatusMessage() { return wrappedWebResponse_.getStatusMessage(); }
/** * {@inheritDoc} * The default behavior of this method is to return getStatusMessage() on the wrapped connection object. */ public String getStatusMessage() { return wrappedWebResponse_.getStatusMessage(); }
/** * Returns the message associated with the failing status code. * @return the message */ public String getStatusMessage() { return response_.getStatusMessage(); }
/** * {@inheritDoc} * The default behavior of this method is to return getStatusMessage() on the wrapped webResponse object. */ @Override public String getStatusMessage() { return wrappedWebResponse_.getStatusMessage(); }
/** * Returns the message associated with the failing status code. * @return the message */ public String getStatusMessage() { return response_.getStatusMessage(); }
/** * Returns the string message accompanying the status code, such as "Not Found" or "OK". * @return the string message accompanying the status code */ public String jsxGet_statusText() { if (webResponse_ != null) { return webResponse_.getStatusMessage(); } LOG.error("XMLHttpRequest.statusText was retrieved before the response was available."); return null; }
/** * Returns the string message accompanying the status code, such as "Not Found" or "OK". * @return the string message accompanying the status code */ public String jsxGet_statusText() { if (webResponse_ != null) { return webResponse_.getStatusMessage(); } LOG.error("XMLHttpRequest.statusText was retrieved before the response was available."); return null; }
/** * Returns the string message accompanying the status code, such as "Not Found" or "OK". * @return the string message accompanying the status code */ public String jsxGet_statusText() { if (webResponse_ != null) { return webResponse_.getStatusMessage(); } LOG.error("XMLHttpRequest.statusText was retrieved before the response was available."); return null; }
@Test public void badRequest() throws IOException { webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setPrintContentOnFailingStatusCode(false); final HtmlPage page = webClient.getPage("http://localhost:8080/test/images/"); final WebResponse response = page.getWebResponse(); assertEquals(400, response.getStatusCode()); assertEquals("An image name is required.", response.getStatusMessage()); webClient.getOptions().setThrowExceptionOnFailingStatusCode(true); webClient.getOptions().setPrintContentOnFailingStatusCode(true); webClient.closeAllWindows(); }
new WebConnectionWrapper(webClient) { public WebResponse getResponse(WebRequest request) throws IOException { WebResponse response = super.getResponse(request); if (request.getUrl().toExternalForm().contains("Inspection.aspx")) { String content = response.getContentAsString("UTF-8"); WebResponseData data = new WebResponseData(content.getBytes("UTF-8"), response.getStatusCode(), response.getStatusMessage(), response.getResponseHeaders()); response = new WebResponse(data, request, response.getLoadTime()); } return response; } };
private static String buildMessage(final WebResponse failingResponse) { final int code = failingResponse.getStatusCode(); final String msg = failingResponse.getStatusMessage(); final URL url = failingResponse.getWebRequest().getUrl(); return code + " " + msg + " for " + url; }
private static String buildMessage(final WebResponse failingResponse) { final int code = failingResponse.getStatusCode(); final String msg = failingResponse.getStatusMessage(); final URL url = failingResponse.getWebRequest().getUrl(); return code + " " + msg + " for " + url; }