Package com.gistlabs.mechanize.impl

Examples of com.gistlabs.mechanize.impl.MechanizeAgent


*/
public class GoogleSearchForMechanizeJavaIT {

  @Test
  public void testGooglePageSearchForm() {
    Mechanize agent = new MechanizeAgent();
    AbstractDocument page = agent.get("http://www.google.com");
    Form form = page.form("f");
    form.get("q").set("mechanize java");
    Resource response = form.submit();
    assertTrue(response.getTitle().startsWith("mechanize java"));
  }
View Full Code Here


  String shortUrl = "http://goo.gl/daal8";
  String longUrl = "http://gistlabs.com/software/mechanize-for-java/";

  @Test
  public void testShortUrl() throws JSONException {
    Mechanize agent = new MechanizeAgent();
    HtmlDocument html = agent.get(shortUrl);
    assertEquals(longUrl, html.getUri());
  }
View Full Code Here

    assertEquals(longUrl, html.getUri());
  }

  @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
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

TOP

Related Classes of com.gistlabs.mechanize.impl.MechanizeAgent

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.