ResponseUtils { public static void setPreventionCachingHeaders( HttpServletResponse response) { if (response != null) { response.setHeader(HEADER_PRAGMA, "no-cache"); response.setDateHeader(HEADER_EXPIRES, 1L); response.setHeader(HEADER_CACHE_CONTROL, "private,no-store,no-cache,must-revalidate"); } } private  ResponseUtils(); static void setPreventionCachingHeaders(
            HttpServletResponse response);  }
@Test public void testSetPreventionCachingHeaders() { ResponseUtils.setPreventionCachingHeaders(response); assertThat(response.getHeader("Cache-Control"), is( "private,no-store,no-cache,must-revalidate")); assertThat(response.getHeader("Pragma"), is("no-cache")); assertThat(response.getHeader("Expires"), is( "Thu, 01 Jan 1970 00:00:00 GMT")); }
@Test public void testSetPreventionCachingHeadersWithNullResponse() { try { ResponseUtils.setPreventionCachingHeaders(null); } catch (Exception ex) { ex.printStackTrace(); fail(); } }