This content has been marked as final.
Show 3 replies
-
1. Re: Invalidating Session breaks JSFUnit Test Case
ssilvert Aug 11, 2008 2:40 PM (in response to danule)I'm pretty sure this is a bug in JSFUnit. The problem is that JSFUnit uses the HttpSession as a conduit for passing the FacesContext to JUnit. When you blow the session away with invalidate(), JSFUnit will break.
If you change your code to clear the session instead of invalidating it, then it will probably work.for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) { session.removeAttribute((String)e.nextElement()); }
However this is not a long term solution, so I've opened the following jira task:
https://jira.jboss.org/jira/browse/JSFUNIT-155
Under the covers, I could easily make HttpSession.invalidate() clear the session during a JSFUnit test. But clearing the session is not exactly the same thing as invalidating it. I'm wondering if that solution would break developers' tests that wanted to be strict about making sure that the HttpSession is blown away.
Any thoughts?
Stan -
2. Re: Invalidating Session breaks JSFUnit Test Case
danule Aug 12, 2008 12:05 PM (in response to danule)Thanks for the quick reply Stan.
If JSFUnit were to clear the session for HttpSession.invalidate() under the covers as you say, for our purposes, it would be adequate in covering our test case, without breaking it.
In our own code, I would be more comfortable invalidating the session, than merely clearing it. -
3. Re: Invalidating Session breaks JSFUnit Test Case
ssilvert Aug 12, 2008 7:14 PM (in response to danule)It's now fixed. If you want to try it out you can build from subversion. Or you can wait a couple of weeks for Beta 3.
Stan