----- Original Message -----
From: "Jari Worsley" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 02, 2001 6:10 PM
Subject: Re: Cactus Question


> "Vaishnav, Kunal" wrote:
> >
> > Hello All,
> >   I had a question. Can I return a vector of objects in the response
stream
> > to be tested in the endXXX() method?. I think that in SimpleServlet
example,
> > it shows how to return
> > cookies. But can I return a vector of objects?.
> >
>
> I don't see why you would want to. Presumably the objects that are the
> result of some servlet method are available in the testXXX method. Just
> test them there rather than in the endXXX.
>
> I am beginning to think that the endXXX method actually confuses the
> issue of where to place test code, and that for servlet testing what you
> seem to need is begin, setup, test and teardown, and that for JSP you
> need setup test,teardown and endXXX.
>

It is actually much simpler that that ! :)

Let's imagine you are writing some server code. This code will sit in a
server engine. Then you need some client application that will access this
code, i.e. use HTTP (for example) as a protocol for sending a request to
your server, the server answers and you process the result in the client. If
you undestand that then you have understood the architecture of Cactus !
Because it is the same ... The client application is JUnit. Your test case
(i.e. your code that extends ServletTestCase) has some code in it that will
open an HTTP connection to the Cactus Servlet Redirector (which is the
server part of Cactus) and the redirector will create *another* instance of
your test case on the server side (this is the only thing to understand:
instead of having to write 2 classes, I have merged it into a single class,
because it was too much a pain to have to write 2 classes ...).

So recap. :
- beginXXX( ) and endXXX() are executed on the client side
- testXXX() is executed in the server

But please have a look at
http://jakarta.apache.org/commons/cactus/architecture.html. I spent some
long hours explaining everything there, with nice diagrams, ... :-)
It something is not clear, this is the place where to change it.

Note to Jari: For JSP you also need beginXXX() and for Servlet testing you
also need endXXX() ! :)

Thanks
Vincent

> Jari
>
> > Thanks,
> > Kunal.
>
> --
> Jari Worsley
> Senior Programmer
> Hyperlink Interactive Ltd
>

Reply via email to