Java 类com.android.volley.RequestQueue.RequestFinishedListener 实例源码

项目:GitHub    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:GitHub    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:GitHub    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:GitHub    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:Codeforces    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:Codeforces    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:VoV    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:VoV    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:volley    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:volley    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:InfoQ-Android-App    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:InfoQ-Android-App    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:volley-public-key-pinning    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:volley-public-key-pinning    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:device-database    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:device-database    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:ShoppingApp    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:ShoppingApp    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:Simplified-Zhihu-Daily    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:Simplified-Zhihu-Daily    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:TastySnake    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:TastySnake    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:SaveVolley    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue
 * interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override public NetworkResponse answer(InvocationOnMock invocationOnMock)
                throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:SaveVolley    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue
 * interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:Jacket-    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:Jacket-    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:AzureML_Recommend_Android    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:AzureML_Recommend_Android    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:spark-android-SDK    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:spark-android-SDK    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:proximity-manager    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:proximity-manager    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:product-emm    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:product-emm    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:product-emm    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:product-emm    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:light-novel-library_Wenku8_Android    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:light-novel-library_Wenku8_Android    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}
项目:CrossBow    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are canceled
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerCanceled() throws Exception {
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    Request request = new MockRequest();
    Answer<NetworkResponse> delayAnswer = new Answer<NetworkResponse>() {
        @Override
        public NetworkResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            Thread.sleep(200);
            return mock(NetworkResponse.class);
        }
    };
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    when(mMockNetwork.performRequest(request)).thenAnswer(delayAnswer);

    queue.addRequestFinishedListener(listener);
    queue.start();
    queue.add(request);

    request.cancel();
    verify(listener, timeout(100)).onRequestFinished(request);
    queue.stop();
}
项目:CrossBow    文件:RequestQueueIntegrationTest.java   
/**
 * Verify RequestFinishedListeners are informed when requests are successfully delivered
 *
 * Needs to be an integration test because relies on Request -> dispatcher -> RequestQueue interaction
 */
@Test public void add_requestFinishedListenerSuccess() throws Exception {
    NetworkResponse response = mock(NetworkResponse.class);
    Request request = new MockRequest();
    RequestFinishedListener listener = mock(RequestFinishedListener.class);
    RequestFinishedListener listener2 = mock(RequestFinishedListener.class);
    RequestQueue queue = new RequestQueue(new NoCache(), mMockNetwork, 1, mDelivery);

    queue.addRequestFinishedListener(listener);
    queue.addRequestFinishedListener(listener2);
    queue.start();
    queue.add(request);

    verify(listener, timeout(100)).onRequestFinished(request);
    verify(listener2, timeout(100)).onRequestFinished(request);

    queue.stop();
}