Search in sources :

Example 76 with HttpDelete

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

the class GraphMLTopologyIT method deleteGraph.

private void deleteGraph() throws IOException, InterruptedException {
    try (HttpClientWrapper client = createClientWrapper()) {
        HttpDelete httpDelete = new HttpDelete(URL);
        CloseableHttpResponse response = client.execute(httpDelete);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
    // We wait to give the GraphMLMetaTopologyFactory the chance to clean up afterwards
    Thread.sleep(20000);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HttpClientWrapper(org.opennms.core.web.HttpClientWrapper) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Example 77 with HttpDelete

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

the class HttpClientStackTest method createDeleteRequest.

@Test
public void createDeleteRequest() throws Exception {
    TestRequest.Delete request = new TestRequest.Delete();
    assertEquals(request.getMethod(), Method.DELETE);
    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpDelete);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpDelete(org.apache.http.client.methods.HttpDelete) TestRequest(com.android.volley.mock.TestRequest) Test(org.junit.Test)

Example 78 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project nhin-d by DirectProject.

the class AbstractDeleteRequest method createRequest.

/**
    * {@inheritDoc}
    */
@Override
protected final HttpUriRequest createRequest() throws IOException {
    try {
        HttpDelete delete = new HttpDelete(getRequestUri());
        delete.setHeader("Accept", MediaType.APPLICATION_JSON);
        return delete;
    } catch (ServiceException e) {
        throw new IOException("Error creating request URI.", e);
    }
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) IOException(java.io.IOException)

Example 79 with HttpDelete

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

the class TaskAttachmentResourceTest method testDeleteAttachment.

/**
   * Test deleting a single attachments for a task
   * DELETE runtime/tasks/{taskId}/attachments/{attachmentId}
   */
public void testDeleteAttachment() throws Exception {
    try {
        Task task = taskService.newTask();
        taskService.saveTask(task);
        // Create URL-attachment
        Attachment urlAttachment = taskService.createAttachment("simpleType", task.getId(), null, "Simple attachment", "Simple attachment description", "http://activiti.org");
        taskService.saveAttachment(urlAttachment);
        // Delete the attachment
        HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, task.getId(), urlAttachment.getId()));
        closeResponse(executeBinaryRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
        // Check if attachment is really deleted
        assertNull(taskService.getAttachment(urlAttachment.getId()));
        // Deleting again should result in 404
        closeResponse(executeBinaryRequest(httpDelete, HttpStatus.SC_NOT_FOUND));
    } finally {
        // Clean adhoc-tasks even if test fails
        List<Task> tasks = taskService.createTaskQuery().list();
        for (Task task : tasks) {
            taskService.deleteTask(task.getId(), true);
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) HttpDelete(org.apache.http.client.methods.HttpDelete) Attachment(org.activiti.engine.task.Attachment)

Example 80 with HttpDelete

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

the class ProcessInstanceVariablesCollectionResourceTest method testDeleteAllProcessVariables.

/**
   * Test deleting all process variables.
   * DELETE runtime/process-instance/{processInstanceId}/variables
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceVariablesCollectionResourceTest.testProcess.bpmn20.xml" })
public void testDeleteAllProcessVariables() throws Exception {
    Map<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("var1", "This is a ProcVariable");
    processVariables.put("var2", 123);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", processVariables);
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE_COLLECTION, processInstance.getId()));
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
    // Check if local variables are gone and global remain unchanged
    assertEquals(0, runtimeService.getVariablesLocal(processInstance.getId()).size());
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

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