final Long currentTime = new Date().getTime();
request.addHeader(ConditionalAbstractResource.HEADER_IF_MODIFIED_SINCE, currentTime);
request.addHeader(ConditionalAbstractResource.HEADER_IF_NONE_MATCH, "\"1234\", \"5678\"");
ConditionalAbstractResource resource = new ConditionalAbstractResource()
{
public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
if (!sendConditional(request, response, "\"5678\"", currentTime + 5000))
{
response.sendError(HttpServletResponse.SC_OK);
}
}
public String getResourcePath()
{
return null;
}
};
resource.getResource(request, response);
assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_LAST_MODIFIED), currentTime + 5000);
assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_ETAG), "\"5678\"");