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 thePortletRequest
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 Description MockPortletRequest()
Create a new MockPortletRequest with a defaultMockPortalContext
and a defaultMockPortletContext
.MockPortletRequest(PortalContext portalContext, PortletContext portletContext)
Create a new MockPortletRequest.MockPortletRequest(PortletContext portletContext)
Create a new MockPortletRequest with a defaultMockPortalContext
.
Method Summary
Constructor Detail
MockPortletRequest
public MockPortletRequest()
Create a new MockPortletRequest with a defaultMockPortalContext
and a defaultMockPortletContext
.- See Also:
MockPortalContext
,MockPortletContext
MockPortletRequest
public MockPortletRequest(PortletContext portletContext)
Create a new MockPortletRequest with a defaultMockPortalContext
.- 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 inportletContext
- 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 interfacePortletRequest
isPortletModeAllowed
public boolean isPortletModeAllowed(PortletMode portletMode)
- Specified by:
isPortletModeAllowed
in interfacePortletRequest
setPortletMode
public void setPortletMode(PortletMode portletMode)
getPortletMode
public PortletMode getPortletMode()
- Specified by:
getPortletMode
in interfacePortletRequest
setWindowState
public void setWindowState(WindowState windowState)
getWindowState
public WindowState getWindowState()
- Specified by:
getWindowState
in interfacePortletRequest
setPreferences
public void setPreferences(PortletPreferences preferences)
getPreferences
public PortletPreferences getPreferences()
- Specified by:
getPreferences
in interfacePortletRequest
setSession
public void setSession(PortletSession session)
getPortletSession
public PortletSession getPortletSession()
- Specified by:
getPortletSession
in interfacePortletRequest
getPortletSession
public PortletSession getPortletSession(boolean create)
- Specified by:
getPortletSession
in interfacePortletRequest
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 interfacePortletRequest
getProperties
public Enumeration<String> getProperties(String key)
- Specified by:
getProperties
in interfacePortletRequest
getPropertyNames
public Enumeration<String> getPropertyNames()
- Specified by:
getPropertyNames
in interfacePortletRequest
getPortalContext
public PortalContext getPortalContext()
- Specified by:
getPortalContext
in interfacePortletRequest
setAuthType
public void setAuthType(String authType)
getAuthType
public String getAuthType()
- Specified by:
getAuthType
in interfacePortletRequest
setContextPath
public void setContextPath(String contextPath)
getContextPath
public String getContextPath()
- Specified by:
getContextPath
in interfacePortletRequest
setRemoteUser
public void setRemoteUser(String remoteUser)
getRemoteUser
public String getRemoteUser()
- Specified by:
getRemoteUser
in interfacePortletRequest
setUserPrincipal
public void setUserPrincipal(Principal userPrincipal)
getUserPrincipal
public Principal getUserPrincipal()
- Specified by:
getUserPrincipal
in interfacePortletRequest
addUserRole
public void addUserRole(String role)
isUserInRole
public boolean isUserInRole(String role)
- Specified by:
isUserInRole
in interfacePortletRequest
getAttribute
public Object getAttribute(String name)
- Specified by:
getAttribute
in interfacePortletRequest
getAttributeNames
public Enumeration<String> getAttributeNames()
- Specified by:
getAttributeNames
in interfacePortletRequest
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 interfacePortletRequest
getParameterNames
public Enumeration<String> getParameterNames()
- Specified by:
getParameterNames
in interfacePortletRequest
getParameterValues
public String[] getParameterValues(String name)
- Specified by:
getParameterValues
in interfacePortletRequest
getParameterMap
public Map<String,String[]> getParameterMap()
- Specified by:
getParameterMap
in interfacePortletRequest
setSecure
public void setSecure(boolean secure)
isSecure
public boolean isSecure()
- Specified by:
isSecure
in interfacePortletRequest
setAttribute
public void setAttribute(String name, Object value)
- Specified by:
setAttribute
in interfacePortletRequest
removeAttribute
public void removeAttribute(String name)
- Specified by:
removeAttribute
in interfacePortletRequest
getRequestedSessionId
public String getRequestedSessionId()
- Specified by:
getRequestedSessionId
in interfacePortletRequest
setRequestedSessionIdValid
public void setRequestedSessionIdValid(boolean requestedSessionIdValid)
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
- Specified by:
isRequestedSessionIdValid
in interfacePortletRequest
addResponseContentType
public void addResponseContentType(String responseContentType)
addPreferredResponseContentType
public void addPreferredResponseContentType(String responseContentType)
getResponseContentType
public String getResponseContentType()
- Specified by:
getResponseContentType
in interfacePortletRequest
getResponseContentTypes
public Enumeration<String> getResponseContentTypes()
- Specified by:
getResponseContentTypes
in interfacePortletRequest
addPreferredLocale
public void addPreferredLocale(Locale locale)
getLocale
public Locale getLocale()
- Specified by:
getLocale
in interfacePortletRequest
getLocales
public Enumeration<Locale> getLocales()
- Specified by:
getLocales
in interfacePortletRequest
getScheme
public String getScheme()
- Specified by:
getScheme
in interfacePortletRequest
setServerName
public void setServerName(String serverName)
getServerName
public String getServerName()
- Specified by:
getServerName
in interfacePortletRequest
setServerPort
public void setServerPort(int serverPort)
getServerPort
public int getServerPort()
- Specified by:
getServerPort
in interfacePortletRequest
setWindowID
public void setWindowID(String windowID)
getWindowID
public String getWindowID()
- Specified by:
getWindowID
in interfacePortletRequest
setCookies
public void setCookies(Cookie... cookies)
getCookies
public Cookie[] getCookies()
- Specified by:
getCookies
in interfacePortletRequest
getPrivateParameterMap
public Map<String,String[]> getPrivateParameterMap()
- Specified by:
getPrivateParameterMap
in interfacePortletRequest
getPublicParameterMap
public Map<String,String[]> getPublicParameterMap()
- Specified by:
getPublicParameterMap
in interfacePortletRequest
registerPublicParameter
public void registerPublicParameter(String name)