Class MockHttpTransport
- java.lang.Object
-
- com.google.api.client.http.HttpTransport
-
- com.google.api.client.testing.http.MockHttpTransport
-
@Beta public class MockHttpTransport extends HttpTransport
Beta
Mock forHttpTransport
.Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
- Since:
- 1.3
- Author:
- Yaniv Inbar
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MockHttpTransport.Builder
-
Constructor Summary
Constructors Modifier Constructor Description MockHttpTransport()
protected
MockHttpTransport(MockHttpTransport.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static MockHttpTransport.Builder
builder()
Deprecated.(to be removed in the future) UseBuilder()
instead.LowLevelHttpRequest
buildRequest(String method, String url)
Builds a low level HTTP request for the given HTTP method.MockLowLevelHttpRequest
getLowLevelHttpRequest()
Returns theMockLowLevelHttpRequest
that is associated with thisMockHttpTransport.Builder
, ornull
if no such instance exists.Set<String>
getSupportedMethods()
Returns the unmodifiable set of supported HTTP methods ornull
to specify that all methods are supported.boolean
supportsMethod(String method)
Returns whether a specified HTTP method is supported by this transport.-
Methods inherited from class com.google.api.client.http.HttpTransport
createRequestFactory, createRequestFactory, shutdown
-
-
-
-
Constructor Detail
-
MockHttpTransport
public MockHttpTransport()
-
MockHttpTransport
protected MockHttpTransport(MockHttpTransport.Builder builder)
- Parameters:
builder
- builder- Since:
- 1.14
-
-
Method Detail
-
supportsMethod
public boolean supportsMethod(String method) throws IOException
Description copied from class:HttpTransport
Returns 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:
supportsMethod
in classHttpTransport
- Parameters:
method
- HTTP method- Throws:
IOException
- I/O exception
-
buildRequest
public LowLevelHttpRequest buildRequest(String method, String url) throws IOException
Description copied from class:HttpTransport
Builds a low level HTTP request for the given HTTP method.- Specified by:
buildRequest
in classHttpTransport
- Parameters:
method
- HTTP methodurl
- URL- Returns:
- new low level HTTP request
- Throws:
IOException
-
getSupportedMethods
public final Set<String> getSupportedMethods()
Returns the unmodifiable set of supported HTTP methods ornull
to specify that all methods are supported.
-
getLowLevelHttpRequest
public final MockLowLevelHttpRequest getLowLevelHttpRequest()
Returns theMockLowLevelHttpRequest
that is associated with thisMockHttpTransport.Builder
, ornull
if no such instance exists.- Since:
- 1.18
-
builder
@Deprecated public static MockHttpTransport.Builder builder()
Deprecated.(to be removed in the future) UseBuilder()
instead.Returns an instance of a new builder.- Since:
- 1.5
-
-