R
Robert Maas, see http://tinyurl.com/uh3t
I want to set up a test rig for HttpServlet things.
The idea is that my test rig creates (from scratch,
not underneath an actual HTTP/Tomcat/J2EE session)
both HttpServletRequest and HttpServletResponse
objects, populating them with realistic data,
then calls the HttpServlet with those as args,
then upon return checks the HttpServletResponse
object to see if the HttpServlet worked correctly.
Unfortunately I haven't been able to find any
public constructor for any class that implements
HttpServletRequest (I haven't even started looking
at HttpServletResponse because I'm already stumped
here), except one which takes another already-constructed
request object as parameter to constructor thereby
begging the question how to construct one from scratch
in the first place.
So I decided to write my own dummy request class which
would implement the interface hence be acceptable as
parameter to a servlet, starting with this skeleton:
public class DummyHttpServletRequest
implements javax.servlet.http.HttpServletRequest {
}
I tried to compile that, expecting to get a compiler
error that I'm missing one or more of the methods
needed to implement the interface. Instead I got this:
DummyHttpServletRequest.java:2: cannot resolve symbol
symbol : class HttpServletRequest
location: package http
implements javax.servlet.http.HttpServletRequest {
^
1 error
What's wrong, and how can I fix it so I can move ahead with this project??
.
The idea is that my test rig creates (from scratch,
not underneath an actual HTTP/Tomcat/J2EE session)
both HttpServletRequest and HttpServletResponse
objects, populating them with realistic data,
then calls the HttpServlet with those as args,
then upon return checks the HttpServletResponse
object to see if the HttpServlet worked correctly.
Unfortunately I haven't been able to find any
public constructor for any class that implements
HttpServletRequest (I haven't even started looking
at HttpServletResponse because I'm already stumped
here), except one which takes another already-constructed
request object as parameter to constructor thereby
begging the question how to construct one from scratch
in the first place.
So I decided to write my own dummy request class which
would implement the interface hence be acceptable as
parameter to a servlet, starting with this skeleton:
public class DummyHttpServletRequest
implements javax.servlet.http.HttpServletRequest {
}
I tried to compile that, expecting to get a compiler
error that I'm missing one or more of the methods
needed to implement the interface. Instead I got this:
DummyHttpServletRequest.java:2: cannot resolve symbol
symbol : class HttpServletRequest
location: package http
implements javax.servlet.http.HttpServletRequest {
^
1 error
What's wrong, and how can I fix it so I can move ahead with this project??
.