jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Using the application environment in Cactus
Date Tue, 22 Jan 2002 23:51:18 GMT
Hi Kaarle,

Apparently there was a problem with the Jakarta mailing-lists.

Several points that might help :
1/ On the server side, the implicit objects (container objects) that are
being passed to your test case are the _real_ objects (but wrapped).
This means that anything that has been set by whoever on these objects
will get passed to your test case. However ...
2/ The goal of cactus is to provide unit tests, i.e. test at method
level. A cactus test case has the following format :
- a) initialize the container objects + objects passed as parameter to
the method to test
- b) execute the method to test
- c) assert the results
This means that Cactus is not interested in testing how you reached the
initialization point (it could be done in real life by calling a login
page that sets some session variable, etc). The only thing that Cactus
(and JUnit BTW) requires is that you _simulate_ how these environment
parameters reached their required state. For example, if the requirement
for a given method is :
- there is a HTTP session created
- the session variable "isLoggedOn" is set to "true"
- there is such cookie set up
then you will need as part of the initialization of the test case to
reproduce this configuration, which is done as follows with Cactus :

public void beginXXX(WebRequest req)
{
  req.addCookie("mycookie", "mycookievalue");
  req.setAutomaticSession(true); // this is the default
}

public void testXXX()
{
  session.setAttribute("isLoggedOn", "true");

  MyCodeToTest mctt = new MyCodeToTest(...);
  Mctt.methodUnderTest(...);

  // do asserts
}

Summary :
----------

Cactus bypasses the way the code under test is reached and directly
points to it. It is not about testing how you got there (which can be
tested in its own right using Cactus but that's a different test !).

Hope this helps
-Vincent

> -----Original Message-----
> From: Kaarle Kaila [mailto:kaarle.kaila@iki.fi]
> Sent: 21 January 2002 05:42
> To: cactus-user@jakarta.apache.org
> Subject: Using the application environment in Cactus
> 
> hi!
> 
> I sent this message a few days ago but seems it did not go !
> 
> With Cactus you can setup your environment on the client
> side before calling the testcases. This is my current understanding
> on how Cactus works.
> 
> My application is executed (currently in weblogic 5.1) .
> The application is not however called directly from the
> users browser as there is a separate login system in between
> that forwards requests of logged-in users with relevant user data
> available in the headers.
> 
> My question is that can Cactus recognize these settings
> such as the session object that the application ha setup
> or does cactus only recognize the settings the Cactus client
> has made?
> 
> regards
> Kaarle
> 
> 
> ---------------------------------------------
> Kaarle Kaila
> http://www.iki.fi/kaila
> mailto:kaarle.kaila@iki.fi
> tel: +358 50 3725844
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message