112fe960436852d05ef79837a462e6132b2e50c8aJan Berkelpackage com.xtremelabs.robolectric.shadows;
212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
312fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport com.xtremelabs.robolectric.Robolectric;
412fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport com.xtremelabs.robolectric.internal.Implementation;
512fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport com.xtremelabs.robolectric.internal.Implements;
612fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport com.xtremelabs.robolectric.internal.RealObject;
712fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.HttpHost;
812fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.HttpRequest;
912fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.HttpResponse;
1012fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.client.ClientProtocolException;
1112fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.client.HttpClient;
1212fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.client.ResponseHandler;
1312fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.client.methods.HttpUriRequest;
1412fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.conn.ClientConnectionManager;
1512fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.impl.client.DefaultHttpClient;
1612fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.params.HttpParams;
1712fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport org.apache.http.protocol.HttpContext;
1812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
1912fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport android.content.Context;
2012fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport android.net.http.AndroidHttpClient;
2112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
2212fe960436852d05ef79837a462e6132b2e50c8aJan Berkelimport java.io.IOException;
2312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
2412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel@Implements(AndroidHttpClient.class)
2512fe960436852d05ef79837a462e6132b2e50c8aJan Berkelpublic class ShadowAndroidHttpClient {
2612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @RealObject private AndroidHttpClient client;
2712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
2812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    private HttpClient httpClient = new DefaultHttpClient();
2912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
3012fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
3112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public static AndroidHttpClient newInstance(String userAgent) {
3212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return Robolectric.newInstanceOf(AndroidHttpClient.class);
3312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
3412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
3512fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
3612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public static AndroidHttpClient newInstance(String userAgent, Context context) {
3712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return Robolectric.newInstanceOf(AndroidHttpClient.class);
3812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
3912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
4012fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
4112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public HttpParams getParams() {
4212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.getParams();
4312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
4412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
4512fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
4612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public ClientConnectionManager getConnectionManager() {
4712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.getConnectionManager();
4812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
4912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
5012fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
5112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public HttpResponse execute(HttpUriRequest httpUriRequest) throws IOException, ClientProtocolException {
5212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpUriRequest);
5312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
5412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
5512fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
5612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public HttpResponse execute(HttpUriRequest httpUriRequest, HttpContext httpContext) throws IOException, ClientProtocolException {
5712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpUriRequest, httpContext);
5812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
5912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
6012fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
6112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public HttpResponse execute(HttpHost httpHost, HttpRequest httpRequest) throws IOException, ClientProtocolException {
6212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpHost, httpRequest);
6312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
6412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
6512fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
6612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public HttpResponse execute(HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext) throws IOException, ClientProtocolException {
6712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpHost, httpRequest, httpContext);
6812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
6912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
7012fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
7112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public <T> T execute(HttpUriRequest httpUriRequest, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException {
7212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpUriRequest, responseHandler);
7312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
7412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
7512fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
7612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public <T> T execute(HttpUriRequest httpUriRequest, ResponseHandler<? extends T> responseHandler, HttpContext httpContext) throws IOException, ClientProtocolException {
7712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpUriRequest, responseHandler, httpContext);
7812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
7912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
8012fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
8112fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public <T> T execute(HttpHost httpHost, HttpRequest httpRequest, ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException {
8212fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpHost, httpRequest, responseHandler);
8312fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
8412fe960436852d05ef79837a462e6132b2e50c8aJan Berkel
8512fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    @Implementation
8612fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    public <T> T execute(HttpHost httpHost, HttpRequest httpRequest, ResponseHandler<? extends T> responseHandler, HttpContext httpContext) throws IOException, ClientProtocolException {
8712fe960436852d05ef79837a462e6132b2e50c8aJan Berkel        return httpClient.execute(httpHost, httpRequest, responseHandler, httpContext);
8812fe960436852d05ef79837a462e6132b2e50c8aJan Berkel    }
8912fe960436852d05ef79837a462e6132b2e50c8aJan Berkel}
90