Package us.monoid.web

Examples of us.monoid.web.Resty$Option


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

  static {
    System.setProperty("content.types.user.table","src/test/java/us/monoid/web/mimecap.properties");
  }
  @Test
  public void sampleUse() throws Exception {
    Resty r = new Resty();
    assertEquals(r.json("file:src/test/java/us/monoid/web/test.json").json(path("key.subkey")).object().getInt("secret"), 42);
  }
View Full Code Here

    assertEquals(r.json("file:src/test/java/us/monoid/web/test.json").json(path("key.subkey")).object().getInt("secret"), 42);
  }

  @Test
  public void geoNames() throws Exception {
    Resty r = new Resty();
    Object name = r.json("http://ws.geonames.org/postalCodeLookupJSON?postalcode=66780&country=DE").get("postalcodes[0].placeName");
    assertEquals(name, "Rehlingen-Siersburg");
  }
View Full Code Here

TOP

Related Classes of us.monoid.web.Resty$Option

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.