Example usage for org.apache.commons.httpclient.methods PostMethod setRequestBody

List of usage examples for org.apache.commons.httpclient.methods PostMethod setRequestBody

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods PostMethod setRequestBody.

Prototype

public void setRequestBody(NameValuePair[] paramArrayOfNameValuePair) throws IllegalArgumentException 

Source Link

Usage

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

public void test_get_embed() {

    // 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", "playlist"),
            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  a  v a2s  .c om*/
        client.executeMethod(post_create);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    post_create.releaseConnection();

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

        e1.printStackTrace();
    }

    HttpMethod get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER
            + "/" + slug_content_dos
            + "/?player_width=1000&player_height=200&player_playlist_layout=left&player_plugins=test-1,test-2&player_autostart=true&player_repeat=none");

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

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

        e.printStackTrace();
    }

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

        e.printStackTrace();
    }

    assertTrue(response_body.contains("<embed>"));
    assertTrue(response_body.contains("</embed>"));
    assertTrue(response_body.contains("width='1000'"));
    assertTrue(response_body.contains("height='200'"));
    assertTrue(response_body.contains("playlist=left"));
    assertTrue(response_body.contains("plugins=test-1,test-2"));
    assertTrue(response_body.contains("autostart=true"));
    assertTrue(response_body.contains("repeat=none"));
    get_content.releaseConnection();
}

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

/**
 * Test the validated property/*from   w  w w.  j  a  v a  2s.co m*/
 */
public void test_content_validation() {

    String validated = "0";
    String response_body = "";

    String source_video = "fuente_default";
    String source_image = "thumbnail_default";

    String file_video = "test.avi";
    String mime_video = "video/avi";

    String file_image = "test.png";
    String mime_image = "image/png";

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

        e1.printStackTrace();
    }

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

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

        e.printStackTrace();
    }

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

        e.printStackTrace();
    }

    assertEquals(response_body, validated);
    get_valid_prop.releaseConnection();

    // Edit source default
    PostMethod post_edit = new PostMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER
            + "/" + slug_content + "/" + SOURCES_FOLDER + "/" + source_video);
    post_edit.setDoAuthentication(true);

    NameValuePair[] data_edit = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("file", file_video), new NameValuePair("mimetype", mime_video),
            new NameValuePair("text_encoding", ""), new NameValuePair("lang", ""),
            new NameValuePair("length", ""), new NameValuePair("size", ""), new NameValuePair("type", ""),
            new NameValuePair("bitrate", ""), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_edit.setRequestBody(data_edit);
    post_edit.setDoAuthentication(true);
    try {
        client.executeMethod(post_edit);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

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

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

        e1.printStackTrace();
    }

    // Edit thumbnail default
    post_edit = null;
    post_edit = new PostMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/"
            + slug_content + "/" + SOURCES_FOLDER + "/" + source_image);
    post_edit.setDoAuthentication(true);

    NameValuePair[] data_edit_image = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("file", file_image), new NameValuePair("mimetype", mime_image),
            new NameValuePair("text_encoding", ""), new NameValuePair("lang", ""),
            new NameValuePair("length", ""), new NameValuePair("size", ""), new NameValuePair("type", ""),
            new NameValuePair("bitrate", ""), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_edit.setRequestBody(data_edit_image);
    post_edit.setDoAuthentication(true);
    try {
        client.executeMethod(post_edit);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

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

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

        e1.printStackTrace();
    }

    // Test if the content is already validated
    validated = "1";
    get_valid_prop = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/"
            + slug_content + "/validated");
    try {
        client.executeMethod(get_valid_prop);
    } catch (HttpException e) {

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

        e.printStackTrace();
    }

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

        e.printStackTrace();
    }

    assertEquals(response_body, validated);
    get_valid_prop.releaseConnection();
}

From source file:org.iavante.sling.gad.content.impl.DirectPublication.java

/**
 * Sends a content to revision.//from  w  w w .  j  a  va2s  . c o m
 * 
 * @throws IOException
 * @throws HttpException
 * @throws RepositoryException
 */
