"Vaishnav, Kunal" wrote:
> 
> Hey Jari,
>  In endXXX() how do I check for a parameter?. I am asking this because in
> endXXX() the parameter is an HttpURLConnection..
> I can do an AssertUtil..but i cant return a something like a reponse object
> per se..so i cant do theResponse.getParameter("something");
> 
> Please comment.
> 

Kunal, I've cc'ed this reply to the mailgroup as it might be something
quite "common" to do ;) (excuse the pun)

I'm not entirely sure what you mean. Do you mean check for an attribute?
Or check the HttpURLConnection for a response code?

in endXXX you get the output from the testcase call, a whole bunch of
html, or whatever you've returned from the server side code you are
testing.

If you want to check that a particular value is being set in a session,
servletcontext or request attribute, then you will need to test this in
the testXXX method while the testcase is running server side.

If you want to check for a response code then you should be able to use
the HttpURLConnection.getResponseCode() method in the endXXX method on
the client.

Are you trying to test what a servlet call puts into the request before
forwarding to a JSP page? (if that is what you're doing, i.e. Model 2)?
or are you trying to test the output of the servlet as well as the
output of a JSP page? 

If you need to test what is being returned by a JSP, then you should
take a look at HttpUnit which is geared up to working on the returned
HttpURLConnection.


I have thought about trying to combine HttpUnit functionality and cactus
- I am wondering about using something like cactus to test the
controller part of a web application, then perverting HttpUnit and
cactus to my cause to test the JSP pages in isolation. The problem with
testing JSP's is that you tend to need the servlet there to provide the
JavaBeans in request/session etc for the JSP to use. Perhaps it 's
possible to use a combination of cactus - to set up dummy data in the
request and session  - then call the JSP then look at the results using
HttpUnit classes to test the JSP works with it's expected inputs. 

Anyone else managed to separate testing of JSP and servlet in a Model 2
shape project?


Jari

Reply via email to