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 for HttpTransport.

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
  • Constructor Details

    • MockHttpTransport

      public MockHttpTransport()
    • MockHttpTransport

      protected MockHttpTransport(MockHttpTransport.Builder builder)
      Parameters:
      builder - builder
      Since:
      1.14
  • Method Details

    • 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 class HttpTransport
      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 class HttpTransport
      Parameters:
      method - HTTP method
      url - URL
      Returns:
      new low level HTTP request
      Throws:
      IOException
    • getSupportedMethods

      public final Set<String> getSupportedMethods()
      Returns the unmodifiable set of supported HTTP methods or null to specify that all methods are supported.
    • getLowLevelHttpRequest

      public final MockLowLevelHttpRequest getLowLevelHttpRequest()
      Returns the MockLowLevelHttpRequest that is associated with this MockHttpTransport.Builder, or null if no such instance exists.
      Since:
      1.18