### Question:
SimpleCachingAcceptHeadersPageCachingFilter extends SimpleCachingHeadersPageCachingFilter { @Override protected String calculateKey(HttpServletRequest httpRequest) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(httpRequest.getRequestURI()).append(httpRequest.getQueryString()); if (httpRequest.getHeader("accept") != null) { String accept = httpRequest.getHeader("accept"); if (accept.contains("json") || accept.contains("n3") || accept.contains("rdf")) { stringBuffer.append(httpRequest.getHeader("accept")); } } return stringBuffer.toString(); }    }### Answer:
@Test public void testCalculateKeyForWebkit() { request.addHeader(acceptHeader, webkitAccept); String key = filter.calculateKey(request); assertEquals("Unexpected key", requestURI + queryString, key); }
@Test public void testCalculateKeyForFirefox() { request.addHeader(acceptHeader, firefoxAccept); String key = filter.calculateKey(request); assertEquals("Unexpected key", requestURI + queryString, key); }
@Test public void testCalculateKeyForJson() { request.addHeader(acceptHeader, jsonAccept); String key = filter.calculateKey(request); assertEquals("Unexpected key", requestURI + queryString + jsonAccept, key); }
@Test public void testCalculateKeyForN3() { request.addHeader(acceptHeader, n3Accept); String key = filter.calculateKey(request); assertEquals("Unexpected key", requestURI + queryString + n3Accept, key); }
@Test public void testCalculateKeyForRdf() { request.addHeader(acceptHeader, rdfAccept); String key = filter.calculateKey(request); assertEquals("Unexpected key", requestURI + queryString + rdfAccept, key); }