Tabnine Logo
com.android.volley.mock
Code IndexAdd Tabnine to your IDE (free)

How to use com.android.volley.mock

Best Java code snippets using com.android.volley.mock (Showing top 20 results out of 315)

origin: mcxiaoke/android-volley

@Before public void setUp() throws Exception {
  mDelivery = new MockResponseDelivery();
  mNetworkQueue = new WaitableQueue();
  mNetwork = new MockNetwork();
  mCache = new MockCache();
  mRequest = new MockRequest();
  mDispatcher = new NetworkDispatcher(mNetworkQueue, mNetwork, mCache, mDelivery);
  mDispatcher.start();
}
origin: mcxiaoke/android-volley

@Test public void cancelledRequest() throws Exception {
  mRequest.cancel();
  mCacheQueue.add(mRequest);
  mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mCache.getCalled);
  assertFalse(mDelivery.wasEitherResponseCalled());
}
origin: mcxiaoke/android-volley

@Test public void shouldCacheFalse() throws Exception {
  mRequest.setShouldCache(false);
  mNetworkQueue.add(mRequest);
  mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mCache.putCalled);
}
origin: mcxiaoke/android-volley

  @Test public void expiredCacheHit() throws Exception {
    Cache.Entry entry = CacheTestUtils.makeRandomCacheEntry(null, true, true);
    mCache.setEntryToReturn(entry);
    mCacheQueue.add(mRequest);
    mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
    assertFalse(mDelivery.wasEitherResponseCalled());
    assertTrue(mNetworkQueue.size() > 0);
    Request request = mNetworkQueue.take();
    assertSame(entry, request.getCacheEntry());
  }
}
origin: mcxiaoke/android-volley

  @Test public void shouldCacheTrue() throws Exception {
    mNetwork.setDataToReturn(CANNED_DATA);
    mRequest.setShouldCache(true);
    mRequest.setCacheKey("bananaphone");
    mNetworkQueue.add(mRequest);
    mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
    assertTrue(mCache.putCalled);
    assertNotNull(mCache.entryPut);
    assertTrue(Arrays.equals(mCache.entryPut.data, CANNED_DATA));
    assertEquals("bananaphone", mCache.keyPut);
  }
}
origin: mcxiaoke/android-volley

@Test public void connectionForPostWithBodyRequest() throws Exception {
  TestRequest.PostWithBody request = new TestRequest.PostWithBody();
  assertEquals(request.getMethod(), Method.POST);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("POST", mMockConnection.getRequestMethod());
  assertTrue(mMockConnection.getDoOutput());
}
origin: mcxiaoke/android-volley

@Test public void connectionForPutRequest() throws Exception {
  TestRequest.Put request = new TestRequest.Put();
  assertEquals(request.getMethod(), Method.PUT);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("PUT", mMockConnection.getRequestMethod());
  assertFalse(mMockConnection.getDoOutput());
}
origin: mcxiaoke/android-volley

@Test public void connectionForDeleteRequest() throws Exception {
  TestRequest.Delete request = new TestRequest.Delete();
  assertEquals(request.getMethod(), Method.DELETE);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("DELETE", mMockConnection.getRequestMethod());
  assertFalse(mMockConnection.getDoOutput());
}
origin: mcxiaoke/android-volley

@Test public void connectionForTraceRequest() throws Exception {
  TestRequest.Trace request = new TestRequest.Trace();
  assertEquals(request.getMethod(), Method.TRACE);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("TRACE", mMockConnection.getRequestMethod());
  assertFalse(mMockConnection.getDoOutput());
}
origin: mcxiaoke/android-volley

@Test public void connectionForDeprecatedPostRequest() throws Exception {
  TestRequest.DeprecatedPost request = new TestRequest.DeprecatedPost();
  assertEquals(request.getMethod(), Method.DEPRECATED_GET_OR_POST);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("POST", mMockConnection.getRequestMethod());
  assertTrue(mMockConnection.getDoOutput());
}
origin: mcxiaoke/android-volley

@Test public void connectionForPostRequest() throws Exception {
  TestRequest.Post request = new TestRequest.Post();
  assertEquals(request.getMethod(), Method.POST);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("POST", mMockConnection.getRequestMethod());
  assertFalse(mMockConnection.getDoOutput());
}
origin: mcxiaoke/android-volley

