Package us.monoid.web

Examples of us.monoid.web.Resty


   *
   *
   * @return {@link Resty} that will be used to perform all requests to Auth0
   */
  protected Resty createResty() {
    return new Resty();
  }
View Full Code Here


            ActorRef zipResourceFetcher = getContext().actorFor("/user/ckanZipResourceFetcher");

            String url = (String) message;

            try {
                String response = new Resty().text(url).toString();
                Metadata metadata = new Gson().fromJson(response, Metadata.class);

                metadataPersist.tell(metadata, getSelf());

                for(MetadataResource resource : metadata.resources) {
View Full Code Here

        if(message instanceof ListAll) {

            final String url = ConfigFactory.load().getString("restopengov.ckan-rest-api");

            try {
                String response = new Resty().text(url).toString();

                Type listType = new TypeToken<ArrayList<String>>() {}.getType();
                List<String> datasetList = new Gson().fromJson(response, listType);

                for(String dataset : datasetList) {
                    System.out.println(dataset);
                }

                getContext().system().shutdown();

            } catch (Exception e) {
                e.printStackTrace();
            }

        } else if(message instanceof FetchAll) {

            final String url = ConfigFactory.load().getString("restopengov.ckan-rest-api");

            try {
                String response = new Resty().text(url).toString();

                Type listType = new TypeToken<ArrayList<String>>() {}.getType();
                List<String> datasetList = new Gson().fromJson(response, listType);

                getSelf().tell(datasetList);
View Full Code Here

public class RestyXmlTest {

  @Test
  public void testXml() throws Exception {
    Resty r = new Resty();
    NodeList nl = r.xml("http://rss.slashdot.org/Slashdot/slashdotGamesatom").get("feed/entry/link");
    assertNotNull(nl);
    for (int i = 0, len = nl.getLength(); i < len; i++) {
      System.out.println(((Element)nl.item(i)).getAttribute("href"));
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testXml2Text() throws Exception {
    Resty r = new Resty();
    String text = r.xml("http://rss.slashdot.org/Slashdot/slashdotDevelopersatom").toString();
    System.out.println(text);
    assertTrue(text.contains("Slashdot: Developers"));
  }
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

public class RestyXmlTest {

  @Test
  public void testXml() throws Exception {
    Resty r = new Resty();
    NodeList nl = r.xml("http://rss.slashdot.org/Slashdot/slashdotGamesatom").get("feed/entry/link");
    assertNotNull(nl);
    for (int i = 0, len = nl.getLength(); i < len; i++) {
      System.out.println(((Element)nl.item(i)).getAttribute("href"));
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testXml2Text() throws Exception {
    Resty r = new Resty();
    String text = r.xml("http://rss.slashdot.org/Slashdot/slashdotDevelopersatom").toString();
    System.out.println(text);
    assertTrue(text.contains("Slashdot: Developers"));
  }
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

    public void shouldAllowConnectionToResourceWhereCertAndHostnameAreInvalidButWhenIgnoreAllCertsIsSet() throws Exception {
        startServer("us/monoid/web/ssl/test-ssl-hostname-eq-site.com.keystore");

        Resty.ignoreAllCerts();

        Resty resty = new Resty();

        TextResource response = resty.text(String.format("https://localhost:%d%s", getPort(), HelloWorldTestResource.HELLO_WORLD_PATH));

        assertThat(response.toString(), equalTo(HelloWorldTestResource.HELLO_WORLD));
    }
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.