org.apache.tapestry.test.mock
Class MockContext

java.lang.Object
  extended by org.apache.tapestry.test.mock.AttributeHolder
      extended by org.apache.tapestry.test.mock.MockContext
All Implemented Interfaces:
ServletContext, InitParameterHolder

public class MockContext
extends AttributeHolder
implements ServletContext, InitParameterHolder

Mock implementation of ServletContext.

Since:
4.0
Author:
Howard Lewis Ship

Constructor Summary
MockContext()
           
MockContext(String testDirectory)
           
 
Method Summary
 MockSession createSession()
           
 ServletContext getContext(String name)
           
 String getContextPath()
           
 String getInitParameter(String name)
           
 Enumeration getInitParameterNames()
           
 int getMajorVersion()
           
 String getMimeType(String path)
           
 int getMinorVersion()
           
 RequestDispatcher getNamedDispatcher(String name)
           
 String getRealPath(String arg0)
           
 RequestDispatcher getRequestDispatcher(String path)
          Gets a dispatcher for the given path.
 URL getResource(String path)
           
 InputStream getResourceAsStream(String path)
           
 Set getResourcePaths(String arg0)
           
 String getRootDirectory()
           
 String getServerInfo()
           
 Servlet getServlet(String name)
           
 String getServletContextName()
           
 Enumeration getServletNames()
           
 Enumeration getServlets()
           
 MockSession getSession()
           
 void log(Exception exception, String message)
           
 void log(String message)
           
 void log(String message, Throwable exception)
           
 void setInitParameter(String name, String value)
          Allows Mock objects to have initial parameters set.
 void setRootDirectory(String rootDirectory)
           
 void setServletContextName(String servletContextName)
           
 
Methods inherited from class org.apache.tapestry.test.mock.AttributeHolder
getAttribute, getAttributeNames, getAttributeNamesArray, getEnumeration, removeAttribute, setAttribute, simulateFailover
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletContext
getAttribute, getAttributeNames, removeAttribute, setAttribute
 

Constructor Detail

MockContext

public MockContext()

MockContext

public MockContext(String testDirectory)
Method Detail

getContext

public ServletContext getContext(String name)
Specified by:
getContext in interface ServletContext

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface ServletContext

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface ServletContext

getMimeType

public String getMimeType(String path)
Specified by:
getMimeType in interface ServletContext

getResourcePaths

public Set getResourcePaths(String arg0)
Specified by:
getResourcePaths in interface ServletContext

getResource

public URL getResource(String path)
                throws MalformedURLException
Specified by:
getResource in interface ServletContext
Throws:
MalformedURLException

getResourceAsStream

public InputStream getResourceAsStream(String path)
Specified by:
getResourceAsStream in interface ServletContext

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)
Gets a dispatcher for the given path. Path should be a relative path (relative to the context). A special case: "NULL" returns null (i.e., when a dispatcher can't be found).

Specified by:
getRequestDispatcher in interface ServletContext

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(String name)
Specified by:
getNamedDispatcher in interface ServletContext

getServlet

public Servlet getServlet(String name)
                   throws ServletException
Specified by:
getServlet in interface ServletContext
Throws:
ServletException

getServlets

public Enumeration getServlets()
Specified by:
getServlets in interface ServletContext

getServletNames

public Enumeration getServletNames()
Specified by:
getServletNames in interface ServletContext

log

public void log(String message)
Specified by:
log in interface ServletContext

log

public void log(Exception exception,
                String message)
Specified by:
log in interface ServletContext

log

public void log(String message,
                Throwable exception)
Specified by:
log in interface ServletContext

getRealPath

public String getRealPath(String arg0)
Specified by:
getRealPath in interface ServletContext

getContextPath

public String getContextPath()

getServerInfo

public String getServerInfo()
Specified by:
getServerInfo in interface ServletContext

getInitParameter

public String getInitParameter(String name)
Specified by:
getInitParameter in interface ServletContext
Specified by:
getInitParameter in interface InitParameterHolder

getInitParameterNames

public Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface ServletContext
Specified by:
getInitParameterNames in interface InitParameterHolder

setInitParameter

public void setInitParameter(String name,
                             String value)
Description copied from interface: InitParameterHolder
Allows Mock objects to have initial parameters set.

Specified by:
setInitParameter in interface InitParameterHolder

getServletContextName

public String getServletContextName()
Specified by:
getServletContextName in interface ServletContext

createSession

public MockSession createSession()

getSession

public MockSession getSession()

setServletContextName

public void setServletContextName(String servletContextName)

getRootDirectory

public String getRootDirectory()

setRootDirectory

public void setRootDirectory(String rootDirectory)


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.