JEEContext implements WebContext { @Override public String getPath() { String fullPath = request.getRequestURI(); if (fullPath == null) { return ""; } if (fullPath.startsWith(" fullPath = fullPath.substring(1); } final String context = request.getContextPath(); if (context != null) { return fullPath.substring(context.length()); } return fullPath; } JEEContext(final HttpServletRequest request, final HttpServletResponse response);  JEEContext(final HttpServletRequest request, final HttpServletResponse response, final SessionStore sessionStore); @Override SessionStore getSessionStore(); @Override Optional<String> getRequestParameter(final String name); @Override Optional getRequestAttribute(final String name); @Override void setRequestAttribute(final String name, final Object value); @Override Map<String, String[]> getRequestParameters(); @Override Optional<String> getRequestHeader(final String name); @Override String getRequestMethod(); @Override String getRemoteAddr(); HttpServletRequest getNativeRequest(); HttpServletResponse getNativeResponse(); @Override void setResponseHeader(final String name, final String value); @Override void setResponseContentType(final String content); @Override String getServerName(); @Override int getServerPort(); @Override String getScheme(); @Override boolean isSecure(); @Override String getFullRequestURL(); @Override Collection<Cookie> getRequestCookies(); @Override void addResponseCookie(final Cookie cookie); @Override String getPath(); @Override String getRequestContent(); @Override String getProtocol();  }
@Test public void testGetPathNullFullPath() { when(request.getRequestURI()).thenReturn(null); final JEEContext context = new JEEContext(request, response); assertEquals("", context.getPath()); }
@Test public void testGetPathFullpath() { when(request.getRequestURI()).thenReturn(CTX_PATH); final JEEContext context = new JEEContext(request, response); assertEquals(CTX_PATH, context.getPath()); }
@Test public void testGetPathFullpathContext() { when(request.getRequestURI()).thenReturn(CTX_PATH); when(request.getContextPath()).thenReturn(CTX); final JEEContext context = new JEEContext(request, response); assertEquals(PATH, context.getPath()); }
@Test public void testGetPathDoubleSlashFullpathContext() { when(request.getRequestURI()).thenReturn("/" + CTX_PATH); when(request.getContextPath()).thenReturn(CTX); final JEEContext context = new JEEContext(request, response); assertEquals(PATH, context.getPath()); }