SessionLogoutResource { @Timed @ExceptionMetered @POST @Produces(APPLICATION_JSON) public Response logout(@Nullable @CookieParam(value = "session") Cookie sessionCookie) { if (sessionCookie != null) { Optional<User> user = cookieAuthenticator.authenticate(sessionCookie); if (user.isPresent()) { logger.info("User logged out: {}", user.get().getName()); } else { logger.warn("Invalid user cookie on logout."); } } NewCookie expiredCookie = cookieFactory.getExpiredSessionCookie(); return Response.ok() .header(HttpHeaders.SET_COOKIE, expiredCookie.toString()) .build(); } @Inject  SessionLogoutResource(CookieAuthenticator cookieAuthenticator,
      AuthenticatedEncryptedCookieFactory cookieFactory); @Timed @ExceptionMetered @POST @Produces(APPLICATION_JSON) Response logout(@Nullable @CookieParam(value = "session") Cookie sessionCookie);  }
@Test public void logoutResourceDeletesSessionCookie() throws Exception { NewCookie cookie = cookieFactory.getSessionCookie(User.named("Me"), ZonedDateTime.now(clock).plusDays(1)); Response response = sessionLogoutResource.logout(cookie); assertThat(response.getStatus()).isEqualTo(200); String resultCookie = response.getMetadata().getFirst("Set-Cookie").toString(); assertThat(resultCookie) .contains("HttpOnly") .contains("Secure") .contains("Path=/admin;") .contains("session=expired;"); }