Last week Eric Denman and I did some long-distance pairing on MockWebServer. If you haven't used it, this is what it looks in your code:
// 1. Enqueue a response.
MockWebServer server = new MockWebServer();
server.enqueue(new MockResponse().setBody("spicy salsa"));
server.play();
// 2. Make a request that retrieves that response.
URL url = server.getUrl("/tacos");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
assertEquals(HTTP_OK, connection.getResponseCode());
assertEquals("spicy salsa", readLine(connection.getInputStream()));
// 3. Validate the request.
RecordedRequest request = server.takeRequest();
assertEquals("GET /tacos HTTP/1.1", request.getRequestLine());
server.shutdown();
We added a feature that lets you control how incoming requests are dispatched. This is very powerful for testing Android apps!