@Test
public void testLoginWithFailure() throws IOException {
final MockWebServer server = new MockWebServer();
//On failure, the server's response code is HTTP_OK,
//but it has a "success: false" parameter.
final MockResponse response = new MockResponse();
response.setResponseCode(HttpURLConnection.HTTP_OK);
response.setBody("test nonsense failure message");
server.enqueue(response);
server.start();
final ZooniverseClient client = createZooniverseClient(server);
try {
final LoginUtils.LoginResult result = client.loginSync("testusername", "testpassword");
assertNotNull(result);
assertFalse(result.getSuccess());
} catch (final ZooniverseClient.LoginException e) {
assertTrue(e.getCause() instanceof MalformedJsonException);
}
server.shutdown();
}
ZooniverseClientTest.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:android-galaxyzoo
作者:
评论列表
文章目录