List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete
public HttpDelete(final String uri)
From source file:org.activiti.rest.service.api.runtime.ProcessInstanceResourceTest.java
/** * Test deleting a single process instance. *//*from w w w .j a v a2 s. c om*/ @Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" }) public void testDeleteProcessInstance() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", "myBusinessKey"); closeResponse( executeRequest( new HttpDelete(SERVER_URL_PREFIX + RestUrls .createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_NO_CONTENT)); // Check if process-instance is gone assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()); }
From source file:com.github.kristofa.test.http.MockHttpServerTest.java
@Test public void testShouldHandleDeleteRequests() throws ClientProtocolException, IOException { // Given a mock server configured to respond to a DELETE /test responseProvider.expect(Method.DELETE, "/test").respondWith(204, "text/plain", ""); // When a request for DELETE /test arrives final HttpDelete req = new HttpDelete(baseUrl + "/test"); final HttpResponse response = client.execute(req); // Then the response status is 204 assertEquals(204, response.getStatusLine().getStatusCode()); }
From source file:com.mikecorrigan.bohrium.pubsub.Transaction.java
public void run() { Log.v(TAG, "send"); mStatusCode = -1;//from w w w.j av a2s. com mStatusReason = null; mResponseBody = null; Log.v(TAG, "baseUri=" + mBaseUriString); Log.v(TAG, "authCookie=" + mAuthCookie); Log.v(TAG, "method=" + mMethod); Log.v(TAG, "uri=" + mUriString); if (mRequestBody != null) { Log.v(TAG, "requestBody=" + mRequestBody); } // Encode URI. URI uri; try { uri = new URI(mBaseUriString + "/" + mUriString); Log.v(TAG, "uri=" + uri); } catch (URISyntaxException e) { Log.w(TAG, "Invalid URI, " + e); uri = null; } if (uri != null) { // Dispatch method. switch (mMethod) { case "GET": { read(new HttpGet(uri)); break; } case "DELETE": { read(new HttpDelete(uri)); break; } case "PUT": { readWrite(new HttpPut(uri)); break; } case "POST": { readWrite(new HttpPost(uri)); break; } default: { Log.e(TAG, "Unsupported method, " + mMethod); break; } } } Log.v(TAG, "statusCode=" + mStatusCode); Log.v(TAG, "statusReason=" + mStatusReason); Log.v(TAG, "responseBody=" + mResponseBody); }
From source file:org.caratarse.auth.services.controller.UserAuthorizationControllerTest.java
@Test public void deleteUserAuthorization() throws IOException { HttpDelete deleteRequest = new HttpDelete( BASE_URL + "/users/a1ab82a6-c8ce-4723-8532-777c4b05d03c/authorizations/ROLE_ADMIN.json"); HttpResponse response = httpClient.execute(deleteRequest); assertEquals(204, response.getStatusLine().getStatusCode()); HttpGet getRequest = new HttpGet( BASE_URL + "/users/a1ab82a6-c8ce-4723-8532-777c4b05d03c/authorizations/ROLE_ADMIN.json"); response = httpClient.execute(getRequest); assertEquals(404, response.getStatusLine().getStatusCode()); log.debug(IOUtils.toString(response.getEntity().getContent())); }
From source file:com.androidex.volley.toolbox.HttpClientStack.java
/** * Creates the appropriate subclass of HttpUriRequest for passed in request. *///from ww w .j a v a 2 s.c om @SuppressWarnings("deprecation") /* protected */static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) throws AuthFailureError, IOException { switch (request.getMethod()) { case Method.DEPRECATED_GET_OR_POST: { // This is the deprecated way that needs to be handled for backwards // compatibility. // If the request's post body is null, then the assumption is that // the request is // GET. Otherwise, it is assumed that the request is a POST. byte[] postBody = request.getPostBody(); if (postBody != null) { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getPostBodyContentType()); HttpEntity entity; entity = new ByteArrayEntity(postBody); postRequest.setEntity(entity); return postRequest; } else { return new HttpGet(request.getUrl()); } } case Method.GET: return new HttpGet(request.getUrl()); case Method.DELETE: return new HttpDelete(request.getUrl()); case Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case Method.HEAD: return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl()); case Method.TRACE: return new HttpTrace(request.getUrl()); case Method.PATCH: { HttpPatch patchRequest = new HttpPatch(request.getUrl()); setEntityIfNonEmptyBody(patchRequest, request); return patchRequest; } default: throw new IllegalStateException("Unknown request method."); } }
From source file:com.farru.android.volley.toolbox.HttpClientStack.java
/** * Creates the appropriate subclass of HttpUriRequest for passed in request. *//*from w ww. j a v a 2 s .co m*/ @SuppressWarnings("deprecation") /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) throws AuthFailureError { switch (request.getMethod()) { case Method.DEPRECATED_GET_OR_POST: { // This is the deprecated way that needs to be handled for backwards // compatibility. // If the request's post body is null, then the assumption is that // the request is // GET. Otherwise, it is assumed that the request is a POST. byte[] postBody = request.getPostBody(); if (postBody != null) { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getPostBodyContentType()); HttpEntity entity; entity = new ByteArrayEntity(postBody); postRequest.setEntity(entity); return postRequest; } else { return new HttpGet(request.getUrl()); } } case Method.GET: return new HttpGet(request.getUrl()); case Method.DELETE: return new HttpDelete(request.getUrl()); case Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case Method.HEAD: return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl()); case Method.TRACE: return new HttpTrace(request.getUrl()); case Method.PATCH: { HttpPatch patchRequest = new HttpPatch(request.getUrl()); patchRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(patchRequest, request); return patchRequest; } default: throw new IllegalStateException("Unknown request method."); } }
From source file:com.ibm.watson.app.common.util.rest.SimpleRestClient.java
protected <T> T delete(String endpoint, ResponseHandler<? extends T> responseHandler) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Making DELETE request at endpoint '" + endpoint + "'"); }/* w w w . j a v a 2 s . c o m*/ HttpDelete httpdelete = new HttpDelete(url + endpoint); return doDelete(httpdelete, responseHandler); }
From source file:net.sf.jaceko.mock.it.helper.request.HttpRequestSender.java
public MockResponse sendDeleteRequest(String url) throws IOException { HttpDelete httpDelete = new HttpDelete(url); return executeRequest(httpDelete, new HashMap<String, String>()); }
From source file:org.caratarse.auth.services.controller.UserControllerTest.java
@Test public void deleteUser() throws IOException { HttpDelete deleteRequest = new HttpDelete(BASE_URL + "/users/a1ab82a6-c8ce-4723-8532-777c4b05d03c"); HttpResponse response = httpClient.execute(deleteRequest); assertEquals(204, response.getStatusLine().getStatusCode()); HttpGet getRequest = new HttpGet(BASE_URL + "/users/a1ab82a6-c8ce-4723-8532-777c4b05d03c.json"); response = httpClient.execute(getRequest); assertEquals(404, response.getStatusLine().getStatusCode()); log.debug(IOUtils.toString(response.getEntity().getContent())); }
From source file:com.intel.cosbench.client.http.HttpClientUtil.java
public static HttpDelete makeHttpDelete(String url) { return new HttpDelete(url); }