Skip to content

Instantly share code, notes, and snippets.

@bsphere
Last active December 27, 2015 12:28
Show Gist options
  • Save bsphere/7325664 to your computer and use it in GitHub Desktop.
Save bsphere/7325664 to your computer and use it in GitHub Desktop.
public class MyHTTPClientTest extends AndroidTestCase {
private MockWebServer mServer;
private MyHTTPClient mClient;
public void setUp() throws Exception {
mServer = new MockWebServer();
mServer.play();
mClient = new MyHTTPClient(mServer.getUrl("/"));
}
public void tearDown() throws Exception {
mServer.shutdown();
}
public void testGetString() throws Exception {
mServer.enqueue(new MockResponse().setResponseCode(200).setBody("myString"));
String str = mClient.getString();
RecordedRequest req = mServer.takeRequest();
assertEquals("/string", req.getPath());
assertEquals("GET", req.getMethod());
assertNotNull(str);
assertEquals("myString", str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment