コード例 #1
0
  public void testEmptyJSON() throws Exception {
    HttpClientImpl http = new HttpClientImpl();

    // empty User list
    List<User> users =
        UserJSONImpl.createUserList(
            http.get("http://twitter4j.org/en/testcases/statuses/friends/T4J_hudson.json"), conf);
    Assert.assertTrue(users.size() == 0);
    assertDeserializedFormIsEqual(users);

    // empty Status list
    List<Status> statuses =
        StatusJSONImpl.createStatusList(
            http.get("http://twitter4j.org/en/testcases/statuses/friends/T4J_hudson.json"), conf);
    Assert.assertTrue(statuses.size() == 0);
    assertDeserializedFormIsEqual(statuses);

    // empty DirectMessages list
    List<DirectMessage> directMessages =
        DirectMessageJSONImpl.createDirectMessageList(
            http.get("http://twitter4j.org/en/testcases/statuses/friends/T4J_hudson.json"), conf);
    Assert.assertTrue(directMessages.size() == 0);
    assertDeserializedFormIsEqual(directMessages);

    // empty Trends list
    List<Trends> trends =
        TrendsJSONImpl.createTrendsList(
            http.get("http://twitter4j.org/en/testcases/trends/daily-empty.json"),
            conf.isJSONStoreEnabled());
    Assert.assertTrue(trends.size() == 0);
    assertDeserializedFormIsEqual(trends);
  }
コード例 #2
0
 public void testDirectMessagesAsJSON() throws Exception {
   HttpClientImpl http = new HttpClientImpl();
   List<DirectMessage> directMessages =
       DirectMessageJSONImpl.createDirectMessageList(
           http.get("http://twitter4j.org/en/testcases/direct_messages.json"), conf);
   DirectMessage dm = directMessages.get(0);
   Assert.assertEquals(new java.util.Date(1248177356000l), dm.getCreatedAt());
   Assert.assertEquals(6358482, dm.getRecipient().getId());
   Assert.assertEquals(246928323, dm.getId());
   Assert.assertEquals(6358482, dm.getRecipientId());
   Assert.assertEquals("twit4j", dm.getRecipientScreenName());
   Assert.assertEquals(6377362, dm.getSender().getId());
   Assert.assertEquals(6377362, dm.getSenderId());
   Assert.assertEquals("twit4j2", dm.getSenderScreenName());
   Assert.assertEquals("Tue Jul 21 20:55:39 KST 2009:directmessage test", dm.getText());
   assertDeserializedFormIsEqual(directMessages);
 }