Package us.monoid.web

Examples of us.monoid.web.Resty


public class RestyGoogleTest {

  @Test
  public void testGeocode() throws Exception {
    // &ll=37.815649,-122.477646
    Resty r = new Resty();
    String ggBridge = r.json("http://maps.googleapis.com/maps/api/geocode/json?latlng=37.815649,-122.477646&sensor=false").
      get("results[0].formatted_address").toString();
    System.out.println(ggBridge);
    assertTrue(ggBridge.contains("Golden Gate Bridge"));
  }
View Full Code Here


    assertTrue(ggBridge.contains("Golden Gate Bridge"));
  }
 
  @Test
  public void testStaticMap() throws Exception {
    Resty r = new Resty();
    File f = r.bytes("http://maps.google.com/maps/api/staticmap?size=512x512&maptype=hybrid" +
        "&markers=size:mid%7Ccolor:red%7C37.815649,-122.477646&sensor=false").save(File.createTempFile("google", ".png"));
    System.out.println(f.toURI());
    f.delete();
  }
View Full Code Here

   * @throws IOException
   * @throws JSONException
   */
  @Test
  public void createMultiformTest() throws IOException, JSONException {
    Resty r = new Resty();
    //TextResource text = r.text("http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echoraw.cgi",
    TextResource text = r.text("http://localhost:9998/mime/multipart",
        form(data("bubu", "lala"), data("schön", "böööh")));
    String result = text.toString();
    System.out.println(result);
    assertTrue(result.contains("bubu") && result.contains("=?ISO-8859-1?Q?sch=F6n?="));
    JSONObject json = new JSONObject();
    json.put("bubu", "lala");
    text = r.text("http://localhost:9998/mime/multipart", form(data("someJson", content(json)), data("someText", "Text")));
    result = text.toString();
    System.out.println(result);
    assertTrue(result.contains("someJson") && result.contains("application/json") && result.contains("someText"));
  }
View Full Code Here

    assertTrue(result.contains("someJson") && result.contains("application/json") && result.contains("someText"));
  }
 
  @Test
  public void testSubmitPost() throws IOException {
    Resty r = new Resty();
    String uri = ts.getBaseUri() + "mime/text";
    System.out.println("Posting to:" + uri);
    String result = r.text(uri, content("bubu")).toString();
    System.out.println(result);
  }
View Full Code Here

    System.out.println(result);
  }
 
  @Test
  public void testSubmitPut() throws IOException {
    Resty r = new Resty();
    String uri = ts.getBaseUri() + "mime/put";
    System.out.println("Put to:" + uri);
    String result = r.text(uri, put(content("bubu"))).toString();
    System.out.println(result);
  }
View Full Code Here

    System.out.println(result);
  }

  @Test
  public void testSubmitDelete() throws IOException {
    Resty r = new Resty();
    String uri = ts.getBaseUri() + "mime/delete";
    System.out.println("Delete at " + uri);
    TextResource text = r.text(uri, delete());
    String result = text.toString();
    System.out.println(result);
    assertTrue(result.equals("DELETED"));
    assertTrue(text.status(200));
  }
View Full Code Here

   * @throws IOException
   * @throws JSONException
   */
  @Test
  public void createMultiformTest() throws IOException, JSONException {
    Resty r = new Resty();
    //TextResource text = r.text("http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echoraw.cgi",
    TextResource text = r.text("http://localhost:9998/mime/multipart",
        form(data("bubu", "lala"), data("schön", "böööh")));
    String result = text.toString();
    System.out.println(result);
    assertTrue(result.contains("bubu") && result.contains("=?ISO-8859-1?Q?sch=F6n?="));
    JSONObject json = new JSONObject();
    json.put("bubu", "lala");
    text = r.text("http://localhost:9998/mime/multipart", form(data("someJson", content(json)), data("someText", "Text")));
    result = text.toString();
    System.out.println(result);
    assertTrue(result.contains("someJson") && result.contains("application/json") && result.contains("someText"));
  }
View Full Code Here

    assertTrue(result.contains("someJson") && result.contains("application/json") && result.contains("someText"));
  }
 
  @Test
  public void testSubmitPost() throws IOException {
    Resty r = new Resty();
    String uri = ts.getBaseUri() + "mime/text";
    System.out.println("Posting to:" + uri);
    String result = r.text(uri, content("bubu")).toString();
    System.out.println(result);
  }
View Full Code Here

    System.out.println(result);
  }
 
  @Test
  public void testSubmitPut() throws IOException {
    Resty r = new Resty();
    String uri = ts.getBaseUri() + "mime/put";
    System.out.println("Put to:" + uri);
    String result = r.text(uri, put(content("bubu"))).toString();
    System.out.println(result);
  }
View Full Code Here

    System.out.println(result);
  }

  @Test
  public void testSubmitDelete() throws IOException {
    Resty r = new Resty();
    String uri = ts.getBaseUri() + "mime/delete";
    System.out.println("Delete at " + uri);
    TextResource text = r.text(uri, delete());
    String result = text.toString();
    System.out.println(result);
    assertTrue(result.equals("DELETED"));
    assertTrue(text.status(200));
  }
View Full Code Here

TOP

Related Classes of us.monoid.web.Resty

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.