public final class GoogleJsonResponseExceptionFactoryTesting
Beta
Factory class that builds GoogleJsonResponseException instances for testing.
Static Methods
newMock(JsonFactory jsonFactory, int httpCode, String reasonPhrase)
public static GoogleJsonResponseException newMock(JsonFactory jsonFactory, int httpCode, String reasonPhrase)
Convenience factory method that builds a GoogleJsonResponseException from its arguments. The method builds a dummy HttpRequest and HttpResponse, sets the response's status to a user-specified HTTP error code, suppresses exceptions, and executes the request. This forces the underlying framework to create, but not throw, a GoogleJsonResponseException, which the method retrieves and returns to the invoker.
Name | Description |
jsonFactory | com.google.api.client.json.JsonFactory the JSON factory that will create all JSON required by the underlying framework |
httpCode | int the desired HTTP error code. Note: do nut specify any codes that indicate successful completion, e.g. 2XX. |
reasonPhrase | String the HTTP reason code that explains the error. For example, if |
Type | Description |
GoogleJsonResponseException | the generated GoogleJsonResponseException, as specified. |
Type | Description |
IOException | if request transport fails. |
Constructors
GoogleJsonResponseExceptionFactoryTesting()
public GoogleJsonResponseExceptionFactoryTesting()