@SuppressWarnings("unchecked") @Test public void testGetRequestCookieMap4() { ServletContext servletContext = PowerMock.createNiceMock(ServletContext.class); HttpServletRequest request = PowerMock.createNiceMock(HttpServletRequest.class); HttpServletResponse response = PowerMock.createNiceMock(HttpServletResponse.class); Cookie cookie = new Cookie("foo", "bar"); expect(request.getCookies()).andReturn(new Cookie[]{cookie}).anyTimes(); replay(servletContext, request, response); ExternalContextImpl externalContext = new ExternalContextImpl(servletContext, request, response); verify(servletContext, request, response); Map<String, Object> requestCookieMap = externalContext.getRequestCookieMap(); boolean exceptionThrown = false; try { requestCookieMap.clear(); } catch (UnsupportedOperationException e) { exceptionThrown = true; } assertTrue(exceptionThrown); verifySupplier(() -> requestCookieMap.put("foot", "bar")); verifyConsumer(m -> requestCookieMap.putAll((Map<? extends String, ? extends Object>) m), new HashMap<>()); verifySupplier(() -> requestCookieMap.remove("foo")); }
@Override public Map<String,Object> getRequestCookieMap() { if (null == cookieMap) { cookieMap = Collections.unmodifiableMap( new RequestCookieMap((HttpServletRequest) request)); } return cookieMap; }
ExternalContextImpl extends ExternalContext { @Override public Map<String,Object> getRequestCookieMap() { if (null == cookieMap) { cookieMap = Collections.unmodifiableMap( new RequestCookieMap((HttpServletRequest) request)); } return cookieMap; } }
ExternalContextImpl extends ExternalContext { @Override public Map<String,Object> getRequestCookieMap() { if (null == cookieMap) { cookieMap = Collections.unmodifiableMap( new RequestCookieMap((HttpServletRequest) request)); } return cookieMap; } ExternalContextImpl(ServletContext sc,
                               ServletRequest request,
                               ServletResponse response); }
ExternalContextImpl extends ExternalContext { @Override public Map<String,Object> getRequestCookieMap() { if (null == cookieMap) { cookieMap = Collections.unmodifiableMap( new RequestCookieMap((HttpServletRequest) request)); } return cookieMap; } ExternalContextImpl(ServletContext sc,
                               ServletRequest request,
                               ServletResponse response); @Override Object getSession(boolean create); @Override String getSessionId(boolean create); @Override Object getContext(); @Override String getContextName(); @Override Object getRequest(); @Override void setRequest(Object request); @Override void setRequestCharacterEncoding(String encoding); @Override Object getResponse(); @Override void setResponse(Object response); @Override ClientWindow getClientWindow(); @Override void setClientWindow(ClientWindow window); @Override void setResponseCharacterEncoding(String encoding); @Override Map<String,Object> getApplicationMap(); @Override String getApplicationContextPath(); @Override Map<String,Object> getSessionMap(); @Override Map<String,Object> getRequestMap(); @Override Map<String,String> getRequestHeaderMap(); @Override Map<String,String[]> getRequestHeaderValuesMap(); @Override Map<String,Object> getRequestCookieMap(); @Override Map<String,String> getInitParameterMap(); @Override Map<String,String> getRequestParameterMap(); @Override Map<String,String[]> getRequestParameterValuesMap(); @Override Iterator<String> getRequestParameterNames(); @Override Locale getRequestLocale(); @Override Iterator<Locale> getRequestLocales(); @Override String getRequestPathInfo(); @Override String getRealPath(String path); @Override String getRequestContextPath(); @Override String getRequestServletPath(); @Override String getRequestCharacterEncoding(); @Override String getRequestContentType(); @Override int getRequestContentLength(); @Override String getResponseCharacterEncoding(); @Override String getResponseContentType(); @Override String getInitParameter(String name); @Override Set<String> getResourcePaths(String path); @Override InputStream getResourceAsStream(String path); @Override URL getResource(String path); @Override String encodeActionURL(String url); @Override String encodeResourceURL(String url); @Override String encodeWebsocketURL(String url); @Override String encodeNamespace(String name); @Override void dispatch(String requestURI); @Override void redirect(String requestURI); @Override void log(String message); @Override void log(String message, Throwable throwable); @Override String getAuthType(); @Override String getMimeType(String file); @Override String getRemoteUser(); @Override java.security.Principal getUserPrincipal(); @Override boolean isUserInRole(String role); @Override void invalidateSession(); @Override void addResponseCookie(String name,
                                  String value,
                                  Map<String,Object> properties); @Override OutputStream getResponseOutputStream(); @Override Writer getResponseOutputWriter(); @Override String getRequestScheme(); @Override String getRequestServerName(); @Override int getRequestServerPort(); @Override void setResponseContentType(String contentType); @Override void setResponseHeader(String name, String value); @Override void addResponseHeader(String name, String value); @Override void setResponseBufferSize(int size); @Override boolean isResponseCommitted(); @Override void responseReset(); @Override void responseSendError(int statusCode, String message); @Override void setResponseStatus(int statusCode); @Override void responseFlushBuffer(); @Override void setResponseContentLength(int length); @Override void setSessionMaxInactiveInterval(int interval); @Override int getResponseBufferSize(); @Override int getSessionMaxInactiveInterval(); @Override boolean isSecure(); @Override String encodeBookmarkableURL(String baseUrl,
                                        Map<String, List<String>> parameters); @Override String encodeRedirectURL(String baseUrl,
                                    Map<String, List<String>> parameters); @Override String encodePartialActionURL(String url); @Override Flash getFlash(); String getFallbackMimeType(String file); }
