use of org.apache.http.impl.client.DefaultRequestDirector in project robolectric by robolectric.
the class FakeHttpTest method makeRequest.
private void makeRequest(String uri) throws HttpException, IOException {
FakeHttp.addPendingHttpResponse(200, "a happy response body");
ConnectionKeepAliveStrategy connectionKeepAliveStrategy = new ConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
return 0;
}
};
DefaultRequestDirector requestDirector = new DefaultRequestDirector(null, null, null, connectionKeepAliveStrategy, null, null, null, null, null, null, null, null);
requestDirector.execute(null, new HttpGet(uri), null);
}
use of org.apache.http.impl.client.DefaultRequestDirector in project robolectric by robolectric.
the class ShadowDefaultRequestDirectorTest method shouldRecordExtendedRequestData.
@Test
public void shouldRecordExtendedRequestData() throws Exception {
FakeHttp.addPendingHttpResponse(200, "a happy response body");
HttpGet httpGet = new HttpGet("http://example.com");
requestDirector.execute(null, httpGet, null);
assertSame(FakeHttp.getSentHttpRequestInfo(0).getHttpRequest(), httpGet);
ConnectionKeepAliveStrategy strategy = shadowOf((DefaultRequestDirector) FakeHttp.getSentHttpRequestInfo(0).getRequestDirector()).getConnectionKeepAliveStrategy();
assertSame(strategy, connectionKeepAliveStrategy);
}
use of org.apache.http.impl.client.DefaultRequestDirector in project robolectric by robolectric.
the class ShadowDefaultRequestDirectorTest method setUp_EnsureStaticStateIsReset.
@Before
public void setUp_EnsureStaticStateIsReset() {
FakeHttpLayer fakeHttpLayer = FakeHttp.getFakeHttpLayer();
assertFalse(fakeHttpLayer.hasPendingResponses());
assertFalse(fakeHttpLayer.hasRequestInfos());
assertFalse(fakeHttpLayer.hasResponseRules());
connectionKeepAliveStrategy = new ConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
return 0;
}
};
requestDirector = new DefaultRequestDirector(null, null, null, connectionKeepAliveStrategy, null, null, null, null, null, null, null, null);
}
Aggregations