#17 Enhancement of MockServletContext

closed
Alwin Ibba
None
5
2005-08-10
2005-08-10
Lars Beuster
No

This is not a bug - but an enhancement request.

It would be nice to give the servletcontext a
java.io.File object as the dir of the deployed webapp.
The methods getResource/getResourceAsStream/getRealPath
could get its results from this dir. This could look
like this:

class MockHttpSession
{
protected File webappDir;
------------
InputStream getResourceAsStream (name)
{
stream = <original method body>
if (stream==null && this.webappDir!=null)
{
return new BufferedInputStream
(new FileInputStream
(new File (this.webappDir, name)));
}
}
--------------
URL getResource (String name)
{
url = <original method body>
if (url==null && this.webappDir!=null)
{
File file = new File (this.webappDir, name);
if (file.exists ()) return file.toURL ();
return null;
}
}
-------------
String getRealPath (String path)
{
realpath = <original method body>
if (realpath==null && this.webappDir!=null)
{
return new File (
this.webappDir, path).getAbsolutePath ();
}
}

Thanks
Lars

Discussion

  • Alwin Ibba
    Alwin Ibba
    2005-08-10

    • assigned_to: nobody --> aibba
     
  • Alwin Ibba
    Alwin Ibba
    2005-08-10

    • status: open --> closed