View Javadoc

1   package com.atlassian.sal.core.net;
2   
3   import org.apache.http.conn.HttpClientConnectionManager;
4   import org.apache.http.protocol.HttpRequestExecutor;
5   
6   /**
7    * This class enables testing our code end-to-end, without HttpClient needing a server to test against
8    */
9   public class HttpClientWithMockConnectionRequestFactory extends HttpClientRequestFactory
10  {
11  
12      private final HttpClientConnectionManager mockConnectionManager;
13      private final HttpRequestExecutor mockRequestExecutor;
14  
15  
16      public HttpClientWithMockConnectionRequestFactory(final HttpClientConnectionManager mockConnectionManager, final HttpRequestExecutor mockRequestExecutor)
17      {
18          this.mockConnectionManager = mockConnectionManager;
19          this.mockRequestExecutor = mockRequestExecutor;
20      }
21  
22      protected HttpRequestExecutor getRequestExecutor()
23      {
24          return mockRequestExecutor;
25      }
26  
27      /**
28       * This mocks out the connection, so we don't actually need a running server
29       * @return
30       */
31      @Override
32      protected HttpClientConnectionManager getConnectionManager()
33      {
34          return mockConnectionManager;
35      }
36  
37  }