Class MockHttpClient

  • All Implemented Interfaces:
    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
    • Constructor Summary

      Constructors

      Constructor and Description
      MockHttpClient()
       
    • Method Summary

      Modifier and Type Method and 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)
       
      int getResponseCode()
      Returns the HTTP response code to use.
      MockHttpClient setResponseCode(int responseCode)
      Sets the HTTP response code to use.
      • Methods inherited from class org.apache.http.impl.client.DefaultHttpClient

        createAuthSchemeRegistry, createClientConnectionManager, createConnectionKeepAliveStrategy, createConnectionReuseStrategy, createCookieSpecRegistry, createCookieStore, createCredentialsProvider, createHttpContext, createHttpParams, createHttpProcessor, createHttpRequestRetryHandler, createHttpRoutePlanner, createProxyAuthenticationHandler, createRedirectHandler, createRequestExecutor, createTargetAuthenticationHandler, createUserTokenHandler
      • Methods inherited from class org.apache.http.impl.client.AbstractHttpClient

        addRequestInterceptor, addRequestInterceptor, addResponseInterceptor, addResponseInterceptor, clearRequestInterceptors, clearResponseInterceptors, determineParams, execute, execute, execute, execute, execute, execute, execute, execute, getAuthSchemes, getConnectionKeepAliveStrategy, getConnectionManager, getConnectionReuseStrategy, getCookieSpecs, getCookieStore, getCredentialsProvider, getHttpProcessor, getHttpRequestRetryHandler, getParams, getProxyAuthenticationHandler, getRedirectHandler, getRequestExecutor, getRequestInterceptor, getRequestInterceptorCount, getResponseInterceptor, getResponseInterceptorCount, getRoutePlanner, getTargetAuthenticationHandler, getUserTokenHandler, removeRequestInterceptorByClass, removeResponseInterceptorByClass, setAuthSchemes, setCookieSpecs, setCookieStore, setCredentialsProvider, setHttpRequestRetryHandler, setKeepAliveStrategy, setParams, setProxyAuthenticationHandler, setRedirectHandler, setReuseStrategy, setRoutePlanner, setTargetAuthenticationHandler, setUserTokenHandler
    • Constructor Detail

      • MockHttpClient

        public MockHttpClient()
    • Method Detail

      • 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)
      • 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.