Class MockHttpTransport
java.lang.Object
com.google.api.client.http.HttpTransport
com.google.api.client.testing.http.MockHttpTransport
Beta Mock for
HttpTransport.
Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
- Since:
- 1.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MockLowLevelHttpRequestTheMockLowLevelHttpRequestto be returned bybuildRequest(String, String).private MockLowLevelHttpResponseTheMockLowLevelHttpResponseto be returned when thisMockHttpTransportexecutes the associated request.Supported HTTP methods ornullto specify that all methods are supported. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionbuildRequest(String method, String url) Builds a low level HTTP request for the given HTTP method.final MockLowLevelHttpRequestReturns theMockLowLevelHttpRequestthat is associated with thisMockHttpTransport.Builder, ornullif no such instance exists.Returns the unmodifiable set of supported HTTP methods ornullto specify that all methods are supported.booleansupportsMethod(String method) Returns whether a specified HTTP method is supported by this transport.Methods inherited from class HttpTransport
createRequestFactory, createRequestFactory, isMtls, isShutdown, shutdown
-
Field Details
-
supportedMethods
-
lowLevelHttpRequest
TheMockLowLevelHttpRequestto be returned bybuildRequest(String, String). If this field isnull,buildRequest(String, String)will create a new instance from its arguments. -
lowLevelHttpResponse
TheMockLowLevelHttpResponseto be returned when thisMockHttpTransportexecutes the associated request. Note that this field is ignored if the caller provided a non-nullMockLowLevelHttpRequestwith thisMockHttpTransportwas built.
-
-
Constructor Details
-
MockHttpTransport
public MockHttpTransport() -
MockHttpTransport
- Parameters:
builder- builder- Since:
- 1.14
-
-
Method Details
-
supportsMethod
Description copied from class:HttpTransportReturns whether a specified HTTP method is supported by this transport.Default implementation returns true if and only if the request method is
"DELETE","GET","POST", or"PUT". Subclasses should override.- Overrides:
supportsMethodin classHttpTransport- Parameters:
method- HTTP method- Throws:
IOException- I/O exception
-
buildRequest
Description copied from class:HttpTransportBuilds a low level HTTP request for the given HTTP method.- Specified by:
buildRequestin classHttpTransport- Parameters:
method- HTTP methodurl- URL- Returns:
- new low level HTTP request
- Throws:
IOException
-
getSupportedMethods
-
getLowLevelHttpRequest
Returns theMockLowLevelHttpRequestthat is associated with thisMockHttpTransport.Builder, ornullif no such instance exists.- Since:
- 1.18
-