HttpRequestWrapper extends HttpServletRequestWrapper implements RequestWithSession { public HttpRequestWrapper(HttpServletRequest req, ServletContext servletContext) { super(req); this.servletContext = servletContext; manager = (SessionManager)servletContext.getAttribute(Attributes.SESSION_MANAGER); ServletRequest originalRequest = req; while (originalRequest instanceof ServletRequestWrapper) { if (originalRequest instanceof HttpRequestWrapper) { break; } originalRequest = ((ServletRequestWrapper)originalRequest).getRequest(); } embeddedRequest = (originalRequest instanceof HttpRequestWrapper) ? (HttpRequestWrapper)originalRequest : null; } HttpRequestWrapper(HttpServletRequest req, ServletContext servletContext); @Override RepositoryBackedHttpSession getSession(); @Override RepositoryBackedHttpSession getSession(boolean create); SessionManager getManager(); HttpResponseWrapper getResponse(); void setResponse(HttpResponseWrapper response); void commit(); @Override RepositoryBackedHttpSession getRepositoryBackedSession(boolean create); @Override ServletContext getServletContext(); HttpRequestWrapper getEmbeddedRequest(); boolean isPropagateOnCreate(); void setPropagateOnCreate(boolean propagate); @Override boolean isIdRetrieved(); @Override void setRequestedSessionId(String id, boolean isFromCookie); @Override String getRequestedSessionId(); @Override boolean isRequestedSessionIdFromCookie(); @Override boolean isRequestedSessionIdFromURL(); @Override boolean isRequestedSessionIdFromUrl(); @Override boolean isRequestedSessionIdValid(); @Override boolean isRepositoryChecked(); @Override void repositoryChecked(); String encodeURL(String url); @Override String changeSessionId();  }
@Test public void testHttpRequestWrapper() { HttpServletRequest wrappedSimple = mock(HttpServletRequest.class); HttpRequestWrapper req = new HttpRequestWrapper(wrappedSimple, servletContext); assertNull(req.getEmbeddedRequest()); assertEquals(wrappedSimple, req.getRequest()); assertEquals(servletContext, req.getServletContext()); assertEquals(sessionManager, req.getManager()); }