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: Error accessing same http session across test methods
Date Sun, 24 Nov 2002 13:42:30 GMT
Hi Avinash,

Nick is right: Cactus creates a new HTTP Session for each testXXX().
Unless you specify not to create one

That said, there are cases when you need to be able to unit test methods
that expect an HTTP Session to exist. A method that tests for
Session.isNew() is such a case...

In order to be able to test this, Cactus 1.5 (it is not present in
Cactus 1.4) has introduced a new method:


anges.xml?rev=1.57&content-type=text/vnd.viewcvs-markup (search for
"HTTP Session")

Here is the test that is included in the Cactus test suite:

public void beginCreateSessionCookie(WebRequest theRequest)
    HttpSessionCookie sessionCookie = theRequest.getSessionCookie();

public void testCreateSessionCookie()
    assertTrue("A session should have been created prior to "
        + "this request", !session.isNew());

You need to get a nightly build


> -----Original Message-----
> From: Avinash Chugh [mailto:avi_chugh@hotmail.com]
> Sent: 21 November 2002 12:57
> To: cactus-user@jakarta.apache.org
> Subject: Error accessing same http session across test methods
> Environment: Weblogic 7, Win2k, Cactus 1.4.1
> I have a ServletTestCase with two test methods - testLogin(),
> testLogout().
> testlogin calls a doPost() on a servlet which logs in user using HTTP
> request parameters, and places an object in session. When I test
> assertNotNull for that session attribute, the test succeeds.
> testlogout() calls another doPost() which logs out the earlier user
> invalidate the session. But when I do assertNotNull() for the same
> session attribute (before the actual call to servlet), the test
> I am using the same servlet...and session.isNew() always returns true
> This leads me to believe..
> The HTTPSession created by testLogin() can nolonger be accessed by
> subsequent test method(s) ??
> This is a bug..right ??
> Regards,
> --
> 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>

View raw message