ExternalContextImpl extends ExternalContext { @Override public Map<String,Object> getRequestCookieMap() { if (null == cookieMap) { cookieMap = Collections.unmodifiableMap( new RequestCookieMap((HttpServletRequest) request)); } return cookieMap; } ExternalContextImpl(ServletContext sc,
                               ServletRequest request,
                               ServletResponse response); @Override Object getSession(boolean create); @Override String getSessionId(boolean create); @Override Object getContext(); @Override String getContextName(); @Override Object getRequest(); @Override void setRequest(Object request); @Override void setRequestCharacterEncoding(String encoding); @Override Object getResponse(); @Override void setResponse(Object response); @Override ClientWindow getClientWindow(); @Override void setClientWindow(ClientWindow window); @Override void setResponseCharacterEncoding(String encoding); @Override Map<String,Object> getApplicationMap(); @Override String getApplicationContextPath(); @Override Map<String,Object> getSessionMap(); @Override Map<String,Object> getRequestMap(); @Override Map<String,String> getRequestHeaderMap(); @Override Map<String,String[]> getRequestHeaderValuesMap(); @Override Map<String,Object> getRequestCookieMap(); @Override Map<String,String> getInitParameterMap(); @Override Map<String,String> getRequestParameterMap(); @Override Map<String,String[]> getRequestParameterValuesMap(); @Override Iterator<String> getRequestParameterNames(); @Override Locale getRequestLocale(); @Override Iterator<Locale> getRequestLocales(); @Override String getRequestPathInfo(); @Override String getRealPath(String path); @Override String getRequestContextPath(); @Override String getRequestServletPath(); @Override String getRequestCharacterEncoding(); @Override String getRequestContentType(); @Override int getRequestContentLength(); @Override String getResponseCharacterEncoding(); @Override String getResponseContentType(); @Override String getInitParameter(String name); @Override Set<String> getResourcePaths(String path); @Override InputStream getResourceAsStream(String path); @Override URL getResource(String path); @Override String encodeActionURL(String url); @Override String encodeResourceURL(String url); @Override String encodeWebsocketURL(String url); @Override String encodeNamespace(String name); @Override void dispatch(String requestURI); @Override void redirect(String requestURI); @Override void log(String message); @Override void log(String message, Throwable throwable); @Override String getAuthType(); @Override String getMimeType(String file); @Override String getRemoteUser(); @Override java.security.Principal getUserPrincipal(); @Override boolean isUserInRole(String role); @Override void invalidateSession(); @Override void addResponseCookie(String name,
                                  String value,
                                  Map<String,Object> properties); @Override OutputStream getResponseOutputStream(); @Override Writer getResponseOutputWriter(); @Override String getRequestScheme(); @Override String getRequestServerName(); @Override int getRequestServerPort(); @Override void setResponseContentType(String contentType); @Override void setResponseHeader(String name, String value); @Override void addResponseHeader(String name, String value); @Override void setResponseBufferSize(int size); @Override boolean isResponseCommitted(); @Override void responseReset(); @Override void responseSendError(int statusCode, String message); @Override void setResponseStatus(int statusCode); @Override void responseFlushBuffer(); @Override void setResponseContentLength(int length); @Override void setSessionMaxInactiveInterval(int interval); @Override int getResponseBufferSize(); @Override int getSessionMaxInactiveInterval(); @Override boolean isSecure(); @Override String encodeBookmarkableURL(String baseUrl,
                                        Map<String, List<String>> parameters); @Override String encodeRedirectURL(String baseUrl,
                                    Map<String, List<String>> parameters); @Override String encodePartialActionURL(String url); @Override Flash getFlash(); String getFallbackMimeType(String file);  }