@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); }
protected static void inject( RequestMatcher request, HttpResponse response ) { FakeHttpLayer http = Robolectric.getFakeHttpLayer(); if( !http.isInterceptingHttpRequests() ) { http.interceptHttpRequests( true ); } http.addHttpResponseRule( request, response ); }
public FakeHttpLayer getFakeHttpLayer() { return fakeHttpLayer; }
public void setFakeHttpLayer(FakeHttpLayer fakeHttpLayer) { if (fakeHttpLayer == null) { throw new IllegalArgumentException(); } this.fakeHttpLayer = fakeHttpLayer; }
public static boolean httpRequestWasMade(String uri) { return getShadowApplication().getFakeHttpLayer().hasRequestMatchingRule( new FakeHttpLayer.UriRequestMatcher(uri)); }
public static FakeHttpLayer getFakeHttpLayer() { return getShadowApplication().getFakeHttpLayer(); }
protected static void doItLive() { FakeHttpLayer http = Robolectric.getFakeHttpLayer(); http.interceptHttpRequests( false ); http.logHttpRequests(); }
protected static RequestMatcher whenRequested( String method, String uriPattern ) { return new FakeHttpLayer.UriRegexMatcher( method, uriPattern ); }