FileDocCategorySizeDatePackage
ResponseDeliveryTest.javaAPI DocAndroid 5.1 API2325Thu Mar 12 22:22:56 GMT 2015com.android.volley

ResponseDeliveryTest

public class ResponseDeliveryTest extends TestCase

Fields Summary
private ExecutorDelivery
mDelivery
private com.android.volley.mock.MockRequest
mRequest
private Response
mSuccessResponse
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();

        // Make the delivery just run its posted responses immediately.
        mDelivery = new ImmediateResponseDelivery();
        mRequest = new MockRequest();
        mRequest.setSequence(1);
        byte[] data = new byte[16];
        Cache.Entry cacheEntry = CacheTestUtils.makeRandomCacheEntry(data);
        mSuccessResponse = Response.success(data, cacheEntry);
    
public voidtestPostError_callsDeliverError()

        Response<byte[]> errorResponse = Response.error(new ServerError());

        mDelivery.postResponse(mRequest, errorResponse);
        assertTrue(mRequest.deliverError_called);
        assertFalse(mRequest.deliverResponse_called);
    
public voidtestPostResponse_callsDeliverResponse()

        mDelivery.postResponse(mRequest, mSuccessResponse);
        assertTrue(mRequest.deliverResponse_called);
        assertFalse(mRequest.deliverError_called);
    
public voidtestPostResponse_suppressesCanceled()

        mRequest.cancel();
        mDelivery.postResponse(mRequest, mSuccessResponse);
        assertFalse(mRequest.deliverResponse_called);
        assertFalse(mRequest.deliverError_called);