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      private final HttpClientConnectionManager mockConnectionManager;
12      private final HttpRequestExecutor mockRequestExecutor;
13  
14  
15      public HttpClientWithMockConnectionRequestFactory(final HttpClientConnectionManager mockConnectionManager, final HttpRequestExecutor mockRequestExecutor) {
16          this.mockConnectionManager = mockConnectionManager;
17          this.mockRequestExecutor = mockRequestExecutor;
18      }
19  
20      protected HttpRequestExecutor getRequestExecutor() {
21          return mockRequestExecutor;
22      }
23  
24      /**
25       * This mocks out the connection, so we don't actually need a running server
26       *
27       * @return
28       */
29      @Override
30      protected HttpClientConnectionManager getConnectionManager() {
31          return mockConnectionManager;
32      }
33  
34  }