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

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

Introduction

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

Prototype

public abstract void releaseConnection();

Source Link

Usage

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

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

    try {//from w w  w.ja  va 2s  .  com
        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_get_published_revision() {

    try {//from  w ww  . j a  v a2 s  .com
        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 {// ww w. j a  v a2 s .  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  www.  j  a  va2 s .  c om
        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 {/* w  ww  .jav a2  s . co  m*/
        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//from ww  w.  ja v a2 s .  c  o  m
 */
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();
}

From source file:org.iavante.sling.gad.collection.CollectionServiceTestIT.java

public void test_getSourcesFolder() {

    try {/* w  w w . ja  va  2s. co m*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {

        e1.printStackTrace();
    }

    String response_body = "";
    HttpMethod get_col_sources = new GetMethod(
            SLING_URL + COLLECTION_URL + slug + "/" + SOURCES_FOLDER + "/" + "sling:resourceType");
    try {
        client.executeMethod(get_col_sources);
    } catch (HttpException e) {

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

        e.printStackTrace();
    }

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

        e.printStackTrace();
    }

    assertEquals(response_body, SOURCES_RESOURCE_TYPE);
    get_col_sources.releaseConnection();
}

From source file:org.iavante.sling.gad.collection.CollectionServiceTestIT.java

public void test_getTagsFolder() {

    try {/*from w  w  w . ja v  a 2 s  . c  o m*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {

        e1.printStackTrace();
    }

    String response_body = "";
    HttpMethod get_col_tags = new GetMethod(
            SLING_URL + COLLECTION_URL + 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(response_body, TAGS_RESOURCE_TYPE);
    get_col_tags.releaseConnection();
}

From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java

public void test_getContent() {

    // Get the content

    try {/* ww w .j  a va 2  s  . co  m*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {

        e1.printStackTrace();
    }

    HttpMethod get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER
            + "/" + slug_content + "/" + "title");
    try {
        this.client.executeMethod(get_content);
    } catch (HttpException e) {

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

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

        e.printStackTrace();
    }

    assertEquals(response_body, title);
    get_content.releaseConnection();
}

From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java

public void test_get_content_inmediatly() {

    // Get the content inmediatly
    PostMethod post_create = new PostMethod(
            SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content_dos);
    post_create.setDoAuthentication(true);

    NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/content"),
            new NameValuePair("title", title), new NameValuePair("schema", schema),
            new NameValuePair("description",
                    "Content description generated by test case. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."),
            new NameValuePair("author", "Test case"), new NameValuePair("origin", "Test case"),
            new NameValuePair("lang", "es"), new NameValuePair("tags", tag1_input),
            new NameValuePair("tags", tag2_input), new NameValuePair("tags@TypeHint", "String[]"),
            new NameValuePair("state", "pending"), new NameValuePair("jcr:created", ""),
            new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""),
            new NameValuePair("jcr:lastModifiedBy", ""), new NameValuePair("_charset_", "utf-8") };

    post_create.setRequestBody(data_create);
    try {/*  w ww .  j  ava 2  s  . co  m*/
        client.executeMethod(post_create);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    post_create.releaseConnection();

    HttpMethod get_content = new GetMethod(
            SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content_dos);

    try {
        this.client.executeMethod(get_content);
    } catch (HttpException e) {

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

        e.printStackTrace();
    }

    assertEquals(get_content.getStatusCode(), 200);
    get_content.releaseConnection();
}