Beispiel #1
0
  /** Test method for {@link winterwell.jtwitter.Twitter#follow(java.lang.String)}. */
  @Test
  public void testFollowAndStopFollowing() throws InterruptedException {
    int lag = 1000; // 300000;
    Twitter tw = TwitterTest.newTestTwitter();
    tw.flush();
    List<User> friends = tw.users().getFriends();
    if (!tw.users().isFollowing("winterstein")) {
      tw.users().follow("winterstein");
      Thread.sleep(lag);
    }
    assert tw.isFollowing("winterstein") : friends;

    // Stop
    User h = tw.users().stopFollowing("winterstein");
    assert h != null;
    Thread.sleep(lag);
    assert !tw.users().isFollowing("winterstein") : friends;

    // break where no friendship exists
    User h2 = tw.users().stopFollowing("winterstein");
    assert h2 == null;

    // Follow
    tw.users().follow("winterstein");
    Thread.sleep(lag);
    assert tw.users().isFollowing("winterstein") : friends;

    try {
      User suspended = tw.users().follow("Alysha6822");
      assert false : "Trying to follow a suspended user should throw an exception";
    } catch (TwitterException e) {
    }
  }