Class MockHttpUnsuccessfulResponseHandler
- java.lang.Object
-
- com.google.api.client.testing.http.MockHttpUnsuccessfulResponseHandler
-
- All Implemented Interfaces:
HttpUnsuccessfulResponseHandler
@Beta public class MockHttpUnsuccessfulResponseHandler extends java.lang.Object implements HttpUnsuccessfulResponseHandler
Beta
Mock forHttpUnsuccessfulResponseHandler
.Contains an
isCalled
method that returns true ifhandleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean)
is called.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isCalled
private boolean
successfullyHandleResponse
-
Constructor Summary
Constructors Constructor Description MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)
Create an instance ofMockHttpUnsuccessfulResponseHandler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry)
Handler that will be invoked when an abnormal response is received.boolean
isCalled()
Returns whether thehandleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean)
method was called or not.
-
-
-
Constructor Detail
-
MockHttpUnsuccessfulResponseHandler
public MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)
Create an instance ofMockHttpUnsuccessfulResponseHandler
.- Parameters:
successfullyHandleResponse
- This will be the return value ofhandleResponse(com.google.api.client.http.HttpRequest, com.google.api.client.http.HttpResponse, boolean)
-
-
Method Detail
-
isCalled
public boolean isCalled()
Returns whether thehandleResponse(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 java.io.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:- If you modify the request object or modify its execute interceptors in a way that should resolve the error, you must return true to issue a retry.
- Do not read from the content stream, this will prevent the eventual end user from having access to it.
- Specified by:
handleResponse
in interfaceHttpUnsuccessfulResponseHandler
- Parameters:
request
- Request object that can be read from for context or modified before retryresponse
- Response to processsupportsRetry
- Whether there will actually be a retry if this handler returntrue
. 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:
java.io.IOException
-
-