Last active
December 27, 2015 12:28
-
-
Save bsphere/7325664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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