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.catalog.CatalogValidationFilterIT.java

public void test_revision_created() {

    String revision_resource_type = "gad/revision";

    try {/*w w w.j a v  a 2  s. c  o m*/
        Thread.sleep(5000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get source test not present in schema    
    HttpMethod get_revision = new GetMethod(
            SLING_URL + CATALOG_URL + PENDING_FOLDER + "/" + content_title + "/sling:resourceType");
    System.out.println("Get revision" + SLING_URL + CATALOG_URL + PENDING_FOLDER + "/" + content_title);
    try {
        client.executeMethod(get_revision);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // handle response.   
    String res_resource_type = "";
    try {
        res_resource_type = get_revision.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Response: " + res_resource_type);

    assertEquals(res_resource_type, revision_resource_type);
    get_revision.releaseConnection();

}

From source file:org.iavante.sling.gad.catalog.DenyRevisionServiceIT.java

public void test_denied_created() {

    System.out.println("TEST Denied Revision created");
    String revision_resource_type = "gad/revision";

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

    // Get source test not present in schema
    HttpMethod get_revision = new GetMethod(
            SLING_URL + CATALOG_URL + DENIED_FOLDER + "/" + content_title + "/sling:resourceType");
    System.out.println(SLING_URL + CATALOG_URL + DENIED_FOLDER + "/" + content_title);
    try {
        client.executeMethod(get_revision);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // handle response.
    String res_resource_type = "";
    try {
        res_resource_type = get_revision.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Response: " + res_resource_type);

    assertEquals(res_resource_type, revision_resource_type);
    get_revision.releaseConnection();
}

From source file:org.iavante.sling.gad.catalog.DenyRevisionServiceIT.java

public void test_get_ref_content_state() {

    try {/*from ww w .  j a va  2s. com*/
        Thread.sleep(8000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    System.out.println("TEST content state updated");
    String pending_state = "denied";
    HttpMethod get_ref_content_state = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/state");
    System.out.println("Get ref content status: " + 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();
    }
    System.out.println("Response: " + response_body);
    assertEquals(response_body, pending_state);
}

From source file:org.iavante.sling.gad.catalog.PendingServiceIT.java

public void test_get_ref_content_state() {

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

    String pending_state = "pending";
    HttpMethod get_ref_content_state = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/state");
    System.out.println("Get ref content status: " + 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();
    }
    System.out.println("Response: " + response_body);
    assertEquals(response_body, pending_state);
}

From source file:org.iavante.sling.gad.catalog.PendingServiceIT.java

public void test_revision_created() {

    String revision_resource_type = "gad/revision";

    try {//from w ww.  j  ava2s .co m
        Thread.sleep(5000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    // Get source test not present in schema
    HttpMethod get_revision = new GetMethod(
            SLING_URL + CATALOG_URL + PENDING_FOLDER + "/" + content_title + "/sling:resourceType");
    System.out.println(SLING_URL + CATALOG_URL + PENDING_FOLDER + "/" + content_title);
    try {
        client.executeMethod(get_revision);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // handle response.
    String res_resource_type = "";
    try {
        res_resource_type = get_revision.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Response: " + res_resource_type);

    assertEquals(res_resource_type, revision_resource_type);
    get_revision.releaseConnection();

}

From source file:org.iavante.sling.gad.catalog.PendingServiceIT.java

public void test_version_original_content() {

    try {//from  w w  w .jav  a 2  s  .  c om
        Thread.sleep(8000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    String version = "1.0";
    HttpMethod get_ref_content_version = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/version");
    System.out.println("Get ref content version: " + SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/version");
    try {
        this.client.executeMethod(get_ref_content_version);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_ref_content_version.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.println("Response: " + response_body);
    assertEquals(response_body, version);
}

From source file:org.iavante.sling.gad.catalog.RevisedServiceIT.java

public void test_revision_created() {

    System.out.println("TEST Revision created");
    String revision_resource_type = "gad/revision";

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

    // Get source test not present in schema    
    HttpMethod get_revision = new GetMethod(
            SLING_URL + CATALOG_URL + REVISED_FOLDER + "/" + content_title + "/sling:resourceType");
    System.out.println(SLING_URL + CATALOG_URL + REVISED_FOLDER + "/" + content_title);
    try {
        client.executeMethod(get_revision);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // handle response.   
    String res_resource_type = "";
    try {
        res_resource_type = get_revision.getResponseBodyAsString();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Response: " + res_resource_type);

    assertEquals(res_resource_type, revision_resource_type);
    get_revision.releaseConnection();
}

From source file:org.iavante.sling.gad.catalog.RevisedServiceIT.java

public void test_get_ref_content_state() {

    try {/*from   w ww  .  j  a va 2  s .  c o  m*/
        Thread.sleep(8000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }

    System.out.println("TEST content state updated");
    String pending_state = "revised";
    HttpMethod get_ref_content_state = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + LOG_FOLDER + "/state");
    System.out.println("Get ref content status: " + 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();
    }
    System.out.println("Response: " + response_body);
    assertEquals(response_body, pending_state);
}

From source file:org.iavante.sling.gad.catalog.RevisedServiceIT.java

public void test_getTagsFolder() {

    try {/*from  w  w  w .ja  v a 2s . co  m*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    String response_body = "";
    HttpMethod get_col_tags = new GetMethod(SLING_URL + CATALOG_URL + TAGS_FOLDER + "/" + "sling:resourceType");
    try {
        client.executeMethod(get_col_tags);
    } catch (HttpException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        response_body = get_col_tags.getResponseBodyAsString();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

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

From source file:org.iavante.sling.gad.catalog.RevisedServiceIT.java

/**
  * Tests for tags postprocessing//from  w  w w  .ja  v  a 2  s . com
  */
public void test_getTagsCatalog() {

    try {
        Thread.sleep(4000);
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    // Get the  tags
    HttpMethod get_col_tag1 = new GetMethod(SLING_URL + CATALOG_URL + TAGS_FOLDER + "/" + tag1_slug + "/title");
    try {
        this.client.executeMethod(get_col_tag1);
    } catch (HttpException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // handle response.
    String response_body = "";
    try {
        response_body = get_col_tag1.getResponseBodyAsString();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // System.out.println("Tag 1: " + response_body);
    assertEquals(response_body, tag1_title);
    get_col_tag1.releaseConnection();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    // Get the collection tags
    HttpMethod get_col_tag2 = new GetMethod(SLING_URL + CATALOG_URL + TAGS_FOLDER + "/" + tag2_slug + "/title");
    try {
        this.client.executeMethod(get_col_tag2);
    } catch (HttpException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // handle response.
    try {
        response_body = get_col_tag2.getResponseBodyAsString();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // System.out.println("Tag 2: " + response_body);
    assertEquals(response_body, tag2_title);
    get_col_tag2.releaseConnection();
}