ZooniverseClientTest.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:android-galaxyzoo 作者:
@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();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号