Class MockHttpClient

java.lang.Object
org.apache.http.impl.client.CloseableHttpClient
org.apache.http.impl.client.AbstractHttpClient
org.apache.http.impl.client.DefaultHttpClient
com.google.api.client.testing.http.apache.MockHttpClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.client.HttpClient

@Beta public class MockHttpClient extends org.apache.http.impl.client.DefaultHttpClient
Beta
Mock for HttpClient that does not actually make any network calls.

Implementation is not thread-safe.

Since:
1.14
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) int
    HTTP response code to use.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.http.client.RequestDirector
    createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, org.apache.http.conn.ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, org.apache.http.conn.ConnectionKeepAliveStrategy kastrat, org.apache.http.conn.routing.HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, org.apache.http.client.HttpRequestRetryHandler retryHandler, org.apache.http.client.RedirectHandler redirectHandler, org.apache.http.client.AuthenticationHandler targetAuthHandler, org.apache.http.client.AuthenticationHandler proxyAuthHandler, org.apache.http.client.UserTokenHandler stateHandler, org.apache.http.params.HttpParams params)
     
    final int
    Returns the HTTP response code to use.
    setResponseCode(int responseCode)
    Sets the HTTP response code to use.

    Methods inherited from class org.apache.http.impl.client.DefaultHttpClient

    createHttpParams, createHttpProcessor, setDefaultHttpParams

    Methods inherited from class org.apache.http.impl.client.AbstractHttpClient

    addRequestInterceptor, addRequestInterceptor, addResponseInterceptor, addResponseInterceptor, clearRequestInterceptors, clearResponseInterceptors, close, createAuthSchemeRegistry, createClientConnectionManager, createClientRequestDirector, createClientRequestDirector, createConnectionKeepAliveStrategy, createConnectionReuseStrategy, createCookieSpecRegistry, createCookieStore, createCredentialsProvider, createHttpContext, createHttpRequestRetryHandler, createHttpRoutePlanner, createProxyAuthenticationHandler, createProxyAuthenticationStrategy, createRedirectHandler, createRequestExecutor, createTargetAuthenticationHandler, createTargetAuthenticationStrategy, createUserTokenHandler, determineParams, doExecute, getAuthSchemes, getBackoffManager, getConnectionBackoffStrategy, getConnectionKeepAliveStrategy, getConnectionManager, getConnectionReuseStrategy, getCookieSpecs, getCookieStore, getCredentialsProvider, getHttpProcessor, getHttpRequestRetryHandler, getParams, getProxyAuthenticationHandler, getProxyAuthenticationStrategy, getRedirectHandler, getRedirectStrategy, getRequestExecutor, getRequestInterceptor, getRequestInterceptorCount, getResponseInterceptor, getResponseInterceptorCount, getRoutePlanner, getTargetAuthenticationHandler, getTargetAuthenticationStrategy, getUserTokenHandler, removeRequestInterceptorByClass, removeResponseInterceptorByClass, setAuthSchemes, setBackoffManager, setConnectionBackoffStrategy, setCookieSpecs, setCookieStore, setCredentialsProvider, setHttpRequestRetryHandler, setKeepAliveStrategy, setParams, setProxyAuthenticationHandler, setProxyAuthenticationStrategy, setRedirectHandler, setRedirectStrategy, setReuseStrategy, setRoutePlanner, setTargetAuthenticationHandler, setTargetAuthenticationStrategy, setUserTokenHandler

    Methods inherited from class org.apache.http.impl.client.CloseableHttpClient

    execute, execute, execute, execute, execute, execute, execute, execute

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • responseCode

      int responseCode
      HTTP response code to use.
  • Constructor Details

    • MockHttpClient

      public MockHttpClient()
  • Method Details

    • createClientRequestDirector

      protected org.apache.http.client.RequestDirector createClientRequestDirector(org.apache.http.protocol.HttpRequestExecutor requestExec, org.apache.http.conn.ClientConnectionManager conman, org.apache.http.ConnectionReuseStrategy reustrat, org.apache.http.conn.ConnectionKeepAliveStrategy kastrat, org.apache.http.conn.routing.HttpRoutePlanner rouplan, org.apache.http.protocol.HttpProcessor httpProcessor, org.apache.http.client.HttpRequestRetryHandler retryHandler, org.apache.http.client.RedirectHandler redirectHandler, org.apache.http.client.AuthenticationHandler targetAuthHandler, org.apache.http.client.AuthenticationHandler proxyAuthHandler, org.apache.http.client.UserTokenHandler stateHandler, org.apache.http.params.HttpParams params)
      Overrides:
      createClientRequestDirector in class org.apache.http.impl.client.AbstractHttpClient
    • getResponseCode

      public final int getResponseCode()
      Returns the HTTP response code to use.
    • setResponseCode

      public MockHttpClient setResponseCode(int responseCode)
      Sets the HTTP response code to use.