コード例 #1
0
  @Test
  public void testGoogleApi() throws JSONException {
    MechanizeAgent agent = new MechanizeAgent();
    JsonDocument json =
        agent.doRequest(googleUrl).add("shortUrl", shortUrl).add("projection", "FULL").get();
    // String debug = json.asString();

    assertEquals(longUrl, json.getRoot().find("longUrl").getValue());

    String value = json.getRoot().find("analytics month countries#US count").getValue();
    assertTrue(value, Integer.valueOf(value) >= 1);
  }
コード例 #2
0
 @Test
 public void testShortUrl() throws JSONException {
   MechanizeAgent agent = new MechanizeAgent();
   HtmlDocument html = agent.get(shortUrl);
   assertEquals(longUrl, html.getUri());
 }