public final class GoogleJsonResponseExceptionFactoryTestingBeta
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.
| Parameters | |
|---|---|
| Name | Description |
jsonFactory |
com.google.api.client.json.JsonFactorythe JSON factory that will create all JSON required by the underlying framework |
httpCode |
intthe desired HTTP error code. Note: do nut specify any codes that indicate successful completion, e.g. 2XX. |
reasonPhrase |
Stringthe HTTP reason code that explains the error. For example, if |
| Returns | |
|---|---|
| Type | Description |
GoogleJsonResponseException |
the generated GoogleJsonResponseException, as specified. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if request transport fails. |
Constructors
GoogleJsonResponseExceptionFactoryTesting()
public GoogleJsonResponseExceptionFactoryTesting()