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"));
}
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"));
}
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();
}
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"));
}
Aggregations