Class GoogleJsonResponseExceptionFactoryTesting (2.7.0)

public final class GoogleJsonResponseExceptionFactoryTesting

Beta
Factory class that builds GoogleJsonResponseException instances for testing.

Inheritance

java.lang.Object > GoogleJsonResponseExceptionFactoryTesting

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.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 httpCode is 404, the reason phrase should be NOT FOUND.

Returns
Type Description
GoogleJsonResponseException

the generated GoogleJsonResponseException, as specified.

Exceptions
Type Description
IOException

if request transport fails.

Constructors

GoogleJsonResponseExceptionFactoryTesting()

public GoogleJsonResponseExceptionFactoryTesting()