org.springframework.mock.web.portlet
Class MockPortletRequest

java.lang.Object
  extended by org.springframework.mock.web.portlet.MockPortletRequest
All Implemented Interfaces:
javax.portlet.PortletRequest
Direct Known Subclasses:
MockClientDataRequest, MockEventRequest, MockRenderRequest

public class MockPortletRequest
extends Object
implements javax.portlet.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
javax.portlet.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
MockPortletRequest()
          Create a new MockPortletRequest with a default MockPortalContext and a default MockPortletContext.
MockPortletRequest(javax.portlet.PortalContext portalContext, javax.portlet.PortletContext portletContext)
          Create a new MockPortletRequest.
MockPortletRequest(javax.portlet.PortletContext portletContext)
          Create a new MockPortletRequest with a default MockPortalContext.
 
Method Summary
 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)
           
 javax.portlet.PortalContext getPortalContext()
           
 javax.portlet.PortletMode getPortletMode()
           
 javax.portlet.PortletSession getPortletSession()
           
 javax.portlet.PortletSession getPortletSession(boolean create)
           
 javax.portlet.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()
           
 javax.portlet.WindowState getWindowState()
           
 boolean isActive()
          Return whether this request is still active (that is, not completed yet).
 boolean isPortletModeAllowed(javax.portlet.PortletMode portletMode)
           
 boolean isRequestedSessionIdValid()
           
 boolean isSecure()
           
 boolean isUserInRole(String role)
           
 boolean isWindowStateAllowed(javax.portlet.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(javax.portlet.PortletMode portletMode)
           
 void setPreferences(javax.portlet.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(javax.portlet.PortletSession session)
           
 void setUserPrincipal(Principal userPrincipal)
           
 void setWindowID(String windowID)
           
 void setWindowState(javax.portlet.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(javax.portlet.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(javax.portlet.PortalContext portalContext,
                          javax.portlet.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(javax.portlet.WindowState windowState)
Specified by:
isWindowStateAllowed in interface javax.portlet.PortletRequest

isPortletModeAllowed

public boolean isPortletModeAllowed(javax.portlet.PortletMode portletMode)
Specified by:
isPortletModeAllowed in interface javax.portlet.PortletRequest

setPortletMode

public void setPortletMode(javax.portlet.PortletMode portletMode)

getPortletMode

public javax.portlet.PortletMode getPortletMode()
Specified by:
getPortletMode in interface javax.portlet.PortletRequest

setWindowState

public void setWindowState(javax.portlet.WindowState windowState)

getWindowState

public javax.portlet.WindowState getWindowState()
Specified by:
getWindowState in interface javax.portlet.PortletRequest

setPreferences

public void setPreferences(javax.portlet.PortletPreferences preferences)

getPreferences

public javax.portlet.PortletPreferences getPreferences()
Specified by:
getPreferences in interface javax.portlet.PortletRequest

setSession

public void setSession(javax.portlet.PortletSession session)

getPortletSession

public javax.portlet.PortletSession getPortletSession()
Specified by:
getPortletSession in interface javax.portlet.PortletRequest

getPortletSession

public javax.portlet.PortletSession getPortletSession(boolean create)
Specified by:
getPortletSession in interface javax.portlet.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 javax.portlet.PortletRequest

getProperties

public Enumeration<String> getProperties(String key)
Specified by:
getProperties in interface javax.portlet.PortletRequest

getPropertyNames

public Enumeration<String> getPropertyNames()
Specified by:
getPropertyNames in interface javax.portlet.PortletRequest

getPortalContext

public javax.portlet.PortalContext getPortalContext()
Specified by:
getPortalContext in interface javax.portlet.PortletRequest

setAuthType

public void setAuthType(String authType)

getAuthType

public String getAuthType()
Specified by:
getAuthType in interface javax.portlet.PortletRequest

setContextPath

public void setContextPath(String contextPath)

getContextPath

public String getContextPath()
Specified by:
getContextPath in interface javax.portlet.PortletRequest

setRemoteUser

public void setRemoteUser(String remoteUser)

getRemoteUser

public String getRemoteUser()
Specified by:
getRemoteUser in interface javax.portlet.PortletRequest

setUserPrincipal

public void setUserPrincipal(Principal userPrincipal)

getUserPrincipal

public Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface javax.portlet.PortletRequest

addUserRole

public void addUserRole(String role)

isUserInRole

public boolean isUserInRole(String role)
Specified by:
isUserInRole in interface javax.portlet.PortletRequest

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface javax.portlet.PortletRequest

getAttributeNames

public Enumeration<String> getAttributeNames()
Specified by:
getAttributeNames in interface javax.portlet.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 javax.portlet.PortletRequest

getParameterNames

public Enumeration<String> getParameterNames()
Specified by:
getParameterNames in interface javax.portlet.PortletRequest

getParameterValues

public String[] getParameterValues(String name)
Specified by:
getParameterValues in interface javax.portlet.PortletRequest

getParameterMap

public Map<String,String[]> getParameterMap()
Specified by:
getParameterMap in interface javax.portlet.PortletRequest

setSecure

public void setSecure(boolean secure)

isSecure

public boolean isSecure()
Specified by:
isSecure in interface javax.portlet.PortletRequest

setAttribute

public void setAttribute(String name,
                         Object value)
Specified by:
setAttribute in interface javax.portlet.PortletRequest

removeAttribute

public void removeAttribute(String name)
Specified by:
removeAttribute in interface javax.portlet.PortletRequest

getRequestedSessionId

public String getRequestedSessionId()
Specified by:
getRequestedSessionId in interface javax.portlet.PortletRequest

setRequestedSessionIdValid

public void setRequestedSessionIdValid(boolean requestedSessionIdValid)

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Specified by:
isRequestedSessionIdValid in interface javax.portlet.PortletRequest

addResponseContentType

public void addResponseContentType(String responseContentType)

addPreferredResponseContentType

public void addPreferredResponseContentType(String responseContentType)

getResponseContentType

public String getResponseContentType()
Specified by:
getResponseContentType in interface javax.portlet.PortletRequest

getResponseContentTypes

public Enumeration<String> getResponseContentTypes()
Specified by:
getResponseContentTypes in interface javax.portlet.PortletRequest

addLocale

public void addLocale(Locale locale)

addPreferredLocale

public void addPreferredLocale(Locale locale)

getLocale

public Locale getLocale()
Specified by:
getLocale in interface javax.portlet.PortletRequest

getLocales

public Enumeration<Locale> getLocales()
Specified by:
getLocales in interface javax.portlet.PortletRequest

setScheme

public void setScheme(String scheme)

getScheme

public String getScheme()
Specified by:
getScheme in interface javax.portlet.PortletRequest

setServerName

public void setServerName(String serverName)

getServerName

public String getServerName()
Specified by:
getServerName in interface javax.portlet.PortletRequest

setServerPort

public void setServerPort(int serverPort)

getServerPort

public int getServerPort()
Specified by:
getServerPort in interface javax.portlet.PortletRequest

setWindowID

public void setWindowID(String windowID)

getWindowID

public String getWindowID()
Specified by:
getWindowID in interface javax.portlet.PortletRequest

setCookies

public void setCookies(Cookie... cookies)

getCookies

public Cookie[] getCookies()
Specified by:
getCookies in interface javax.portlet.PortletRequest

getPrivateParameterMap

public Map<String,String[]> getPrivateParameterMap()
Specified by:
getPrivateParameterMap in interface javax.portlet.PortletRequest

getPublicParameterMap

public Map<String,String[]> getPublicParameterMap()
Specified by:
getPublicParameterMap in interface javax.portlet.PortletRequest

registerPublicParameter

public void registerPublicParameter(String name)