@Test public void exceptionPostsError() throws Exception {
  mNetwork.setNumExceptionsToThrow(MockNetwork.ALWAYS_THROW_EXCEPTIONS);
  mNetworkQueue.add(mRequest);
  mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mDelivery.postResponse_called);
  assertTrue(mDelivery.postError_called);
}
origin: mcxiaoke/android-volley

@Before public void setUp() throws Exception {
  mCacheQueue = new WaitableQueue();
  mNetworkQueue = new WaitableQueue();
  mCache = new MockCache();
  mDelivery = new MockResponseDelivery();
  mRequest = new MockRequest();
  mDispatcher = new CacheDispatcher(mCacheQueue, mNetworkQueue, mCache, mDelivery);
  mDispatcher.start();
}
origin: mcxiaoke/android-volley

@Test public void cacheMiss() throws Exception {
  mCacheQueue.add(mRequest);
  mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mDelivery.wasEitherResponseCalled());
  assertTrue(mNetworkQueue.size() > 0);
  Request request = mNetworkQueue.take();
  assertNull(request.getCacheEntry());
}
origin: jiangqqlmj/FastDev4Android

  @Test public void shouldCacheTrue() throws Exception {
    mNetwork.setDataToReturn(CANNED_DATA);
    mRequest.setShouldCache(true);
    mRequest.setCacheKey("bananaphone");
    mNetworkQueue.add(mRequest);
    mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
    assertTrue(mCache.putCalled);
    assertNotNull(mCache.entryPut);
    assertTrue(Arrays.equals(mCache.entryPut.data, CANNED_DATA));
    assertEquals("bananaphone", mCache.keyPut);
  }
}
origin: jiangqqlmj/FastDev4Android

@Test public void cancelledRequest() throws Exception {
  mRequest.cancel();
  mCacheQueue.add(mRequest);
  mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mCache.getCalled);
  assertFalse(mDelivery.wasEitherResponseCalled());
}
origin: jiangqqlmj/FastDev4Android

@Test public void shouldCacheFalse() throws Exception {
  mRequest.setShouldCache(false);
  mNetworkQueue.add(mRequest);
  mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mCache.putCalled);
}
origin: jiangqqlmj/FastDev4Android

@Test public void exceptionPostsError() throws Exception {
  mNetwork.setNumExceptionsToThrow(MockNetwork.ALWAYS_THROW_EXCEPTIONS);
  mNetworkQueue.add(mRequest);
  mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
  assertFalse(mDelivery.postResponse_called);
  assertTrue(mDelivery.postError_called);
}
origin: jiangqqlmj/FastDev4Android

@Before public void setUp() throws Exception {
  mDelivery = new MockResponseDelivery();
  mNetworkQueue = new WaitableQueue();
  mNetwork = new MockNetwork();
  mCache = new MockCache();
  mRequest = new MockRequest();
  mDispatcher = new NetworkDispatcher(mNetworkQueue, mNetwork, mCache, mDelivery);
  mDispatcher.start();
}
origin: jiangqqlmj/FastDev4Android

@Before public void setUp() throws Exception {
  mCacheQueue = new WaitableQueue();
  mNetworkQueue = new WaitableQueue();
  mCache = new MockCache();
  mDelivery = new MockResponseDelivery();
  mRequest = new MockRequest();
  mDispatcher = new CacheDispatcher(mCacheQueue, mNetworkQueue, mCache, mDelivery);
  mDispatcher.start();
}
com.android.volley.mock

Most used classes

  • MockCache
  • MockHttpStack
  • MockHttpURLConnection
  • MockNetwork
  • MockRequest
  • TestRequest$Delete,
  • TestRequest$DeprecatedGet,
  • TestRequest$DeprecatedPost,
  • TestRequest$Get,
  • TestRequest$Head,
  • TestRequest$Options,
  • TestRequest$Patch,
  • TestRequest$PatchWithBody,
  • TestRequest$Post,
  • TestRequest$PostWithBody,
  • TestRequest$Put,
  • TestRequest$PutWithBody,
  • TestRequest$Trace,
  • WaitableQueue
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now