Class RequestContext


  • public class RequestContext
    extends Object
    The request context serves multiple purposes:
    • Provides the request and response object through a ThreadLocal. This means that these do not have to passed as parameters to methods.
    • If there is no request/response object available then Mock versions are used. This makes it possible to run logic in a test environment outside of the servlet container.
    • Makes it possible to set request parameters to simulate a request from a client to a server.
    Author:
    mtaal
    • Constructor Detail

      • RequestContext

        public RequestContext()
    • Method Detail

      • getServletContext

        public static javax.servlet.ServletContext getServletContext()
      • setServletContext

        public static void setServletContext​(javax.servlet.ServletContext aServletContext)
      • clear

        public static void clear()
      • getRequestContent

        public String getRequestContent()
      • getRequestParameter

        public String getRequestParameter​(String name)
      • getParameterMap

        public Map<?,​?> getParameterMap()
      • setRequestParameter

        public void setRequestParameter​(String name,
                                        String value)
      • getSessionAttribute

        public Object getSessionAttribute​(String name)
      • getSessionAttributeNames

        public Enumeration<?> getSessionAttributeNames()
      • setSessionAttribute

        public void setSessionAttribute​(String name,
                                        Object value)
      • removeSessionAttribute

        public void removeSessionAttribute​(String name)
      • getSession

        public javax.servlet.http.HttpSession getSession()
      • getRequest

        public javax.servlet.http.HttpServletRequest getRequest()
      • setRequestContent

        public void setRequestContent​(String requestContent)
      • setVariableSecureApp

        public void setVariableSecureApp​(VariablesSecureApp variablesSecureApp)
      • setRequest

        public void setRequest​(javax.servlet.http.HttpServletRequest request)
      • getResponse

        public javax.servlet.http.HttpServletResponse getResponse()
        This method makes only sense to be invoked from a Request in a servlet container, other cases response will be null
      • setResponse

        public void setResponse​(javax.servlet.http.HttpServletResponse response)