Search in sources :

Example 31 with HttpDelete

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

the class TaskResourceTest method testDeleteUnexistingTask.

/**
   * Test updating an unexisting task.
   * PUT runtime/tasks/{taskId}
   */
public void testDeleteUnexistingTask() throws Exception {
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, "unexistingtask"));
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NOT_FOUND));
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete)

Example 32 with HttpDelete

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

the class TaskVariableResourceTest method testDeleteTaskVariable.

/**
   * Test deleting a single task variable in all scopes, including "not found" check.
   * 
   * DELETE runtime/tasks/{taskId}/variables/{variableName}
   */
@Deployment
public void testDeleteTaskVariable() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.singletonMap("overlappingVariable", (Object) "processValue"));
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.setVariableLocal(task.getId(), "overlappingVariable", "taskValue");
    taskService.setVariableLocal(task.getId(), "anotherTaskVariable", "taskValue");
    // Delete variable without scope, local should be presumed -> local removed and global should be retained
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_VARIABLE, task.getId(), "overlappingVariable"));
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
    assertFalse(taskService.hasVariableLocal(task.getId(), "overlappingVariable"));
    assertTrue(taskService.hasVariable(task.getId(), "overlappingVariable"));
    // Delete local scope variable
    httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_VARIABLE, task.getId(), "anotherTaskVariable") + "?scope=local");
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
    assertFalse(taskService.hasVariableLocal(task.getId(), "anotherTaskVariable"));
    // Delete global scope variable
    assertTrue(taskService.hasVariable(task.getId(), "overlappingVariable"));
    httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_VARIABLE, task.getId(), "overlappingVariable") + "?scope=global");
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
    assertFalse(taskService.hasVariable(task.getId(), "overlappingVariable"));
    // Run the same delete again, variable is not there so 404 should be returned
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NOT_FOUND));
}
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 33 with HttpDelete

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

the class TaskVariablesCollectionResourceTest method testDeleteAllLocalVariables.

/**
   * Test deleting all local task variables.
   * DELETE runtime/tasks/{taskId}/variables
   */
@Deployment
public void testDeleteAllLocalVariables() throws Exception {
    // Start process with all types of variables
    Map<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("var1", "This is a ProcVariable");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", processVariables);
    // Set local task variables
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    Map<String, Object> taskVariables = new HashMap<String, Object>();
    taskVariables.put("var1", "This is a TaskVariable");
    taskVariables.put("var2", 123);
    taskService.setVariablesLocal(task.getId(), taskVariables);
    assertEquals(2, taskService.getVariablesLocal(task.getId()).size());
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_VARIABLES_COLLECTION, task.getId()));
    closeResponse(executeBinaryRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
    // Check if local variables are gone and global remain unchanged
    assertEquals(0, taskService.getVariablesLocal(task.getId()).size());
    assertEquals(1, taskService.getVariables(task.getId()).size());
}
Also used : Task(org.activiti.engine.task.Task) HttpDelete(org.apache.http.client.methods.HttpDelete) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 34 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project undertow by undertow-io.

the class SimpleBlockingServerTestCase method testDeleteRequests.

@Test
public void testDeleteRequests() throws IOException {
    message = "My HTTP Request!";
    TestHttpClient client = new TestHttpClient();
    HttpDelete delete = new HttpDelete(DefaultServer.getDefaultServerURL() + "/path");
    try {
        for (int i = 0; i < 3; ++i) {
            //WFLY-1540 run a few requests to make sure persistent re
            HttpResponse result = client.execute(delete);
            Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
            Assert.assertEquals(message, HttpClientUtils.readResponse(result));
        }
    } finally {
        client.getConnectionManager().shutdown();
    }
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HttpResponse(org.apache.http.HttpResponse) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test)

Example 35 with HttpDelete

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

the class RFC4918DestinationHeaderTest method testMove.

public void testMove() throws IOException, DavException, URISyntaxException {
    String testuri = this.root + "movetest";
    String destinationuri = testuri + "2";
    String destinationpath = new URI(destinationuri).getRawPath();
    // make sure the scheme is removed
    assertFalse(destinationpath.contains(":"));
    try {
        HttpPut put = new HttpPut(testuri);
        int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
        // try to move outside the servlet's name space
        HttpMove move = new HttpMove(testuri, "/foobar", true);
        status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 502);
        // try a relative path
        move = new HttpMove(testuri, "foobar", true);
        status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 400);
        move = new HttpMove(testuri, destinationpath, true);
        status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
        HttpHead head = new HttpHead(destinationuri);
        status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 200);
        head = new HttpHead(testuri);
        status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 404);
    } finally {
        HttpDelete delete = new HttpDelete(testuri);
        int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
        delete = new HttpDelete(destinationuri);
        status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
    }
}
Also used : HttpMove(org.apache.jackrabbit.webdav.client.methods.HttpMove) HttpDelete(org.apache.http.client.methods.HttpDelete) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) HttpHead(org.apache.http.client.methods.HttpHead)

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