Class MockPortletContext
- java.lang.Object
- org.springframework.mock.web.portlet.MockPortletContext
- All Implemented Interfaces:
PortletContext
public class MockPortletContext extends Object implements PortletContext
Mock implementation of thePortletContextinterface.- Since:
- 2.0
- Author:
- John A. Lewis, Juergen Hoeller
Constructor Summary
Constructors Constructor Description MockPortletContext()Create a new MockPortletContext with no base path and a DefaultResourceLoader (i.e.MockPortletContext(String resourceBasePath)Create a new MockPortletContext using a DefaultResourceLoader.MockPortletContext(String resourceBasePath, ResourceLoader resourceLoader)Create a new MockPortletContext.MockPortletContext(ResourceLoader resourceLoader)Create a new MockPortletContext, using the specified ResourceLoader and no base path.
Method Summary
Constructor Detail
MockPortletContext
public MockPortletContext()
Create a new MockPortletContext with no base path and a DefaultResourceLoader (i.e. the classpath root as WAR root).- See Also:
DefaultResourceLoader
MockPortletContext
public MockPortletContext(String resourceBasePath)
Create a new MockPortletContext using a DefaultResourceLoader.- Parameters:
resourceBasePath- the WAR root directory (should not end with a slash)- See Also:
DefaultResourceLoader
MockPortletContext
public MockPortletContext(ResourceLoader resourceLoader)
Create a new MockPortletContext, using the specified ResourceLoader and no base path.- Parameters:
resourceLoader- the ResourceLoader to use (or null for the default)
MockPortletContext
public MockPortletContext(String resourceBasePath, ResourceLoader resourceLoader)
Create a new MockPortletContext.- Parameters:
resourceBasePath- the WAR root directory (should not end with a slash)resourceLoader- the ResourceLoader to use (or null for the default)
Method Detail
getResourceLocation
protected String getResourceLocation(String path)
Build a full resource location for the given path, prepending the resource base path of this MockPortletContext.- Parameters:
path- the path as specified- Returns:
- the full resource path
getServerInfo
public String getServerInfo()
- Specified by:
getServerInfoin interfacePortletContext
getRequestDispatcher
public PortletRequestDispatcher getRequestDispatcher(String path)
- Specified by:
getRequestDispatcherin interfacePortletContext
getNamedDispatcher
public PortletRequestDispatcher getNamedDispatcher(String path)
- Specified by:
getNamedDispatcherin interfacePortletContext
getResourceAsStream
public InputStream getResourceAsStream(String path)
- Specified by:
getResourceAsStreamin interfacePortletContext
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersionin interfacePortletContext
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersionin interfacePortletContext
getMimeType
public String getMimeType(String filePath)
- Specified by:
getMimeTypein interfacePortletContext
getRealPath
public String getRealPath(String path)
- Specified by:
getRealPathin interfacePortletContext
getResourcePaths
public Set<String> getResourcePaths(String path)
- Specified by:
getResourcePathsin interfacePortletContext
getResource
public URL getResource(String path) throws MalformedURLException
- Specified by:
getResourcein interfacePortletContext- Throws:
MalformedURLException
getAttribute
public Object getAttribute(String name)
- Specified by:
getAttributein interfacePortletContext
getAttributeNames
public Enumeration<String> getAttributeNames()
- Specified by:
getAttributeNamesin interfacePortletContext
setAttribute
public void setAttribute(String name, Object value)
- Specified by:
setAttributein interfacePortletContext
removeAttribute
public void removeAttribute(String name)
- Specified by:
removeAttributein interfacePortletContext
addInitParameter
public void addInitParameter(String name, String value)
getInitParameter
public String getInitParameter(String name)
- Specified by:
getInitParameterin interfacePortletContext
getInitParameterNames
public Enumeration<String> getInitParameterNames()
- Specified by:
getInitParameterNamesin interfacePortletContext
log
public void log(String message)
- Specified by:
login interfacePortletContext
log
public void log(String message, Throwable t)
- Specified by:
login interfacePortletContext
setPortletContextName
public void setPortletContextName(String portletContextName)
getPortletContextName
public String getPortletContextName()
- Specified by:
getPortletContextNamein interfacePortletContext
addContainerRuntimeOption
public void addContainerRuntimeOption(String key)
getContainerRuntimeOptions
public Enumeration<String> getContainerRuntimeOptions()
- Specified by:
getContainerRuntimeOptionsin interfacePortletContext