HttpRequestWrapper extends HttpServletRequestWrapper implements RequestWithSession { public HttpRequestWrapper getEmbeddedRequest() { return embeddedRequest; } 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 testHttpRequestWrapperOfWrappedRequest() { HttpServletRequest wrappedSimple = mock(HttpServletRequest.class); HttpServletRequest wrappedComplex = new HttpServletRequestWrapper(wrappedSimple); HttpRequestWrapper req = new HttpRequestWrapper(wrappedComplex, servletContext); assertNull(req.getEmbeddedRequest()); assertEquals(wrappedComplex, req.getRequest()); }
@Test public void testHttpRequestWrapperOfHttpRequestWrapper() { HttpServletRequest wrappedSimple = mock(HttpServletRequest.class); HttpRequestWrapper wrappedHttpRequestWrapper = mock(HttpRequestWrapper.class); when(wrappedHttpRequestWrapper.getRequest()).thenReturn(wrappedSimple); HttpServletRequest wrappedComplex = new HttpServletRequestWrapper(wrappedHttpRequestWrapper); HttpRequestWrapper req = new HttpRequestWrapper(wrappedComplex, servletContext); assertEquals(wrappedHttpRequestWrapper, req.getEmbeddedRequest()); assertEquals(wrappedComplex, req.getRequest()); }