List of usage examples for org.apache.commons.httpclient HttpMethod releaseConnection
public abstract void releaseConnection();
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
public void test_get_content_finish_prop() { // 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 {/*from w w w .jav a 2 s .c o m*/ 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); 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("<finish>1")); get_content.releaseConnection(); }
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 w w . j a va 2s.c o m*/ 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
public void test_getSourcesFolder() { // Get the content try {/*from w ww. j a v a 2s .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 + "/" + SOURCES_FOLDER + "/sling:resourceType"); 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, SOURCES_RESOURCE_TYPE); get_content.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
public void test_getVersion() { // Get the content try {//from ww w.j a v a 2s.com Thread.sleep(4000); } catch (InterruptedException e1) { e1.printStackTrace(); } String version = "1.1"; // Get the content HttpMethod get_content_version = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + "/" + "version"); try { this.client.executeMethod(get_content_version); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // handle response. String response_body = ""; try { response_body = get_content_version.getResponseBodyAsString(); } catch (IOException e) { e.printStackTrace(); } assertEquals(response_body, version); get_content_version.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
public void test_getContentHits() { // Get the content hits property try {/*from ww w . j ava2 s . c o m*/ Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } HttpMethod get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + "/" + "hits"); try { this.client.executeMethod(get_content); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Get the content hits property try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } String response_body = null; try { response_body = get_content.getResponseBodyAsString(); } catch (IOException e) { e.printStackTrace(); } assertEquals(response_body, "0"); get_content.releaseConnection(); get_content = new GetMethod( SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + "/"); try { this.client.executeMethod(get_content); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Get the content hits property try { Thread.sleep(4000); } catch (InterruptedException e1) { e1.printStackTrace(); } get_content.releaseConnection(); get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + "/" + "hits"); try { this.client.executeMethod(get_content); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } response_body = null; try { response_body = get_content.getResponseBodyAsString(); } catch (IOException e) { e.printStackTrace(); } assertEquals(response_body, "1"); get_content.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
public void test_getContentGadUuid() { // Get the content gaduuid property try {/*from w ww.ja v a 2 s .c o m*/ Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } HttpMethod get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + "/" + "gaduuid"); try { this.client.executeMethod(get_content); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } assertEquals(get_content.getStatusCode(), 200); get_content.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
public void test_getSMIL() { // Get the content try {//from w ww.ja v a 2 s . c o m Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } HttpMethod get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + ".smil"); 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(); } assert response_body.indexOf("<meta name=\"title\" content=\"Test case content\"/>") != -1; assert response_body.indexOf("<meta name=\"author\" content=\"Test case\"/>") != -1; assert response_body.indexOf("<video ") != -1; get_content.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
public void test_getPlaylist() { // Get the content try {/*www. j a v a 2 s . c o m*/ Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } HttpMethod get_content = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + ".playlist"); 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(); } assert response_body.indexOf("<meta name=\"title\" content=\"Test case content\"/>") != -1; assert response_body.indexOf("<meta name=\"author\" content=\"Test case\"/>") != -1; get_content.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
/** * Tests for tags postprocessing/*from ww w. ja va 2 s.c om*/ */ public void test_getTagsCollection() { try { Thread.sleep(4000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Get the collection tags HttpMethod get_col_tag1 = new GetMethod( SLING_URL + COLLECTIONS_URL + slug_collection + "/" + 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(response_body, tag1_title); 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 + COLLECTIONS_URL + slug_collection + "/" + 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(response_body, tag2_title); get_col_tag2.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
/** * Tests path property/* ww w . j a v a2 s . co m*/ */ public void test_getPathProp() { try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Get path property String path_response = COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content; String path_prop = "jcr_path"; try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Get the content HttpMethod get_content_path = new GetMethod(SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content + "/" + path_prop); try { this.client.executeMethod(get_content_path); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // handle response. String response_body = ""; try { response_body = get_content_path.getResponseBodyAsString(); } catch (IOException e) { e.printStackTrace(); } assertEquals(response_body, path_response); get_content_path.releaseConnection(); }