MockPortletRequest (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.mock.web.portlet

## Class MockPortletRequest

- java.lang.Object
- - org.springframework.mock.web.portlet.MockPortletRequest

- All Implemented Interfaces:
    PortletRequest
  Direct Known Subclasses:
    MockClientDataRequest, MockEventRequest, MockRenderRequest

      public class MockPortletRequest
      extends Object
      implements PortletRequest

  Mock implementation of the `PortletRequest` interface.
  Since:
    2.0
  Author:
    John A. Lewis, Juergen Hoeller

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface javax.portlet.PortletRequest

      `PortletRequest.P3PUserInfos`

  - ### Field Summary

    - ### Fields inherited from interface javax.portlet.PortletRequest

      `ACTION_PHASE, ACTION_SCOPE_ID, BASIC_AUTH, CCPP_PROFILE, CLIENT_CERT_AUTH, DIGEST_AUTH, EVENT_PHASE, FORM_AUTH, LIFECYCLE_PHASE, RENDER_HEADERS, RENDER_MARKUP, RENDER_PART, RENDER_PHASE, RESOURCE_PHASE, USER_INFO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MockPortletRequest()` Create a new MockPortletRequest with a default `MockPortalContext` and a default `MockPortletContext`.
    `MockPortletRequest(PortalContext portalContext, PortletContext portletContext)` Create a new MockPortletRequest.
    `MockPortletRequest(PortletContext portletContext)` Create a new MockPortletRequest with a default `MockPortalContext`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addLocale(Locale locale)`
    `void` | `addParameter(String name, String value)`
    `void` | `addParameter(String name, String[] values)`
    `void` | `addPreferredLocale(Locale locale)`
    `void` | `addPreferredResponseContentType(String responseContentType)`
    `void` | `addProperty(String key, String value)` Add a single value for the specified property.
    `void` | `addResponseContentType(String responseContentType)`
    `void` | `addUserRole(String role)`
    `protected void` | `checkActive()` Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.
    `void` | `close()` Mark this request as completed.
    `Object` | `getAttribute(String name)`
    `Enumeration<String>` | `getAttributeNames()`
    `String` | `getAuthType()`
    `String` | `getContextPath()`
    `Cookie[]` | `getCookies()`
    `protected String` | `getLifecyclePhase()` Return the Portlet 2.0 lifecycle id for the current phase.
    `Locale` | `getLocale()`
    `Enumeration<Locale>` | `getLocales()`
    `String` | `getParameter(String name)`
    `Map<String,String[]>` | `getParameterMap()`
    `Enumeration<String>` | `getParameterNames()`
    `String[]` | `getParameterValues(String name)`
    `PortalContext` | `getPortalContext()`
    `PortletMode` | `getPortletMode()`
    `PortletSession` | `getPortletSession()`
    `PortletSession` | `getPortletSession(boolean create)`
    `PortletPreferences` | `getPreferences()`
    `Map<String,String[]>` | `getPrivateParameterMap()`
    `Enumeration<String>` | `getProperties(String key)`
    `String` | `getProperty(String key)`
    `Enumeration<String>` | `getPropertyNames()`
    `Map<String,String[]>` | `getPublicParameterMap()`
    `String` | `getRemoteUser()`
    `String` | `getRequestedSessionId()`
    `String` | `getResponseContentType()`
    `Enumeration<String>` | `getResponseContentTypes()`
    `String` | `getScheme()`
    `String` | `getServerName()`
    `int` | `getServerPort()`
    `Principal` | `getUserPrincipal()`
    `String` | `getWindowID()`
    `WindowState` | `getWindowState()`
    `boolean` | `isActive()` Return whether this request is still active (that is, not completed yet).
    `boolean` | `isPortletModeAllowed(PortletMode portletMode)`
    `boolean` | `isRequestedSessionIdValid()`
    `boolean` | `isSecure()`
    `boolean` | `isUserInRole(String role)`
    `boolean` | `isWindowStateAllowed(WindowState windowState)`
    `void` | `registerPublicParameter(String name)`
    `void` | `removeAttribute(String name)`
    `void` | `setAttribute(String name, Object value)`
    `void` | `setAuthType(String authType)`
    `void` | `setContextPath(String contextPath)`
    `void` | `setCookies(Cookie... cookies)`
    `void` | `setParameter(String key, String value)`
    `void` | `setParameter(String key, String[] values)`
    `void` | `setParameters(Map<String,String[]> parameters)`
    `void` | `setPortletMode(PortletMode portletMode)`
    `void` | `setPreferences(PortletPreferences preferences)`
    `void` | `setProperty(String key, String value)` Set a single value for the specified property.
    `void` | `setRemoteUser(String remoteUser)`
    `void` | `setRequestedSessionIdValid(boolean requestedSessionIdValid)`
    `void` | `setScheme(String scheme)`
    `void` | `setSecure(boolean secure)`
    `void` | `setServerName(String serverName)`
    `void` | `setServerPort(int serverPort)`
    `void` | `setSession(PortletSession session)`
    `void` | `setUserPrincipal(Principal userPrincipal)`
    `void` | `setWindowID(String windowID)`
    `void` | `setWindowState(WindowState windowState)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MockPortletRequest

          public MockPortletRequest()

      Create a new MockPortletRequest with a default `MockPortalContext` and a default `MockPortletContext`.
      See Also:
        `MockPortalContext`, `MockPortletContext`

    - #### MockPortletRequest

          public MockPortletRequest(PortletContext portletContext)

      Create a new MockPortletRequest with a default `MockPortalContext`.
      Parameters:
        `portletContext` - the PortletContext that the request runs in
      See Also:
        `MockPortalContext`

    - #### MockPortletRequest

          public MockPortletRequest(PortalContext portalContext,
                            PortletContext portletContext)

      Create a new MockPortletRequest.
      Parameters:
        `portalContext` - the PortalContext that the request runs in
        `portletContext` - the PortletContext that the request runs in

  - ### Method Detail

    - #### getLifecyclePhase

          protected String getLifecyclePhase()

      Return the Portlet 2.0 lifecycle id for the current phase.

    - #### isActive

          public boolean isActive()

      Return whether this request is still active (that is, not completed yet).

    - #### close

          public void close()

      Mark this request as completed.

    - #### checkActive

          protected void checkActive()
                              throws IllegalStateException

      Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.
      Throws:
        `IllegalStateException`

    - #### isWindowStateAllowed

          public boolean isWindowStateAllowed(WindowState windowState)

      Specified by:
        `isWindowStateAllowed` in interface `PortletRequest`

    - #### isPortletModeAllowed

          public boolean isPortletModeAllowed(PortletMode portletMode)

      Specified by:
        `isPortletModeAllowed` in interface `PortletRequest`

    - #### setPortletMode

          public void setPortletMode(PortletMode portletMode)

    - #### getPortletMode

          public PortletMode getPortletMode()

      Specified by:
        `getPortletMode` in interface `PortletRequest`

    - #### setWindowState

          public void setWindowState(WindowState windowState)

    - #### getWindowState

          public WindowState getWindowState()

      Specified by:
        `getWindowState` in interface `PortletRequest`

    - #### setPreferences

          public void setPreferences(PortletPreferences preferences)

    - #### getPreferences

          public PortletPreferences getPreferences()

      Specified by:
        `getPreferences` in interface `PortletRequest`

    - #### setSession

          public void setSession(PortletSession session)

    - #### getPortletSession

          public PortletSession getPortletSession()

      Specified by:
        `getPortletSession` in interface `PortletRequest`

    - #### getPortletSession

          public PortletSession getPortletSession(boolean create)

      Specified by:
        `getPortletSession` in interface `PortletRequest`

    - #### setProperty

          public void setProperty(String key,
                         String value)

      Set a single value for the specified property.

      If there are already one or more values registered for the given property key, they will be replaced.

    - #### addProperty

          public void addProperty(String key,
                         String value)

      Add a single value for the specified property.

      If there are already one or more values registered for the given property key, the given value will be added to the end of the list.

    - #### getProperty

          public String getProperty(String key)

      Specified by:
        `getProperty` in interface `PortletRequest`

    - #### getProperties

          public Enumeration<String> getProperties(String key)

      Specified by:
        `getProperties` in interface `PortletRequest`

    - #### getPropertyNames

          public Enumeration<String> getPropertyNames()

      Specified by:
        `getPropertyNames` in interface `PortletRequest`

    - #### getPortalContext

          public PortalContext getPortalContext()

      Specified by:
        `getPortalContext` in interface `PortletRequest`

    - #### setAuthType

          public void setAuthType(String authType)

    - #### getAuthType

          public String getAuthType()

      Specified by:
        `getAuthType` in interface `PortletRequest`

    - #### setContextPath

          public void setContextPath(String contextPath)

    - #### getContextPath

          public String getContextPath()

      Specified by:
        `getContextPath` in interface `PortletRequest`

    - #### setRemoteUser

          public void setRemoteUser(String remoteUser)

    - #### getRemoteUser

          public String getRemoteUser()

      Specified by:
        `getRemoteUser` in interface `PortletRequest`

    - #### setUserPrincipal

          public void setUserPrincipal(Principal userPrincipal)

    - #### getUserPrincipal

          public Principal getUserPrincipal()

      Specified by:
        `getUserPrincipal` in interface `PortletRequest`

    - #### addUserRole

          public void addUserRole(String role)

    - #### isUserInRole

          public boolean isUserInRole(String role)

      Specified by:
        `isUserInRole` in interface `PortletRequest`

    - #### getAttribute

          public Object getAttribute(String name)

      Specified by:
        `getAttribute` in interface `PortletRequest`

    - #### getAttributeNames

          public Enumeration<String> getAttributeNames()

      Specified by:
        `getAttributeNames` in interface `PortletRequest`

    - #### setParameters

          public void setParameters(Map<String,String[]> parameters)

    - #### setParameter

          public void setParameter(String key,
                          String value)

    - #### setParameter

          public void setParameter(String key,
                          String[] values)

    - #### addParameter

          public void addParameter(String name,
                          String value)

    - #### addParameter

          public void addParameter(String name,
                          String[] values)

    - #### getParameter

          public String getParameter(String name)

      Specified by:
        `getParameter` in interface `PortletRequest`

    - #### getParameterNames

          public Enumeration<String> getParameterNames()

      Specified by:
        `getParameterNames` in interface `PortletRequest`

    - #### getParameterValues

          public String[] getParameterValues(String name)

      Specified by:
        `getParameterValues` in interface `PortletRequest`

    - #### getParameterMap

          public Map<String,String[]> getParameterMap()

      Specified by:
        `getParameterMap` in interface `PortletRequest`

    - #### setSecure

          public void setSecure(boolean secure)

    - #### isSecure

          public boolean isSecure()

      Specified by:
        `isSecure` in interface `PortletRequest`

    - #### setAttribute

          public void setAttribute(String name,
                          Object value)

      Specified by:
        `setAttribute` in interface `PortletRequest`

    - #### removeAttribute

          public void removeAttribute(String name)

      Specified by:
        `removeAttribute` in interface `PortletRequest`

    - #### getRequestedSessionId

          public String getRequestedSessionId()

      Specified by:
        `getRequestedSessionId` in interface `PortletRequest`

    - #### setRequestedSessionIdValid

          public void setRequestedSessionIdValid(boolean requestedSessionIdValid)

    - #### isRequestedSessionIdValid

          public boolean isRequestedSessionIdValid()

      Specified by:
        `isRequestedSessionIdValid` in interface `PortletRequest`

    - #### addResponseContentType

          public void addResponseContentType(String responseContentType)

    - #### addPreferredResponseContentType

          public void addPreferredResponseContentType(String responseContentType)

    - #### getResponseContentType

          public String getResponseContentType()

      Specified by:
        `getResponseContentType` in interface `PortletRequest`

    - #### getResponseContentTypes

          public Enumeration<String> getResponseContentTypes()

      Specified by:
        `getResponseContentTypes` in interface `PortletRequest`

    - #### addLocale

          public void addLocale(Locale locale)

    - #### addPreferredLocale

          public void addPreferredLocale(Locale locale)

    - #### getLocale

          public Locale getLocale()

      Specified by:
        `getLocale` in interface `PortletRequest`

    - #### getLocales

          public Enumeration<Locale> getLocales()

      Specified by:
        `getLocales` in interface `PortletRequest`

    - #### setScheme

          public void setScheme(String scheme)

    - #### getScheme

          public String getScheme()

      Specified by:
        `getScheme` in interface `PortletRequest`

    - #### setServerName

          public void setServerName(String serverName)

    - #### getServerName

          public String getServerName()

      Specified by:
        `getServerName` in interface `PortletRequest`

    - #### setServerPort

          public void setServerPort(int serverPort)

    - #### getServerPort

          public int getServerPort()

      Specified by:
        `getServerPort` in interface `PortletRequest`

    - #### setWindowID

          public void setWindowID(String windowID)

    - #### getWindowID

          public String getWindowID()

      Specified by:
        `getWindowID` in interface `PortletRequest`

    - #### setCookies

          public void setCookies(Cookie... cookies)

    - #### getCookies

          public Cookie[] getCookies()

      Specified by:
        `getCookies` in interface `PortletRequest`

    - #### getPrivateParameterMap

          public Map<String,String[]> getPrivateParameterMap()

      Specified by:
        `getPrivateParameterMap` in interface `PortletRequest`

    - #### getPublicParameterMap

          public Map<String,String[]> getPublicParameterMap()

      Specified by:
        `getPublicParameterMap` in interface `PortletRequest`

    - #### registerPublicParameter

          public void registerPublicParameter(String name)