StaticResourceServlet extends HttpServlet { static String getEtag(final File resource) { return "W/\"" + resource.length() + "-" + resource.lastModified(); }    }
@Test public void testWithEtag() throws ServletException, IOException { final HashMap<String, String> headers = new HashMap<String, String>(); headers.put("If-None-Match", StaticResourceServlet.getEtag(new File( rootDirectory, "default.css"))); final HttpServletResponse response = doGetTest("default.css", headers); Mockito.verify(response).setStatus(HttpServletResponse.SC_NOT_MODIFIED); }
@Test public void getEtag() { Assert.assertNotNull(StaticResourceServlet.getEtag(new File( rootDirectory, "index.html"))); }