TokenUploadHandler extends JsonHttpResponseHandler { @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { String responseString = null; if (errorResponse != null) { responseString = errorResponse.toString(); } onFailure(statusCode, responseString); } TokenUploadHandler(Context context, RegistrationListenerStack listenerStack); @Override void onSuccess(int statusCode, Header[] headers, JSONObject response); @Override void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse); @Override void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable);  }
@Test public void onFailure() throws Exception { uploadHandler.onFailure(500, null, "internal server error :(", null); verify(stack).onFailedRegistration(500, "internal server error :("); }