use of javax.ws.rs.core.EntityTag 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 javax.ws.rs.core.EntityTag 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"));
}
use of javax.ws.rs.core.EntityTag in project che by eclipse.
the class ETagResponseFilterTest method filterListEntityTestWithEtag.
/**
* Check if ETag sent with header is redirecting to NOT_MODIFIED
*/
@Test
public void filterListEntityTestWithEtag() throws Exception {
Map<String, List<String>> headers = new HashMap<>();
headers.put("If-None-Match", Collections.singletonList(new EntityTag("900150983cd24fb0d6963f7d28e17f72").toString()));
final ContainerResponse response = resourceLauncher.service(HttpMethod.GET, SERVICE_PATH + "/list", BASE_URI, headers, null, null);
assertEquals(response.getStatus(), NOT_MODIFIED.getStatusCode());
// check null body
Assert.assertNull(response.getEntity());
}
use of javax.ws.rs.core.EntityTag in project jersey by jersey.
the class ContainerRequestTest method testPreconditionsMatch.
@Test
public void testPreconditionsMatch() {
ContainerRequest r = new ContainerRequest(URI.create("http://example.org/app"), URI.create("http://example.org/app/resource"), "GET", SECURITY_CONTEXT, new MapPropertiesDelegate());
r.header(HttpHeaders.IF_MATCH, "\"686897696a7c876b7e\"");
assertNull(r.evaluatePreconditions(new EntityTag("686897696a7c876b7e")));
assertEquals(r.evaluatePreconditions(new EntityTag("0")).build().getStatus(), Response.Status.PRECONDITION_FAILED.getStatusCode());
}
use of javax.ws.rs.core.EntityTag in project jersey by jersey.
the class MatchingEntityTagTest method testOneEntityTag.
@Test
public void testOneEntityTag() throws Exception {
String header = "\"1\"";
Set<MatchingEntityTag> s = HttpHeaderReader.readMatchingEntityTag(header);
assertEquals(1, s.size());
assertTrue(s.contains(new EntityTag("1")));
}
Aggregations