|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.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 ServletContext
public Enumeration getInitParameterNames()
getInitParameterNames
in interface ServletContext
public 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 ServletContext
aPathPattern
- starts with "/", path to which items are matched; usually ends with '/' ,
to indicate a directory.public String getRealPath(String aPath)
getRealPath
in interface ServletContext
aPath
- 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 ServletContext
public Object getAttribute(String aName)
getAttribute
in interface ServletContext
public void removeAttribute(String aName)
removeAttribute
in interface ServletContext
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletContext
public String getServerInfo()
getServerInfo
in interface ServletContext
public String getServletContextName()
getServletContextName
in interface ServletContext
public 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 ServletContext
public int getMajorVersion()
getMajorVersion
in interface ServletContext
public int getMinorVersion()
getMinorVersion
in interface ServletContext
public URL getResource(String aPath) throws MalformedURLException
getResource
in interface ServletContext
MalformedURLException
public ServletContext getContext(String aPath)
getContext
in interface ServletContext
public String getContextPath()
getContextPath
in interface ServletContext
public String getMimeType(String aFileName)
getMimeType
in interface ServletContext
public RequestDispatcher getRequestDispatcher(String aPath)
getRequestDispatcher
in interface ServletContext
public RequestDispatcher getNamedDispatcher(String aServletName)
getNamedDispatcher
in interface ServletContext
public Servlet getServlet(String aName) throws ServletException
getServlet
in interface ServletContext
ServletException
public Enumeration getServlets()
getServlets
in interface ServletContext
public Enumeration getServletNames()
getServletNames
in interface ServletContext
|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |