/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */ protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler stateHandler, HttpParams params ) { return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler, stateHandler, params); }
public void __constructor__( HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params) { __constructor__( LogFactory.getLog(DefaultRequestDirector.class), requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler, userTokenHandler, params); }
@Before public void setUp_EnsureStaticStateIsReset() { FakeHttpLayer fakeHttpLayer = Robolectric.getFakeHttpLayer(); assertFalse(fakeHttpLayer.hasPendingResponses()); assertFalse(fakeHttpLayer.hasRequestInfos()); assertFalse(fakeHttpLayer.hasResponseRules()); assertNull(fakeHttpLayer.getDefaultResponse()); 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); }
@Test public void shouldRecordExtendedRequestData() throws Exception { Robolectric.addPendingHttpResponse(200, "a happy response body"); HttpGet httpGet = new HttpGet("http://example.com"); requestDirector.execute(null, httpGet, null); assertSame(Robolectric.getSentHttpRequestInfo(0).getHttpRequest(), httpGet); ConnectionKeepAliveStrategy strategy = shadowOf((DefaultRequestDirector) Robolectric.getSentHttpRequestInfo(0).getRequestDirector()).getConnectionKeepAliveStrategy(); assertSame(strategy, connectionKeepAliveStrategy); }
private void makeRequest(String uri) throws HttpException, IOException { Robolectric.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); }
public void __constructor__( Log log, HttpRequestExecutor requestExec, ClientConnectionManager conman, ConnectionReuseStrategy reustrat, ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor, HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler, AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler, UserTokenHandler userTokenHandler, HttpParams params) { this.log = log; this.httpRequestExecutor = requestExec; this.connectionManager = conman; this.connectionReuseStrategy = reustrat; this.connectionKeepAliveStrategy = kastrat; this.httpRoutePlanner = rouplan; this.httpProcessor = httpProcessor; this.httpRequestRetryHandler = retryHandler; this.redirectHandler = redirectHandler; this.targetAuthenticationHandler = targetAuthHandler; this.proxyAuthenticationHandler = proxyAuthHandler; this.userTokenHandler = userTokenHandler; this.httpParams = params; try { redirector = new org.robolectric.tester.org.apache.http.impl.client.DefaultRequestDirector( log, requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler, userTokenHandler, params ); } catch (IllegalArgumentException ignored) { Robolectric.getFakeHttpLayer().interceptHttpRequests(true); } }
public static ShadowDefaultRequestDirector shadowOf(DefaultRequestDirector instance) { return (ShadowDefaultRequestDirector) shadowOf_(instance); }