### Question:
AbstractExpiresHeaderFilter extends AbstractDispatcherCacheHeaderFilter { @Override @SuppressWarnings("unchecked") protected boolean accepts(HttpServletRequest request) { if (super.accepts(request)) { Enumeration<String> expiresheaders = request.getHeaders(EXPIRES_NAME); return expiresheaders == null || !expiresheaders.hasMoreElements(); } return false; }  String toString(); static final String PROP_EXPIRES_TIME; }### Answer:
@Test public void testAcceptsHasExpiresHeader() throws Exception { expires.add("Some Expires Header"); when(request.getHeaders(AbstractExpiresHeaderFilter.EXPIRES_NAME)) .thenReturn(Collections.enumeration(expires)); boolean result = filter.accepts(request); assertFalse(result); verify(request).getHeaders(AbstractExpiresHeaderFilter.EXPIRES_NAME); }
@Test public void testAcceptsNoExpiresHeader() throws Exception { when(request.getHeaders(AbstractExpiresHeaderFilter.EXPIRES_NAME)) .thenReturn(Collections.enumeration(expires)); boolean result = filter.accepts(request); assertTrue(result); verify(request).getHeaders(AbstractExpiresHeaderFilter.EXPIRES_NAME); }
@Test @SuppressWarnings("unchecked") public void testAcceptsCalledParent() throws Exception { params.put("key", "value"); boolean result = filter.accepts(request); assertFalse(result); verify(request, times(0)).getHeaders(AbstractExpiresHeaderFilter.EXPIRES_NAME); }