You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Miguel <mi...@almeida.at> on 2011/05/23 20:15:17 UTC

Where's the best way to test session timeout?

Dear all,

Today's question is on the borderline between Struts and general "good
testing practises".

I have an application requirement "users must re-login after 5 minutes
of inactivity".

Now, the way to do this is to add to the web.xml:

<session-config> <session-timeout>5</session-timeout> </session-config>

However, how does one test it? More specifically:

1) Can we test it with a struts integration test?
2) How can we mock the time span (ie, we obviously don't want to wait 5
minutes for the test to finish...).


Thanks for the input,

Miguel Almeida

Re: Where's the best way to test session timeout?

Posted by Eric Lentz <Er...@sherwin.com>.
> 1) Can we test it with a struts integration test?
> 2) How can we mock the time span (ie, we obviously don't want to wait 5
> minutes for the test to finish...).

Are you testing what happens when a session is no longer a session? 
Invalidate the session in your test:
http://struts.apache.org/2.2.1/docs/how-do-we-get-invalidate-the-session.html

Otherwise, you're testing your servlet container, which is pretty silly 
IMO.

If you are testing the configuration file, then parse it and look for the 
correct timeout.

RE: Where's the best way to test session timeout?

Posted by "Biesbrock, Kevin" <Bi...@aoins.com>.
<session-config> <session-timeout>1</session-timeout> </session-config>?

Beez


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org