Search in sources :

Example 81 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.

the class TaskResourceTest method testDeleteTaskInProcess.

/**
   * Test updating a task that is part of a process.
   * PUT runtime/tasks/{taskId}
   */
@Deployment
public void testDeleteTaskInProcess() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, task.getId()));
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_FORBIDDEN));
}
Also used : Task(org.activiti.engine.task.Task) HttpDelete(org.apache.http.client.methods.HttpDelete) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 82 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project azure-tools-for-java by Microsoft.

the class SparkBatchSubmission method killBatchJob.

/**
     * kill batch job
     * @param connectUrl : eg http://localhost:8998/batches
     * @param batchId : batch Id
     * @return response result
     * @throws IOException
     */
public HttpResponse killBatchJob(String connectUrl, int batchId) throws IOException {
    CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
    HttpDelete httpDelete = new HttpDelete(connectUrl + "/" + batchId);
    httpDelete.addHeader("User-Agent", userAgentName);
    httpDelete.addHeader("Content-Type", "application/json");
    try (CloseableHttpResponse response = httpclient.execute(httpDelete)) {
        return StreamUtil.getResultFromHttpResponse(response);
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpDelete(org.apache.http.client.methods.HttpDelete) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Example 83 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project azure-tools-for-java by Microsoft.

the class SparkInteractiveSessions method killSession.

/**
     * kill session
     *
     * @param connectUrl : eg http://localhost:8998/sessions
     * @param sessionId  : session id
     * @return response result
     * @throws IOException
     */
public HttpResponse killSession(String connectUrl, int sessionId) throws IOException {
    CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
    HttpDelete httpDelete = new HttpDelete(connectUrl + "/" + sessionId);
    httpDelete.addHeader("Content-Type", "application/json");
    try (CloseableHttpResponse response = httpclient.execute(httpDelete)) {
        return StreamUtil.getResultFromHttpResponse(response);
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpDelete(org.apache.http.client.methods.HttpDelete) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Example 84 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project camel by apache.

the class CxfRsRouterTest method testPostConsumer.

@Test
public void testPostConsumer() throws Exception {
    HttpPost post = new HttpPost("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers");
    post.addHeader("Accept", "text/xml");
    StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
    entity.setContentType("text/xml; charset=ISO-8859-1");
    post.setEntity(entity);
    CloseableHttpClient httpclient = HttpClientBuilder.create().build();
    try {
        HttpResponse response = httpclient.execute(post);
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>124</id><name>Jack</name></Customer>", EntityUtils.toString(response.getEntity()));
        HttpDelete del = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/");
        response = httpclient.execute(del);
        // need to check the response of delete method
        assertEquals(200, response.getStatusLine().getStatusCode());
    } finally {
        httpclient.close();
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpDelete(org.apache.http.client.methods.HttpDelete) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.Test)

Example 85 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project robolectric by robolectric.

the class ParamsParserTest method parseParams_returnsNullForUnsupportedOperations.

@Test
public void parseParams_returnsNullForUnsupportedOperations() throws Exception {
    HttpDelete httpDelete = new HttpDelete("http://example.com/deleteme");
    assertThat(ParamsParser.parseParams(httpDelete)).isEmpty();
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) Test(org.junit.Test)

Aggregations

HttpDelete (org.apache.http.client.methods.HttpDelete)108 HttpResponse (org.apache.http.HttpResponse)25 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)22 Test (org.junit.Test)21 HttpGet (org.apache.http.client.methods.HttpGet)16 HttpPut (org.apache.http.client.methods.HttpPut)16 HttpPost (org.apache.http.client.methods.HttpPost)15 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)14 IOException (java.io.IOException)12 Deployment (org.activiti.engine.test.Deployment)12 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)11 Task (org.activiti.engine.task.Task)9 StringEntity (org.apache.http.entity.StringEntity)9 URI (java.net.URI)7 RequestExecutor (org.apache.stanbol.commons.testing.http.RequestExecutor)7 URISyntaxException (java.net.URISyntaxException)6 Header (org.apache.http.Header)6 HttpEntity (org.apache.http.HttpEntity)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 User (org.activiti.engine.identity.User)5