protected void assertCodeMakes(
      String method,
      URI uri,
      int statusCode,
      String message,
      String contentType,
      String content,
      Class<? extends Exception> expected) {

    HttpErrorHandler function =
        Guice.createInjector(new SaxParserModule()).getInstance(getHandlerClass());

    HttpCommand command = createMock(HttpCommand.class);
    HttpRequest request = new HttpRequest(method, uri);
    HttpResponse response =
        new HttpResponse(statusCode, message, Payloads.newStringPayload(content));
    if (contentType != null) response.getPayload().getContentMetadata().setContentType(contentType);

    expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
    command.setException(classEq(expected));

    replay(command);

    function.handleError(command, response);

    verify(command);
  }
 public HttpResponseException(HttpCommand command, HttpResponse response) {
   this(
       String.format(
           "request: %s %sfailed with response: %s",
           command.getCurrentRequest().getRequestLine(),
           requestPayloadIfStringOrFormIfNotReturnEmptyString(
               (HttpRequest) command.getCurrentRequest()),
           response.getStatusLine()),
       command,
       response);
 }
 public HttpResponseException(HttpCommand command, HttpResponse response, Throwable cause) {
   this(
       String.format(
           "command: %1$s failed with response: %2$s",
           command.getCurrentRequest().getRequestLine(), response.getStatusLine()),
       command,
       response,
       cause);
 }
 public HttpResponseException(HttpCommand command, HttpResponse response, String content) {
   this(
       String.format(
           "command: %s failed with response: %s; content: [%s]",
           command.getCurrentRequest().getRequestLine(), response.getStatusLine(), content),
       command,
       response,
       content);
 }