private void sendContentToRevision() throws HttpException, IOException {

    PostMethod post = new PostMethod(HTTP_BASE_URL + nodePath);
    String catalog_pending_url = CATALOG_URL + PENDING_FOLDER + "/";

    post.setDoAuthentication(true);

    NameValuePair[] data_send_to_revision = { new NameValuePair(":operation", "copy"),
            new NameValuePair(":dest", catalog_pending_url), new NameValuePair(":replace", "true") };

    int responseCode = -1;
    post.setRequestBody(data_send_to_revision);

    try {
        client.getState().setCredentials(AuthScope.ANY, userCreds);
        client.executeMethod(post);
        responseCode = post.getStatusCode();
    } finally {
        post.releaseConnection();
    }

    if (responseCode != 201 && responseCode != 200) {
        throw new IOException("sendContentToRevision, code=" + responseCode);
    }

}

From source file:org.iavante.sling.gad.content.impl.DirectPublication.java

/**
 * Accepts a revision and inserts it into the catalog.
 * // w w  w  .java 2 s. c  om
 * @throws IOException
 * @throws HttpException
 */
private void acceptRevision() throws HttpException, IOException {

    PostMethod post = new PostMethod(HTTP_BASE_URL + CATALOG_URL + PENDING_FOLDER + "/" + contentName);
    String catalog_revised_url = CATALOG_URL + REVISED_FOLDER + "/";

    post.setDoAuthentication(true);

    NameValuePair[] data_revise_content = { new NameValuePair(":operation", "move"),
            new NameValuePair(":dest", catalog_revised_url), new NameValuePair(":replace", "true") };

    int responseCode = -1;
    post.setRequestBody(data_revise_content);

    try {
        client.getState().setCredentials(AuthScope.ANY, userCreds);
        client.executeMethod(post);
        responseCode = post.getStatusCode();
    } finally {
        post.releaseConnection();
    }

    if (responseCode != 201 && responseCode != 200) {
        throw new IOException("acceptRevision, code=" + responseCode);
    }

}

From source file:org.iavante.sling.gad.content.impl.DirectPublication.java

/**
 * Publishes the revision to the specified channels.
 * /*from   w  w  w.  j  a va  2 s .c o m*/
 * @throws IOException
 * @throws HttpException
 */
private void publishToChannels() throws HttpException, IOException {

    String[] channelNames = channels.trim().split(",");

    for (int i = 0; i < channelNames.length; i++) {

        PostMethod post = new PostMethod(HTTP_BASE_URL + CATALOG_URL + REVISED_FOLDER + "/" + contentName);
        String channel = CHANNEL_URL + channelNames[i] + "/contents/";

        post.setDoAuthentication(true);

        NameValuePair[] data_publish = { new NameValuePair(":operation", "copy"),
                new NameValuePair(":dest", channel), new NameValuePair(":replace", "true") };

        int responseCode = -1;
        post.setRequestBody(data_publish);

        try {
            client.getState().setCredentials(AuthScope.ANY, userCreds);
            client.executeMethod(post);
            responseCode = post.getStatusCode();
        } finally {
            post.releaseConnection();
        }

        if (responseCode != 201 && responseCode != 200) {
            throw new IOException("publishToChannels, code=" + responseCode);
        }

    }
}

From source file:org.iavante.sling.gad.source.SourceServiceTestIT.java

