CookieSessionTracking extends BaseSessionTracking implements SessionTracking { private String cookiePath() { if (contextPath != null) { return contextPath; } return DEFAULT_CONTEXT_PATH; }  @Override IdAndSource retrieveId(RequestWithSession request); @Override void propagateSession(RequestWithSession request, Object response); @Override void configure(SessionConfiguration conf); @Override boolean isCookieTracking();  }
@Test public void testCookiePath() { SessionConfiguration sc = new SessionConfiguration(); sc.setSessionIdName("somesession"); sc.setAttribute(CookieSessionTracking.COOKIE_CONTEXT_PATH_PARAMETER, COOKIE_PATH_TEST); cookieSessionTracking.configure(sc); RequestWithSession request = mock(RequestWithSession.class, withSettings().extraInterfaces(HttpServletRequest.class)); when(((HttpServletRequest) request).getContextPath()).thenReturn("path"); RepositoryBackedSession session = mock(RepositoryBackedSession.class); when(session.getId()).thenReturn("123"); when(session.isValid()).thenReturn(true); when(request.getRepositoryBackedSession(false)).thenReturn(session); HttpServletResponse response = mock(HttpServletResponse.class); cookieSessionTracking.propagateSession(request, response); ArgumentCaptor<Cookie> cookie = ArgumentCaptor.forClass(Cookie.class); verify(response).addCookie(cookie.capture()); assertEquals("somesession", cookie.getValue().getName()); assertEquals("123", cookie.getValue().getValue()); assertEquals(-1, cookie.getValue().getMaxAge()); assertEquals(COOKIE_PATH_TEST, cookie.getValue().getPath()); }