List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getStatusCode
@Override public int getStatusCode()
From source file:org.apache.wookie.tests.functional.ParticipantsControllerTest.java
@Test public void deleteParticipant_InvalidAPIKey() { try {//from w w w .j a v a2s . c o m HttpClient client = new HttpClient(); DeleteMethod post = new DeleteMethod(TEST_PARTICIPANTS_SERVICE_URL_VALID); post.setQueryString("api_key=" + API_KEY_INVALID + "&widgetid=" + WIDGET_ID_VALID + "&userid=test&shareddatakey=participantstest"); client.executeMethod(post); int code = post.getStatusCode(); assertEquals(401, code); post.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("post failed"); } }
From source file:org.apache.wookie.tests.functional.ParticipantsControllerTest.java
@Test public void deleteParticipant_InvalidParticipant() { try {/*from w w w. ja v a 2s . c om*/ HttpClient client = new HttpClient(); DeleteMethod post = new DeleteMethod(TEST_PARTICIPANTS_SERVICE_URL_VALID); post.setQueryString("api_key=" + API_KEY_VALID + "&widgetid=" + WIDGET_ID_VALID + "&userid=test&shareddatakey=participantstest&participant_id=99"); client.executeMethod(post); int code = post.getStatusCode(); assertEquals(404, code); post.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("post failed"); } }
From source file:org.apache.wookie.tests.functional.ParticipantsControllerTest.java
@Test public void deleteParticipant_InvalidInstance() { try {//from w w w .j av a 2s . co m HttpClient client = new HttpClient(); DeleteMethod post = new DeleteMethod(TEST_PARTICIPANTS_SERVICE_URL_VALID); post.setQueryString("api_key=" + API_KEY_VALID + "&widgetid=" + WIDGET_ID_VALID + "&userid=test&shareddatakey=participantstestinvalidkey&participant_id=1"); client.executeMethod(post); int code = post.getStatusCode(); assertEquals(400, code); post.releaseConnection(); } catch (Exception e) { e.printStackTrace(); fail("post failed"); } }
From source file:org.apache.wookie.tests.functional.PropertiesControllerTest.java
@Test public void removeProperty() { try {/*from w w w . j a v a2s . c o m*/ HttpClient client = new HttpClient(); DeleteMethod delete = new DeleteMethod(TEST_PROPERTIES_SERVICE_URL_VALID); delete.setQueryString("api_key=" + API_KEY_VALID + "&widgetid=" + WIDGET_ID_VALID + "&userid=test&is_public=true&shareddatakey=propstest&propertyname=cat"); client.executeMethod(delete); int code = delete.getStatusCode(); assertEquals(200, code); delete.releaseConnection(); } catch (Exception e) { fail("delete failed"); } }
From source file:org.apache.wookie.tests.functional.PropertiesControllerTest.java
@Test public void removePropertyNonExisting() { try {// ww w.j a va 2s . c om HttpClient client = new HttpClient(); DeleteMethod delete = new DeleteMethod(TEST_PROPERTIES_SERVICE_URL_VALID); delete.setQueryString("api_key=" + API_KEY_VALID + "&widgetid=" + WIDGET_ID_VALID + "&userid=test&is_public=true&shareddatakey=propstest&propertyname=bogus"); client.executeMethod(delete); int code = delete.getStatusCode(); assertEquals(404, code); delete.releaseConnection(); } catch (Exception e) { fail("delete failed"); } }
From source file:org.apache.wookie.tests.functional.WidgetAccessRequestPolicyControllerTest.java
@Test public void deletePolicy() { try {//from www . ja va 2 s.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 {/*w w w . jav 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 {/*ww w . ja v a2 s.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 av 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 www .j av a2 s . c o m 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"); } }