protected void setUp() {

    Map<String, String> envs = System.getenv();
    Set<String> keys = envs.keySet();

    Iterator<String> it = keys.iterator();
    boolean hashost = false;
    while (it.hasNext()) {
        String key = (String) it.next();

        if (key.compareTo(HOSTVAR) == 0) {
            SLING_URL = SLING_URL + (String) envs.get(key);
            hashost = true;/*  ww  w.  j  av a 2  s  .co m*/
        }
    }
    if (hashost == false)
        SLING_URL = SLING_URL + HOSTPREDEF;

    client = new HttpClient();
    col_title = "it_col";
    content_title = "it_content";
    source_title = "it_source";
    file = "integration-test.flv";
    mimetype = "video/flv";
    type = "video";
    schema = "default";

    authPrefs = new ArrayList(2);
    authPrefs.add(AuthPolicy.DIGEST);
    authPrefs.add(AuthPolicy.BASIC);

    defaultcreds = new UsernamePasswordCredentials("admin", "admin");

    client.getParams().setAuthenticationPreemptive(true);
    client.getState().setCredentials(AuthScope.ANY, defaultcreds);
    client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);

    // Create collection
    PostMethod post_create_col = new PostMethod(SLING_URL + COL_URL + col_title);
    post_create_col.setDoAuthentication(true);

    NameValuePair[] data_create_col = { new NameValuePair("sling:resourceType", "gad/collection"),
            new NameValuePair("title", col_title), new NameValuePair("schema", schema),
            new NameValuePair("subtitle", ""), new NameValuePair("extern_storage", "on"),
            new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""),
            new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""),
            new NameValuePair("jcr:lastModifiedBy", "") };
    post_create_col.setRequestBody(data_create_col);
    // post.setDoAuthentication(true);
    try {
        client.executeMethod(post_create_col);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    // Collection created
    assertEquals(201, post_create_col.getStatusCode());
    post_create_col.releaseConnection();

    // Create content in collection
    PostMethod post_create_content = new PostMethod(
            SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title);
    post_create_content.setDoAuthentication(true);

    NameValuePair[] data_create_content = { new NameValuePair("sling:resourceType", "gad/content"),
            new NameValuePair("title", content_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", "test case"),
            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", "") };
    post_create_content.setRequestBody(data_create_content);
    // post.setDoAuthentication(true);
    try {
        client.executeMethod(post_create_content);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    // Content created
    assertEquals(201, post_create_content.getStatusCode());
    post_create_content.releaseConnection();
}

From source file:org.iavante.sling.gad.source.SourceServiceTestIT.java

protected void tearDown() {

    // Delete the collection
    PostMethod post_delete = new PostMethod(SLING_URL + COL_URL + col_title);
    NameValuePair[] data_delete = { new NameValuePair(":operation", "delete"), };

    post_delete.setDoAuthentication(true);
    post_delete.setRequestBody(data_delete);

    try {/*  w w w. j a va  2s .  c  o  m*/
        client.executeMethod(post_delete);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    assertEquals(200, post_delete.getStatusCode());
    post_delete.releaseConnection();
}

From source file:org.iavante.sling.gad.source.SourceServiceTestIT.java

public void test_notify_status_code() {

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

        e1.printStackTrace();
    }

    // Create the source
    PostMethod post_create = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title);
    post_create.setDoAuthentication(true);
    NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("title", source_title), new NameValuePair("file", ""),
            new NameValuePair("mimetype", ""), new NameValuePair("text_encoding", ""),
            new NameValuePair("lang", ""), new NameValuePair("length", ""), new NameValuePair("size", ""),
            new NameValuePair("type", ""), new NameValuePair("bitrate", ""),
            new NameValuePair("tags", TAGS_REQUEST), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_create.setRequestBody(data_create);

    try {
        client.executeMethod(post_create);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

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

    // Edit the source
    PostMethod post_edit = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title);
    post_create.setDoAuthentication(true);

    NameValuePair[] data_edit = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("file", file), new NameValuePair("mimetype", mimetype),
            new NameValuePair("text_encoding", ""), new NameValuePair("lang", ""),
            new NameValuePair("length", ""), new NameValuePair("size", ""), new NameValuePair("type", type),
            new NameValuePair("bitrate", ""), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_edit.setRequestBody(data_edit);
    post_edit.setDoAuthentication(true);
    try {
        client.executeMethod(post_edit);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    assertEquals(200, post_edit.getStatusCode());

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

        e1.printStackTrace();
    }

    // Get trans preview notify_status_code
    HttpMethod get_trans_preview_status = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER
            + "/" + content_title + "/" + SOURCES_FOLDER + "/" + source_title + "/" + TRANSFORMATIONS_FOLDER
            + "/" + TRANSFORMATION_PREVIEW + "/" + "notify_status_code");
    try {
        client.executeMethod(get_trans_preview_status);
    } catch (HttpException e) {

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

        e.printStackTrace();
    }

    int status_code = get_trans_preview_status.getStatusCode();

    boolean failed = true;

    if (status_code != 404)
        failed = false;

    assertFalse(failed);
    get_trans_preview_status.releaseConnection();

}

From source file:org.iavante.sling.gad.source.SourceServiceTestIT.java

public void test_create_source_in_content() {

    try {/*from   w  w w .java  2 s .  com*/
        Thread.sleep(2000);
    } catch (InterruptedException e1) {

        e1.printStackTrace();
    }

    // Create the source
    PostMethod post_create = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title);
    post_create.setDoAuthentication(true);
    NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("title", source_title), new NameValuePair("file", ""),
            new NameValuePair("mimetype", ""), new NameValuePair("text_encoding", ""),
            new NameValuePair("lang", ""), new NameValuePair("length", ""), new NameValuePair("size", ""),
            new NameValuePair("type", ""), new NameValuePair("bitrate", ""),
            new NameValuePair("tags", TAGS_REQUEST), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_create.setRequestBody(data_create);
    // post.setDoAuthentication(true);
    try {
        client.executeMethod(post_create);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

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

    // Edit the source
    PostMethod post_edit = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title);
    post_create.setDoAuthentication(true);

    NameValuePair[] data_edit = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("file", file), new NameValuePair("mimetype", mimetype),
            new NameValuePair("text_encoding", ""), new NameValuePair("lang", ""),
            new NameValuePair("length", ""), new NameValuePair("size", ""), new NameValuePair("type", type),
            new NameValuePair("bitrate", ""), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_edit.setRequestBody(data_edit);
    post_edit.setDoAuthentication(true);
    try {
        client.executeMethod(post_edit);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    assertEquals(200, post_edit.getStatusCode());

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

        e1.printStackTrace();
    }

    // Get trans preview
    HttpMethod get_trans_preview = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title + "/" + TRANSFORMATIONS_FOLDER + "/"
            + TRANSFORMATION_PREVIEW + "/" + "title");
    try {
        client.executeMethod(get_trans_preview);
    } catch (HttpException e) {

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

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

        e.printStackTrace();
    }

    assertEquals(TRANSFORMATION_PREVIEW_TITLE, res_trans_title);
    get_trans_preview.releaseConnection();
}

