@Override
  protected int checkResponse(URI uri, ClientResponse response) {
    ClientResponse.Status status = response.getClientResponseStatus();
    int errorCode = status.getStatusCode();
    if (errorCode >= 300) {
      JSONObject obj = null;
      int code = 0;
      try {
        obj = response.getEntity(JSONObject.class);
        code = obj.getInt(ScaleIOConstants.ERROR_CODE);
      } catch (Exception e) {
        log.error("Parsing the failure response object failed", e);
      }

      if (code == 404 || code == 410) {
        throw ScaleIOException.exceptions.resourceNotFound(uri.toString());
      } else if (code == 401) {
        throw ScaleIOException.exceptions.authenticationFailure(uri.toString());
      } else {
        throw ScaleIOException.exceptions.internalError(uri.toString(), obj.toString());
      }
    } else {
      return errorCode;
    }
  }
 public void testUser(String userName, ClientResponse.Status expectedStatus, String expectedResult)
     throws Exception {
   Client webClient = Client.create();
   webClient.addFilter(new HTTPBasicAuthFilter(userName, generalPassword));
   WebResource webResource =
       webClient.resource(
           new URI(contextUri(scheduler().injector()) + "/jobscheduler/engine-cpp/command"));
   ClientResponse response = webResource.post(ClientResponse.class, xmlCommand);
   assertThat(response.getStatus(), equalTo(expectedStatus.getStatusCode()));
   assertThat(response.getEntity(String.class), containsString(expectedResult));
   webClient.destroy();
 }