|
Fish & Chips Club 4.7.1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objecthirondelle.fish.test.doubles.FakeServletContext
public class FakeServletContext
Fake implementation of ServletContext, used only for testing outside
the regular runtime environment.
This class requires that a System property be set correctly.
See ROOT_DIRECTORY for more information.
| Field Summary | |
|---|---|
static String |
ROOT_DIRECTORY
Name of a System property ("rootDirectory") that holds the root directory for this web application (with no trailing separator). |
static String |
SERVER_INFO
Value - "Fake ServletContext For Testing/1.0". |
static String |
SERVLET_CONTEXT_NAME
Value - "Fake ServletContext For Testing". |
| Constructor Summary | |
|---|---|
FakeServletContext()
Constructor |
|
| Method Summary | |
|---|---|
Object |
getAttribute(String aName)
|
Enumeration |
getAttributeNames()
|
ServletContext |
getContext(String aPath)
Not implemented - returns null. |
String |
getContextPath()
Not implemented - returns null. |
String |
getInitParameter(String aParamName)
|
Enumeration |
getInitParameterNames()
|
int |
getMajorVersion()
Returns 2. |
String |
getMimeType(String aFileName)
Not implemented - returns null. |
int |
getMinorVersion()
Returns 4. |
RequestDispatcher |
getNamedDispatcher(String aServletName)
Not implemented - returns null. |
String |
getRealPath(String aPath)
Return the full path to an underlying file or directory. |
RequestDispatcher |
getRequestDispatcher(String aPath)
Not implemented - returns null. |
URL |
getResource(String aPath)
Not implemented - returns null. |
InputStream |
getResourceAsStream(String aPath)
|
Set |
getResourcePaths(String aPathPattern)
Returns paths to items under the root directory. |
static String |
getRootDirectory()
Return the non-empty value of the System property identified by ROOT_DIRECTORY. |
String |
getServerInfo()
Returns "Fake ServletContext For Testing/1.0". |
Servlet |
getServlet(String aName)
Not implemented - returns null. |
String |
getServletContextName()
Returns "Fake ServletContext For Testing". |
Enumeration |
getServletNames()
Not implemented - returns null. |
Enumeration |
getServlets()
Not implemented - returns null. |
void |
log(Exception aException,
String aMessage)
|
void |
log(String aMessage)
|
void |
log(String aMessage,
Throwable aThrowable)
|
void |
removeAttribute(String aName)
|
void |
setAttribute(String aName,
Object aObject)
|
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ROOT_DIRECTORY
This item exists because ServletContext needs to translate request paths into explicit file system paths.
When using fake objects for testing, this System property must be set to a non-empty value, for example :
'rootDirectory=C:\myname\myprojects\blah'.
There are various ways of setting this property :
TESTAll.setRootDirectory()
System.setProperty(java.lang.String, java.lang.String) explicitly
'java ... -DrootDirectory=C:\myname\myprojects\blah ...'.
public static final String SERVER_INFO
public static final String SERVLET_CONTEXT_NAME
| Constructor Detail |
|---|
public FakeServletContext()
throws FileNotFoundException
FileNotFoundException| Method Detail |
|---|
public static String getRootDirectory()
ROOT_DIRECTORY.
public String getInitParameter(String aParamName)
getInitParameter in interface ServletContextpublic Enumeration getInitParameterNames()
getInitParameterNames in interface ServletContextpublic Set getResourcePaths(String aPathPattern)
Returns paths to items under the root directory.
Example return value, given path patern of "/catalog/":
"/catalog/blah.html" "/catalog/xyz.html" "/catalog/specials/"Note that '/catalog/' itself if not returned.
getResourcePaths in interface ServletContextaPathPattern - starts with "/", path to which items are matched; usually ends with '/' ,
to indicate a directory.public String getRealPath(String aPath)
getRealPath in interface ServletContextaPath - such as '/index.html'; directories end in a separator.public InputStream getResourceAsStream(String aPath)
getResourceAsStream in interface ServletContext
public void setAttribute(String aName,
Object aObject)
setAttribute in interface ServletContextpublic Object getAttribute(String aName)
getAttribute in interface ServletContextpublic void removeAttribute(String aName)
removeAttribute in interface ServletContextpublic Enumeration getAttributeNames()
getAttributeNames in interface ServletContextpublic String getServerInfo()
getServerInfo in interface ServletContextpublic String getServletContextName()
getServletContextName in interface ServletContextpublic void log(String aMessage)
log in interface ServletContext
public void log(Exception aException,
String aMessage)
log in interface ServletContext
public void log(String aMessage,
Throwable aThrowable)
log in interface ServletContextpublic int getMajorVersion()
getMajorVersion in interface ServletContextpublic int getMinorVersion()
getMinorVersion in interface ServletContext
public URL getResource(String aPath)
throws MalformedURLException
getResource in interface ServletContextMalformedURLExceptionpublic ServletContext getContext(String aPath)
getContext in interface ServletContextpublic String getContextPath()
getContextPath in interface ServletContextpublic String getMimeType(String aFileName)
getMimeType in interface ServletContextpublic RequestDispatcher getRequestDispatcher(String aPath)
getRequestDispatcher in interface ServletContextpublic RequestDispatcher getNamedDispatcher(String aServletName)
getNamedDispatcher in interface ServletContext
public Servlet getServlet(String aName)
throws ServletException
getServlet in interface ServletContextServletExceptionpublic Enumeration getServlets()
getServlets in interface ServletContextpublic Enumeration getServletNames()
getServletNames in interface ServletContext
|
Fish & Chips Club 4.7.1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||