Search in sources :

Example 66 with ContainerResponse

use of org.everrest.core.impl.ContainerResponse in project che by eclipse.

the class ProjectServiceTest method testDeleteInvalidPath.

@Test
public void testDeleteInvalidPath() throws Exception {
    ContainerResponse response = launcher.service(DELETE, "http://localhost:8080/api/project/my_project/a/b/c", "http://localhost:8080/api", null, null, null);
    assertEquals(response.getStatus(), 204);
    assertNotNull(pm.getProject("my_project"));
}
Also used : ContainerResponse(org.everrest.core.impl.ContainerResponse) Test(org.testng.annotations.Test)

Example 67 with ContainerResponse

use of org.everrest.core.impl.ContainerResponse in project che by eclipse.

the class ETagResponseFilterTest method filterSingleEntityTest.

/**
     * Check if ETag is generated for a simple entity of JSON
     */
@Test
public void filterSingleEntityTest() throws Exception {
    final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/single", BASE_URI, null, null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    // check entity
    Assert.assertEquals(response.getEntity(), "hello");
    // Check etag
    List<Object> headerTags = response.getHttpHeaders().get("ETag");
    Assert.assertNotNull(headerTags);
    Assert.assertEquals(headerTags.size(), 1);
    Assert.assertEquals(headerTags.get(0), new EntityTag("5d41402abc4b2a76b9719d911017c592"));
}
Also used : ContainerResponse(org.everrest.core.impl.ContainerResponse) EntityTag(javax.ws.rs.core.EntityTag) Test(org.testng.annotations.Test)

Example 68 with ContainerResponse

use of org.everrest.core.impl.ContainerResponse in project che by eclipse.

the class ServiceDescriptorTest method getDescriptor.

private ServiceDescriptor getDescriptor() throws Exception {
    String path = SERVICE_URI;
    ContainerResponse response = launcher.service(HttpMethod.OPTIONS, path, BASE_URI, null, null, null, null);
    Assert.assertEquals(response.getStatus(), 200);
    return (ServiceDescriptor) response.getEntity();
}
Also used : ContainerResponse(org.everrest.core.impl.ContainerResponse) ServiceDescriptor(org.eclipse.che.api.core.rest.shared.dto.ServiceDescriptor)

Example 69 with ContainerResponse

use of org.everrest.core.impl.ContainerResponse in project che by eclipse.

the class ETagResponseFilterTest method useExistingHeaders.

/**
     * Check if ETag is added in response if we're also using a custom header
     */
@Test
public void useExistingHeaders() throws Exception {
    final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/modify", BASE_URI, null, null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    // check entity
    Assert.assertEquals(response.getEntity(), "helloContent");
    // headers = 2
    Assert.assertEquals(response.getHttpHeaders().keySet().size(), 3);
    // Check custom header
    List<Object> customTags = response.getHttpHeaders().get(HttpHeaders.CONTENT_DISPOSITION);
    Assert.assertNotNull(customTags);
    Assert.assertEquals(customTags.size(), 1);
    Assert.assertEquals(customTags.get(0), "attachment; filename=my.json");
    // Check etag
    List<Object> headerTags = response.getHttpHeaders().get("ETag");
    Assert.assertNotNull(headerTags);
    Assert.assertEquals(headerTags.get(0), new EntityTag("77e671575d94cfd400ed26c5ef08e0fd"));
}
Also used : ContainerResponse(org.everrest.core.impl.ContainerResponse) EntityTag(javax.ws.rs.core.EntityTag) Test(org.testng.annotations.Test)

Aggregations

ContainerResponse (org.everrest.core.impl.ContainerResponse)69 Test (org.testng.annotations.Test)68 List (java.util.List)35 LinkedList (java.util.LinkedList)34 ArrayList (java.util.ArrayList)33 Collections.singletonList (java.util.Collections.singletonList)33 HashMap (java.util.HashMap)22 ItemReference (org.eclipse.che.api.project.shared.dto.ItemReference)22 LinkedHashMap (java.util.LinkedHashMap)20 LinkedHashSet (java.util.LinkedHashSet)15 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)12 MoveOptions (org.eclipse.che.api.project.shared.dto.MoveOptions)8 CopyOptions (org.eclipse.che.api.project.shared.dto.CopyOptions)6 TreeElement (org.eclipse.che.api.project.shared.dto.TreeElement)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 EntityTag (javax.ws.rs.core.EntityTag)5 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)5 ServerException (org.eclipse.che.api.core.ServerException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4