use of org.everrest.core.impl.ContainerResponse in project che by eclipse.
the class ETagResponseFilterTest method filterSingleEntityTestWithEtag.
/**
* Check if ETag sent with header is redirecting to NOT_MODIFIED
*/
@Test
public void filterSingleEntityTestWithEtag() throws Exception {
Map<String, List<String>> headers = new HashMap<>();
headers.put("If-None-Match", Collections.singletonList(new EntityTag("5d41402abc4b2a76b9719d911017c592").toString()));
final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/single", BASE_URI, headers, null, null);
assertEquals(response.getStatus(), NOT_MODIFIED.getStatusCode());
// check null body
Assert.assertNull(response.getEntity());
}
use of org.everrest.core.impl.ContainerResponse in project che by eclipse.
the class DownloadFileResponseFilterTest method checkOnlyOnGetMethodTest.
/**
* Check that parameter is only handled if there is a GET method, not POST
*/
@Test
public void checkOnlyOnGetMethodTest() throws Exception {
final ContainerResponse response = resourceLauncher.service(HttpMethod.POST, SERVICE_PATH + "/modify?" + DownloadFileResponseFilter.QUERY_DOWNLOAD_PARAMETER + "=hello.json", BASE_URI, null, null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
// check entity
Assert.assertEquals(response.getEntity(), "helloContent");
// headers = 2
Assert.assertEquals(response.getHttpHeaders().size(), 1);
// Check custom header
List<Object> headers = response.getHttpHeaders().get(HttpHeaders.CONTENT_DISPOSITION);
Assert.assertNull(headers);
}
use of org.everrest.core.impl.ContainerResponse in project che by eclipse.
the class DownloadFileResponseFilterTest method checkDownloadFileWithParameter.
/**
* Check if header for downloading is added in response if we're also using a custom header
*/
@Test
public void checkDownloadFileWithParameter() throws Exception {
final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/list?" + DownloadFileResponseFilter.QUERY_DOWNLOAD_PARAMETER + "=hello.json", BASE_URI, null, null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
// check entity
Assert.assertEquals(response.getEntity(), Arrays.asList("a", "b", "c"));
// headers = 2
Assert.assertEquals(response.getHttpHeaders().size(), 2);
// Check custom header
List<Object> headers = response.getHttpHeaders().get(HttpHeaders.CONTENT_DISPOSITION);
Assert.assertNotNull(headers);
Assert.assertEquals(headers.size(), 1);
Assert.assertEquals(headers.get(0), "attachment; filename=hello.json");
}
use of org.everrest.core.impl.ContainerResponse in project che by eclipse.
the class DownloadFileResponseFilterTest method checkNoParameterTest.
/**
* Check if header is absent when parameter is empty
*/
@Test
public void checkNoParameterTest() throws Exception {
final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/list", BASE_URI, null, null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
// check entity
Assert.assertEquals(response.getEntity(), Arrays.asList("a", "b", "c"));
// Check headers
MultivaluedMap<String, Object> headerTags = response.getHttpHeaders();
Assert.assertNotNull(headerTags);
Assert.assertEquals(headerTags.size(), 1);
}
use of org.everrest.core.impl.ContainerResponse in project che by eclipse.
the class ETagResponseFilterTest method filterListEntityTest.
/**
* Check if ETag is generated for a list of JSON
*/
@Test
public void filterListEntityTest() throws Exception {
final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/list", BASE_URI, null, null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
// check entity
Assert.assertEquals(response.getEntity(), Arrays.asList("a", "b", "c"));
// Check etag
List<Object> headerTags = response.getHttpHeaders().get("ETag");
Assert.assertNotNull(headerTags);
Assert.assertEquals(headerTags.size(), 1);
Assert.assertEquals(headerTags.get(0), new EntityTag("900150983cd24fb0d6963f7d28e17f72"));
}
Aggregations