From source file:org.iavante.sling.gad.source.SourceServiceTestIT.java

public void test_source_finish_prop() {

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

        e1.printStackTrace();
    }

    // Create the source
    PostMethod post_create = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title);
    post_create.setDoAuthentication(true);
    NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/source"),
            new NameValuePair("title", source_title), new NameValuePair("file", ""),
            new NameValuePair("mimetype", ""), new NameValuePair("text_encoding", ""),
            new NameValuePair("lang", ""), new NameValuePair("length", ""), new NameValuePair("size", ""),
            new NameValuePair("type", ""), new NameValuePair("bitrate", ""),
            new NameValuePair("tags", TAGS_REQUEST), new NameValuePair("tracks_number", ""),
            new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""),
            new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""),
            new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""),
            new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""),
            new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") };
    post_create.setRequestBody(data_create);
    // post.setDoAuthentication(true);
    try {
        client.executeMethod(post_create);
    } catch (HttpException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    post_create.releaseConnection();

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

        e1.printStackTrace();
    }

    // Get the source
    HttpMethod get_source = new GetMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/"
            + content_title + "/" + SOURCES_FOLDER + "/" + source_title);
    try {
        client.executeMethod(get_source);
    } catch (HttpException e) {

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

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

        e.printStackTrace();
    }

    assertTrue(response_body.contains("<finish>1"));
    get_source.releaseConnection();
}