HttpException extends IOException { public HttpResponse response() { return this.resp; } HttpException(final int status);   HttpException(final int status, @NotNull final String cause);   HttpException(final int status, @NotNull final Throwable cause);   HttpException(@NotNull final HttpResponse response); HttpResponse response();  }
@Test public void parsesHttpException() throws Exception { final HttpException exp = new HttpException( HttpURLConnection.HTTP_NOT_FOUND, "not found" ); MatcherAssert.assertThat( HttpResponseMocker.toString(exp.response()), Matchers.startsWith("HTTP/1.1 404 Not Found") ); }
@Test public void makesHttpResponseWithNull() throws Exception { final HttpException exp = new HttpException( HttpURLConnection.HTTP_SEE_OTHER, new IOException((String) null) ); MatcherAssert.assertThat( HttpResponseMocker.toString(exp.response()), Matchers.startsWith("HTTP/1.1 303 See Other") ); }