Example usage for org.apache.commons.httpclient HttpMethod getResponseBodyAsString

List of usage examples for org.apache.commons.httpclient HttpMethod getResponseBodyAsString

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpMethod getResponseBodyAsString.

Prototype

public abstract String getResponseBodyAsString() throws IOException;

Source Link

Usage

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_getContentsFolder() {

    try {//  ww  w .j  a  v a2 s  .c om
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get the content
    HttpMethod get_col_contents = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + CONTENTS_FOLDER + "/" + "sling:resourceType");
    try {
        client.executeMethod(get_col_contents);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_col_contents.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(REVISIONS_RESOURCE_TYPE, response_body);

}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_get_ds_custom_Folder() {

    try {//from w  w w  . j  a  v a2  s  . c  o  m
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get the content
    HttpMethod get_col_contents = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + DS_CUSTOM_FOLDER + "/" + "sling:resourceType");
    try {
        client.executeMethod(get_col_contents);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_col_contents.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(CONFIG_RESOURCE_TYPE, response_body);

}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_get_ds_custom_Prop() {

    String test_value = "test_value";

    try {//  w w w .  java 2  s . co m
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get the content
    HttpMethod get_col_contents = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + DS_CUSTOM_FOLDER + "/" + "test_prop");
    try {
        client.executeMethod(get_col_contents);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_col_contents.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(test_value, response_body);

}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_getTagsFolder() {

    try {/*from  www.  ja  va  2  s  .  c om*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    String response_body = "";
    HttpMethod get_col_tags = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + TAGS_FOLDER + "/" + "sling:resourceType");
    try {
        client.executeMethod(get_col_tags);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        response_body = get_col_tags.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(TAGS_RESOURCE_TYPE, response_body);
    get_col_tags.releaseConnection();
}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_getCatsFolder() {

    try {/*from w  w  w.  j  av  a2  s.  c  om*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get the content
    HttpMethod get_col_cats = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + CATEGORY_FOLDER + "/" + "sling:resourceType");
    try {
        client.executeMethod(get_col_cats);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_col_cats.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(CATEGORY_RESOURCE_TYPE, response_body);

}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_get_published_revision() {

    try {//from  ww w .  j  a  v a2  s  . c o m
        Thread.sleep(4000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    String response_body = "";
    HttpMethod get = new GetMethod(SLING_URL + CHANNEL_URL + channel_slug + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + "sling:resourceType");
    try {
        client.executeMethod(get);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        response_body = get.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(REVISION_RESOURCE_TYPE, response_body);
    get.releaseConnection();
}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_get_ref_content_state() {

    try {//from  www. j a v a 2s.  c o m
        Thread.sleep(6000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    String published_state = "published";
    HttpMethod get_ref_content_state = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/state");
    try {
        this.client.executeMethod(get_ref_content_state);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_ref_content_state.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(published_state, response_body);
    get_ref_content_state.releaseConnection();
}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_get_catalog_state() {

    try {/*from  w  w  w.j  ava  2s  .  c o  m*/
        Thread.sleep(6000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    String published_state = "published";
    HttpMethod get_ref_content_state = new GetMethod(
            SLING_URL + CATALOG_URL + "/" + REVISED_FOLDER + "/" + content_title + "/" + LOG_FOLDER + "/state");
    try {
        this.client.executeMethod(get_ref_content_state);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_ref_content_state.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(published_state, response_body);
    get_ref_content_state.releaseConnection();
}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

@org.junit.Test
public void test_unpublish_revision() {

    try {/*from   w w w  . jav a2  s  .  c  om*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Unpublish the content
    PostMethod post_publish = new PostMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + CONTENTS_FOLDER + "/" + content_title);
    String unpublished_dest = CHANNEL_URL + channel_slug + "/" + UNPUBLISHED_FOLDER + "/";
    post_publish.setDoAuthentication(true);

    NameValuePair[] data_publish = { new NameValuePair(":operation", "move"),
            new NameValuePair(":dest", unpublished_dest), new NameValuePair("replace", "true") };
    post_publish.setRequestBody(data_publish);
    try {
        client.executeMethod(post_publish);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    assertEquals(201, post_publish.getStatusCode());
    post_publish.releaseConnection();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get the unpublished revision in contents folder
    HttpMethod get_unpublished_revision = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + CONTENTS_FOLDER + "/" + content_title);
    try {
        client.executeMethod(get_unpublished_revision);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(404, get_unpublished_revision.getStatusCode());
    get_unpublished_revision.releaseConnection();

    // Get the unpublished revision in unpublished folder
    get_unpublished_revision = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + UNPUBLISHED_FOLDER + "/" + content_title);
    try {
        client.executeMethod(get_unpublished_revision);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(200, get_unpublished_revision.getStatusCode());
    get_unpublished_revision.releaseConnection();

    try {
        Thread.sleep(6000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    String unpublished_state = "unpublished";
    HttpMethod get_ref_content_state = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/state");
    try {
        this.client.executeMethod(get_ref_content_state);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_ref_content_state.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(unpublished_state, response_body);
    get_ref_content_state.releaseConnection();
}

From source file:org.iavante.sling.gad.channel.ChannelServiceIT.java

/**
 * Tests for tags postprocessing/*  www .  ja  v  a2  s.c  om*/
 */
public void test_getTagsChannel() {

    try {
        Thread.sleep(4000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get the channel tags
    HttpMethod get_col_tag1 = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + TAGS_FOLDER + "/" + tag1_slug + "/title");
    try {
        this.client.executeMethod(get_col_tag1);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_col_tag1.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(tag1_title, response_body);
    get_col_tag1.releaseConnection();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    // Get the collection tags
    HttpMethod get_col_tag2 = new GetMethod(
            SLING_URL + CHANNEL_URL + channel_slug + "/" + TAGS_FOLDER + "/" + tag2_slug + "/title");
    try {
        this.client.executeMethod(get_col_tag2);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    try {
        response_body = get_col_tag2.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    assertEquals(tag2_title, response_body);
    get_col_tag2.releaseConnection();
}