com.google.api.client.testing.http
Class MockHttpUnsuccessfulResponseHandler

java.lang.Object
  extended by com.google.api.client.testing.http.MockHttpUnsuccessfulResponseHandler
All Implemented Interfaces:
HttpUnsuccessfulResponseHandler

public class MockHttpUnsuccessfulResponseHandler
extends Object
implements HttpUnsuccessfulResponseHandler

Mock for HttpUnsuccessfulResponseHandler.

Contains an isCalled method that returns true if handleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean) is called.

Since:
1.6
Author:
Ravi Mistry

Constructor Summary
MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)
          Create an instance of MockHttpUnsuccessfulResponseHandler.
 
Method Summary
 boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry)
          Handler that will be invoked when an abnormal response is received.
 boolean isCalled()
          Returns whether the handleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean) method was called or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockHttpUnsuccessfulResponseHandler

public MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)
Create an instance of MockHttpUnsuccessfulResponseHandler.

Parameters:
successfullyHandleResponse - This will be the return value of handleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean)
Method Detail

isCalled

public boolean isCalled()
Returns whether the handleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean) method was called or not.


handleResponse

public boolean handleResponse(HttpRequest request,
                              HttpResponse response,
                              boolean supportsRetry)
                       throws IOException
Description copied from interface: HttpUnsuccessfulResponseHandler
Handler that will be invoked when an abnormal response is received. There are a few simple rules that one must follow:

Specified by:
handleResponse in interface HttpUnsuccessfulResponseHandler
Parameters:
request - Request object that can be read from for context or modified before retry
response - Response to process
supportsRetry - Whether there will actually be a retry if this handler return true. Some handlers may want to have an effect only when there will actually be a retry after they handle their event (e.g. a handler that implements exponential backoff).
Returns:
Whether or not this handler has made a change that will require the request to be re-sent.
Throws:
IOException


Copyright © 2011-2012 Google. All Rights Reserved.