Package us.monoid.web

Examples of us.monoid.web.Resty.json()


  @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


    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);
  }

  @Test
  public void geoNames() throws Exception {
    Resty r = new Resty();
View Full Code Here

  }

  @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");
  }
 
  @Test
  public void formDataGet() throws Exception {
View Full Code Here

    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);
  }

  @Test
  public void geoNames() throws Exception {
    Resty r = new Resty();
View Full Code Here

  }

  @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");
  }
 
  @Test
  public void formDataGet() throws Exception {
View Full Code Here

      json.put("client_secret", properties.get("auth0.client_secret"));
      json.put("redirect_uri", req.getRequestURL().toString());
      json.put("grant_type", "authorization_code");
      json.put("code", authorizationCode);

      JSONResource tokenInfo = resty.json(tokenUri, content(json));
      return new Tokens(tokenInfo.toObject());

    } catch (Exception ex) {
      throw new IllegalStateException("Cannot get Token from Auth0", ex);
    }
View Full Code Here

    Resty resty = createResty();

    String userInfoUri = getUserInfoUri(tokens.getAccessToken());

    try {
      JSONResource json = resty.json(userInfoUri);
      return new Auth0User(json.toObject());
    } catch (Exception ex) {
      throw new IllegalStateException("Cannot get User from Auth0", ex);
    }
  }
View Full Code Here

  /** Getting the Google Developer calendar feed as JSON and following to the first entry, which is an XML resource:
*/
  @Test
  public void jsonToXml() throws Exception {
    Resty r = new Resty();
    String title = r.json("http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json").
      xml(path("feed.entry[0].id.$t")).get("entry/title/text()", String.class);
    assertNotNull(title);
    System.out.println(title);
  }
}
View Full Code Here

  /** Getting the Google Developer calendar feed as JSON and following to the first entry, which is an XML resource:
*/
  @Test
  public void jsonToXml() throws Exception {
    Resty r = new Resty();
    String title = r.json("http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json").
      xml(path("feed.entry[0].id.$t")).get("entry/title/text()", String.class);
    assertNotNull(title);
    System.out.println(title);
  }
}
View Full Code Here

    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(getClass().getResource("test.json").toString()).json(path("key.subkey")).object().getInt("secret"), 42);
  }

//  @Test
//  public void geoNames() throws Exception {
//    Resty r = new Resty();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.