FileDocCategorySizeDatePackage
MockNetwork.javaAPI DocAndroid 5.1 API1883Thu Mar 12 22:22:56 GMT 2015com.android.volley.mock

MockNetwork

public class MockNetwork extends Object implements com.android.volley.Network

Fields Summary
public static final int
ALWAYS_THROW_EXCEPTIONS
private int
mNumExceptionsToThrow
private byte[]
mDataToReturn
public com.android.volley.Request
requestHandled
Constructors Summary
Methods Summary
public com.android.volley.NetworkResponseperformRequest(com.android.volley.Request request)


    
          
        if (mNumExceptionsToThrow > 0 || mNumExceptionsToThrow == ALWAYS_THROW_EXCEPTIONS) {
            if (mNumExceptionsToThrow != ALWAYS_THROW_EXCEPTIONS) {
                mNumExceptionsToThrow--;
            }
            throw new ServerError();
        }

        requestHandled = request;
        return new NetworkResponse(mDataToReturn);
    
public voidsetDataToReturn(byte[] data)

        mDataToReturn = data;
    
public voidsetNumExceptionsToThrow(int numExceptionsToThrow)

param
numExceptionsToThrow number of times to throw an exception or {@link #ALWAYS_THROW_EXCEPTIONS}


                     
        
        mNumExceptionsToThrow = numExceptionsToThrow;