List of usage examples for org.apache.commons.httpclient.methods DeleteMethod releaseConnection
@Override public void releaseConnection()
From source file:org.apache.wookie.tests.functional.WidgetAccessRequestPolicyControllerTest.java
@Test public void deletePolicy() { try {/* w w w . j a va 2s .c o m*/ HttpClient client = new HttpClient(); setAuthenticationCredentials(client); DeleteMethod del = new DeleteMethod(TEST_WARP_SERVICE_URL_VALID + "/" + id); del.setDoAuthentication(true); client.executeMethod(del); int code = del.getStatusCode(); assertEquals(200, code); del.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("put failed"); } // Now lets make sure it was deleted OK Element[] policies = getPolicies(); for (Element policy : policies) { if (policy.getAttribute("id").getValue().equals(id)) { fail("Policy was not deleted"); } } }
From source file:org.apache.wookie.tests.functional.WidgetServicesControllerTest.java
@Test public void deleteService() { try {/*www. j av a 2 s . c om*/ HttpClient client = new HttpClient(); setAuthenticationCredentials(client); DeleteMethod del = new DeleteMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test2"); del.setDoAuthentication(true); client.executeMethod(del); int code = del.getStatusCode(); assertEquals(200, code); del.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("put failed"); } // Now lets GET it to make sure it was deleted OK try { HttpClient client = new HttpClient(); GetMethod get = new GetMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test2"); client.executeMethod(get); int code = get.getStatusCode(); assertEquals(404, code); get.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("get failed"); } }
From source file:org.apache.wookie.tests.functional.WidgetServicesControllerTest.java
@Test public void deleteServiceNoAuth() { try {//from w w w .j a v a 2s . co m HttpClient client = new HttpClient(); DeleteMethod del = new DeleteMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test2"); del.setQueryString("name=test2"); client.executeMethod(del); int code = del.getStatusCode(); assertEquals(401, code); del.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("put failed"); } }
From source file:org.apache.wookie.tests.functional.WidgetServicesControllerTest.java
@Test public void addServiceAlreadyExists() { try {/*from w w w. j a v a 2 s . com*/ HttpClient client = new HttpClient(); setAuthenticationCredentials(client); PostMethod post = new PostMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test_add2"); post.setDoAuthentication(true); client.executeMethod(post); int code = post.getStatusCode(); assertEquals(201, code); post.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("post failed"); } try { HttpClient client = new HttpClient(); setAuthenticationCredentials(client); PostMethod post = new PostMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test_add2"); post.setDoAuthentication(true); client.executeMethod(post); int code = post.getStatusCode(); assertEquals(409, code); post.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("post failed"); } // clean up try { HttpClient client = new HttpClient(); setAuthenticationCredentials(client); DeleteMethod del = new DeleteMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test_add2"); del.setDoAuthentication(true); client.executeMethod(del); int code = del.getStatusCode(); assertEquals(200, code); del.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("put failed"); } }
From source file:org.apache.wookie.tests.functional.WidgetServicesControllerTest.java
@Test public void deleteServiceNonExists() { try {//from ww w . j a v a 2s .c om HttpClient client = new HttpClient(); setAuthenticationCredentials(client); DeleteMethod del = new DeleteMethod(TEST_SERVICES_SERVICE_URL_VALID + "/test999"); del.setDoAuthentication(true); client.executeMethod(del); int code = del.getStatusCode(); assertEquals(404, code); del.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("put failed"); } }
From source file:org.apache.zeppelin.rest.CredentialsRestApiTest.java
public void testRemoveUserCredentials() throws IOException { DeleteMethod deleteMethod = httpDelete("/credential/"); assertThat("Test delete method:", deleteMethod, isAllowed()); deleteMethod.releaseConnection(); }
From source file:org.apache.zeppelin.rest.CredentialsRestApiTest.java
public void testRemoveCredentialEntity(String entity) throws IOException { DeleteMethod deleteMethod = httpDelete("/credential/" + entity); assertThat("Test delete method:", deleteMethod, isAllowed()); deleteMethod.releaseConnection(); }
From source file:org.apache.zeppelin.rest.InterpreterRestApiTest.java
@Test public void testSettingsCRUD() throws IOException { // when: call create setting API String rawRequest = "{\"name\":\"md2\",\"group\":\"md\",\"properties\":{\"propname\":\"propvalue\"}," + "\"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]," + "\"dependencies\":[]," + "\"option\": { \"remote\": true, \"session\": false }}"; JsonObject jsonRequest = gson.fromJson(rawRequest, JsonElement.class).getAsJsonObject(); PostMethod post = httpPost("/interpreter/setting/", jsonRequest.toString()); String postResponse = post.getResponseBodyAsString(); LOG.info("testSettingCRUD create response\n" + post.getResponseBodyAsString()); InterpreterSetting created = convertResponseToInterpreterSetting(postResponse); String newSettingId = created.getId(); // then : call create setting API assertThat("test create method:", post, isAllowed()); post.releaseConnection();/*from ww w .j a v a2s . c o m*/ // when: call read setting API GetMethod get = httpGet("/interpreter/setting/" + newSettingId); String getResponse = get.getResponseBodyAsString(); LOG.info("testSettingCRUD get response\n" + getResponse); InterpreterSetting previouslyCreated = convertResponseToInterpreterSetting(getResponse); // then : read Setting API assertThat("Test get method:", get, isAllowed()); assertEquals(newSettingId, previouslyCreated.getId()); get.releaseConnection(); // when: call update setting API jsonRequest.getAsJsonObject("properties").addProperty("propname2", "this is new prop"); PutMethod put = httpPut("/interpreter/setting/" + newSettingId, jsonRequest.toString()); LOG.info("testSettingCRUD update response\n" + put.getResponseBodyAsString()); // then: call update setting API assertThat("test update method:", put, isAllowed()); put.releaseConnection(); // when: call delete setting API DeleteMethod delete = httpDelete("/interpreter/setting/" + newSettingId); LOG.info("testSettingCRUD delete response\n" + delete.getResponseBodyAsString()); // then: call delete setting API assertThat("Test delete method:", delete, isAllowed()); delete.releaseConnection(); }
From source file:org.apache.zeppelin.rest.InterpreterRestApiTest.java
@Test public void testAddDeleteRepository() throws IOException { // Call create repository API String repoId = "securecentral"; String jsonRequest = "{\"id\":\"" + repoId + "\",\"url\":\"https://repo1.maven.org/maven2\",\"snapshot\":\"false\"}"; PostMethod post = httpPost("/interpreter/repository/", jsonRequest); assertThat("Test create method:", post, isAllowed()); post.releaseConnection();/*from www . j av a 2 s . co m*/ // Call delete repository API DeleteMethod delete = httpDelete("/interpreter/repository/" + repoId); assertThat("Test delete method:", delete, isAllowed()); delete.releaseConnection(); }
From source file:org.apache.zeppelin.rest.NotebookSecurityRestApiTest.java
private void userTryRemoveNote(String noteId, String user, String pwd, Matcher<? super HttpMethodBase> m) throws IOException { DeleteMethod delete = httpDelete(("/notebook/" + noteId), user, pwd); assertThat(delete, m);/* w w w . j a v a2 s . co m*/ delete.releaseConnection(); }