Search in sources :

Example 16 with Request

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

the class EvaluatePreconditionsTest method testUnconditional200.

@Test
public void testUnconditional200() {
    final Request request = getRequest();
    final Response response = service.perform(request);
    Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(javax.ws.rs.core.Response) Request(javax.ws.rs.core.Request) Test(org.junit.Test)

Example 17 with Request

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

the class EvaluatePreconditionsTest method testIfNoneMatchIfModified304.

@Test
public void testIfNoneMatchIfModified304() {
    final Request request = getRequest(HttpHeaders.IF_MODIFIED_SINCE, dateFormat.format(DATE_OLD), HttpHeaders.IF_NONE_MATCH, ETAG_OLD.toString());
    final Response response = service.perform(request);
    Assert.assertEquals(HttpServletResponse.SC_NOT_MODIFIED, response.getStatus());
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(javax.ws.rs.core.Response) Request(javax.ws.rs.core.Request) Test(org.junit.Test)

Example 18 with Request

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

the class EvaluatePreconditionsTest method testIfModified200.

@Test
public void testIfModified200() {
    service.setLastModified(DATE_NEW);
    final Request request = getRequest(HttpHeaders.IF_MODIFIED_SINCE, dateFormat.format(DATE_OLD));
    final Response response = service.perform(request);
    Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(javax.ws.rs.core.Response) Request(javax.ws.rs.core.Request) Test(org.junit.Test)

Example 19 with Request

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

the class EvaluatePreconditionsTest method testIfNoneMatchIfModified200.

@Test
public void testIfNoneMatchIfModified200() {
    // RFC 2616 / section 14.26
    // "If none of the entity tags match, then the server MAY perform the requested method as
    // if the If-None-Match header field did not exist, but MUST also ignore any If-Modified-Since
    // header field(s) in the request. That is, if no entity tags match, then the server MUST NOT
    // return a 304 (Not Modified) response."
    final Request request = getRequest(HttpHeaders.IF_MODIFIED_SINCE, dateFormat.format(DATE_OLD), HttpHeaders.IF_NONE_MATCH, // ETags don't
    ETAG_NEW.toString());
    // match,
    // If-Modified-Since
    // must be ignored
    final Response response = service.perform(request);
    Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(javax.ws.rs.core.Response) Request(javax.ws.rs.core.Request) Test(org.junit.Test)

Aggregations

Request (javax.ws.rs.core.Request)19 Response (javax.ws.rs.core.Response)12 Test (org.junit.Test)11 HttpServletResponse (javax.servlet.http.HttpServletResponse)9 IOException (java.io.IOException)4 UriInfo (javax.ws.rs.core.UriInfo)3 URISyntaxException (java.net.URISyntaxException)2 List (java.util.List)2 EntityTag (javax.ws.rs.core.EntityTag)2 ApplicationContext (org.everrest.core.ApplicationContext)2 GenericContainerResponse (org.everrest.core.GenericContainerResponse)2 Fault (org.ovirt.engine.api.model.Fault)2 HashCode (com.google.common.hash.HashCode)1 HashFunction (com.google.common.hash.HashFunction)1 Hasher (com.google.common.hash.Hasher)1 APIError (com.liferay.apio.architect.error.APIError)1 ApioLogger (com.liferay.apio.architect.logger.ApioLogger)1 ErrorMessageMapper (com.liferay.apio.architect.message.json.ErrorMessageMapper)1 ExceptionConverterManager (com.liferay.apio.architect.wiring.osgi.manager.ExceptionConverterManager)1 ErrorMessageMapperManager (com.liferay.apio.architect.wiring.osgi.manager.message.json.ErrorMessageMapperManager)1