Search in sources :

Example 16 with EntityTag

use of javax.ws.rs.core.EntityTag in project cxf by apache.

the class RequestImplTest method testStrictEtagsPreconditionNotMet.

@Test
public void testStrictEtagsPreconditionNotMet() {
    metadata.putSingle("If-Match", new EntityTag("123", true).toString());
    ResponseBuilder rb = new RequestImpl(m).evaluatePreconditions(new EntityTag("123"));
    assertEquals("Precondition must not be met, strict comparison is required", 412, rb.build().getStatus());
}
Also used : EntityTag(javax.ws.rs.core.EntityTag) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Test(org.junit.Test)

Example 17 with EntityTag

use of javax.ws.rs.core.EntityTag in project cxf by apache.

the class RequestImplTest method testStarEtagsIfNotMatchPut.

@Test
public void testStarEtagsIfNotMatchPut() {
    metadata.putSingle(HttpHeaders.IF_NONE_MATCH, "*");
    m.put(Message.HTTP_REQUEST_METHOD, "PUT");
    ResponseBuilder rb = new RequestImpl(m).evaluatePreconditions(new EntityTag("123"));
    assertEquals("Precondition must not be met", 412, rb.build().getStatus());
}
Also used : EntityTag(javax.ws.rs.core.EntityTag) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Test(org.junit.Test)

Example 18 with EntityTag

use of javax.ws.rs.core.EntityTag in project cxf by apache.

the class RequestImplTest method testStarEtags.

@Test
public void testStarEtags() {
    metadata.putSingle("If-Match", "*");
    ResponseBuilder rb = new RequestImpl(m).evaluatePreconditions(new EntityTag("123"));
    assertNull("Precondition must be met", rb);
}
Also used : EntityTag(javax.ws.rs.core.EntityTag) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Test(org.junit.Test)

Example 19 with EntityTag

use of javax.ws.rs.core.EntityTag in project cxf by apache.

the class RequestImplTest method testStrictEtagsPreconditionMet.

@Test
public void testStrictEtagsPreconditionMet() {
    metadata.putSingle("If-Match", new EntityTag("123").toString());
    ResponseBuilder rb = new RequestImpl(m).evaluatePreconditions(new EntityTag("123"));
    assertNull("Precondition must be met", rb);
}
Also used : EntityTag(javax.ws.rs.core.EntityTag) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Test(org.junit.Test)

Example 20 with EntityTag

use of javax.ws.rs.core.EntityTag in project cxf by apache.

the class EntityTagHeaderProviderTest method testToString.

@Test
public void testToString() {
    EntityTag tag = new EntityTag("");
    assertEquals("\"\"", tag.toString());
    tag = new EntityTag("", true);
    assertEquals("W/\"\"", tag.toString());
    tag = new EntityTag("bar");
    assertEquals("\"bar\"", tag.toString());
}
Also used : EntityTag(javax.ws.rs.core.EntityTag) Test(org.junit.Test)

Aggregations

EntityTag (javax.ws.rs.core.EntityTag)77 Response (javax.ws.rs.core.Response)28 GET (javax.ws.rs.GET)27 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)25 Path (javax.ws.rs.Path)24 CacheControl (javax.ws.rs.core.CacheControl)20 Test (org.junit.Test)18 Produces (javax.ws.rs.Produces)16 Date (java.util.Date)10 Test (org.testng.annotations.Test)9 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)8 Timestamp (com.yahoo.rdl.Timestamp)5 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)5 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 ContainerResponse (org.everrest.core.impl.ContainerResponse)5 Principal (com.yahoo.athenz.auth.Principal)4