Spring Framework

org.springframework.mock.web.portlet
Class MockPortletContext

java.lang.Object
  extended by org.springframework.mock.web.portlet.MockPortletContext
All Implemented Interfaces:
javax.portlet.PortletContext

public class MockPortletContext
extends java.lang.Object
implements javax.portlet.PortletContext

Mock implementation of the PortletContext interface.

Since:
2.0
Author:
John A. Lewis, Juergen Hoeller

Constructor Summary
MockPortletContext()
          Create a new MockPortletContext with no base path and a DefaultResourceLoader (i.e.
MockPortletContext(ResourceLoader resourceLoader)
          Create a new MockPortletContext, using the specified ResourceLoader and no base path.
MockPortletContext(java.lang.String resourceBasePath)
          Create a new MockPortletContext using a DefaultResourceLoader.
MockPortletContext(java.lang.String resourceBasePath, ResourceLoader resourceLoader)
          Create a new MockPortletContext.
 
Method Summary
 void addContainerRuntimeOption(java.lang.String key)
           
 void addInitParameter(java.lang.String name, java.lang.String value)
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration<java.lang.String> getAttributeNames()
           
 java.util.Enumeration<java.lang.String> getContainerRuntimeOptions()
           
 java.lang.String getInitParameter(java.lang.String name)
           
 java.util.Enumeration<java.lang.String> getInitParameterNames()
           
 int getMajorVersion()
           
 java.lang.String getMimeType(java.lang.String filePath)
           
 int getMinorVersion()
           
 javax.portlet.PortletRequestDispatcher getNamedDispatcher(java.lang.String path)
           
 java.lang.String getPortletContextName()
           
 java.lang.String getRealPath(java.lang.String path)
           
 javax.portlet.PortletRequestDispatcher getRequestDispatcher(java.lang.String path)
           
 java.net.URL getResource(java.lang.String path)
           
 java.io.InputStream getResourceAsStream(java.lang.String path)
           
protected  java.lang.String getResourceLocation(java.lang.String path)
          Build a full resource location for the given path, prepending the resource base path of this MockPortletContext.
 java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)
           
 java.lang.String getServerInfo()
           
 void log(java.lang.String message)
           
 void log(java.lang.String message, java.lang.Throwable t)
           
 void removeAttribute(java.lang.String name)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setPortletContextName(java.lang.String portletContextName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(java.lang.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(java.lang.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 java.lang.String getResourceLocation(java.lang.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 java.lang.String getServerInfo()
Specified by:
getServerInfo in interface javax.portlet.PortletContext

getRequestDispatcher

public javax.portlet.PortletRequestDispatcher getRequestDispatcher(java.lang.String path)
Specified by:
getRequestDispatcher in interface javax.portlet.PortletContext

getNamedDispatcher

public javax.portlet.PortletRequestDispatcher getNamedDispatcher(java.lang.String path)
Specified by:
getNamedDispatcher in interface javax.portlet.PortletContext

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Specified by:
getResourceAsStream in interface javax.portlet.PortletContext

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface javax.portlet.PortletContext

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface javax.portlet.PortletContext

getMimeType

public java.lang.String getMimeType(java.lang.String filePath)
Specified by:
getMimeType in interface javax.portlet.PortletContext

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Specified by:
getRealPath in interface javax.portlet.PortletContext

getResourcePaths

public java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)
Specified by:
getResourcePaths in interface javax.portlet.PortletContext

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Specified by:
getResource in interface javax.portlet.PortletContext
Throws:
java.net.MalformedURLException

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface javax.portlet.PortletContext

getAttributeNames

public java.util.Enumeration<java.lang.String> getAttributeNames()
Specified by:
getAttributeNames in interface javax.portlet.PortletContext

setAttribute

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

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface javax.portlet.PortletContext

addInitParameter

public void addInitParameter(java.lang.String name,
                             java.lang.String value)

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Specified by:
getInitParameter in interface javax.portlet.PortletContext

getInitParameterNames

public java.util.Enumeration<java.lang.String> getInitParameterNames()
Specified by:
getInitParameterNames in interface javax.portlet.PortletContext

log

public void log(java.lang.String message)
Specified by:
log in interface javax.portlet.PortletContext

log

public void log(java.lang.String message,
                java.lang.Throwable t)
Specified by:
log in interface javax.portlet.PortletContext

setPortletContextName

public void setPortletContextName(java.lang.String portletContextName)

getPortletContextName

public java.lang.String getPortletContextName()
Specified by:
getPortletContextName in interface javax.portlet.PortletContext

addContainerRuntimeOption

public void addContainerRuntimeOption(java.lang.String key)

getContainerRuntimeOptions

public java.util.Enumeration<java.lang.String> getContainerRuntimeOptions()
Specified by:
getContainerRuntimeOptions in interface javax.portlet.PortletContext

Spring Framework