Package com.gistlabs.mechanize.document.json

Examples of com.gistlabs.mechanize.document.json.JsonDocument


  }

  @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());

    //FRAGILE TEST no longer works
    //String value = json.getRoot().find("analytics month countries#US count").getValue();
    //assertTrue(value, Integer.valueOf(value)>=1);
  }
View Full Code Here


public class AndroidJsonApiIT {

  @Test
  public void testAndroidJsonApiDemo() throws JSONException {
    Mechanize agent = new MechanizeAgent();
    JsonDocument page = (JsonDocument) agent.get("http://api.androidhive.info/contacts/");

    List<? extends JsonNode> contacts = page.getRoot().getChildren("contacts");
    assertNotNull(contacts);
    assertEquals("c200", contacts.get(0).getAttribute("id"));
  }
View Full Code Here

  }
 
  @Test
  public void testLoadJson() {
    addPageRequest("GET", "http://test.com", getClass().getResourceAsStream("dropbox.account.info.json"));
    JsonDocument page = agent().get("http://test.com");
    assertNotNull(page);
    assertEquals(JsonDocument.class, page.getClass());
  }
View Full Code Here

  }

  @Test
  public void testParseJson() {
    addPageRequest("GET", "http://test.com", getClass().getResourceAsStream("dropbox.account.info.json"));
    JsonDocument page = agent().get("http://test.com");
    assertNotNull(page.getRoot());

    assertEquals("US", page.getRoot().getAttribute("country"));

    JsonNode node = page.getRoot().find("quota_info");
    assertEquals("107374182400000", node.getAttribute("quota"));
  }
View Full Code Here

 
  @Test
  public void testTwitterJson() {
    addPageRequest("GET", "http://test.com", getClass().getResourceAsStream("twitter.json"));
    JsonDocument page = agent().get("http://test.com");
    assertNotNull(page);
    assertEquals(JsonDocument.class, page.getClass());
    List<? extends Node> users = page.findAll("user");
    assertEquals(17, users.size());
  }
View Full Code Here

TOP

Related Classes of com.gistlabs.mechanize.document.json.JsonDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.