FileDocCategorySizeDatePackage
BasicNetworkTest.javaAPI DocAndroid 5.1 API2798Thu Mar 12 22:22:56 GMT 2015com.android.volley.toolbox

BasicNetworkTest

public class BasicNetworkTest extends android.test.AndroidTestCase

Fields Summary
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        mContext = getContext();
    
public voidtestHeadersAndPostParams()

        MockHttpStack mockHttpStack = new MockHttpStack();
        BasicHttpResponse fakeResponse = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1),
                200, "OK");
        fakeResponse.setEntity(new StringEntity("foobar"));
        mockHttpStack.setResponseToReturn(fakeResponse);
        BasicNetwork httpNetwork = new BasicNetwork(mockHttpStack);
        Request<String> request = new Request<String>(Request.Method.GET, "http://foo", null) {

            @Override
            protected Response<String> parseNetworkResponse(NetworkResponse response) {
                return null;
            }

            @Override
            protected void deliverResponse(String response) {
            }

            @Override
            public Map<String, String> getHeaders() {
                Map<String, String> result = new HashMap<String, String>();
                result.put("requestheader", "foo");
                return result;
            }

            @Override
            public Map<String, String> getParams() {
                Map<String, String> result = new HashMap<String, String>();
                result.put("requestpost", "foo");
                return result;
            }
        };
        httpNetwork.performRequest(request);
        assertEquals("foo", mockHttpStack.getLastHeaders().get("requestheader"));
        assertEquals("requestpost=foo&", new String(mockHttpStack.getLastPostBody()));