statics in StripesFilter (configurations etc.), unit test isolation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

statics in StripesFilter (configurations etc.), unit test isolation

VANKEISBELCK Remi
Hi folks,

I've had a shot at :

The issue is basically that MockServletContext has no "close" method, so the registered filters and servlet are never disposed correctly (as per the servlet spec, by calling "destroy()" on them). 

I though it was an easy one, but fixing this made other issues appear. Closing the context in my unit test would make other unit tests fail !

Loads of tests call StripesFilter.getConfiguration(), and rely on a statically shared MockServletContext (find usages for StripesTestFixture.getServletContext()) in order to do so. So my test that closed the context (and destroyed StripesFilter) had a side effect on other tests...

I'm fixing the test isolation issue by creating a new MockServletContext and wrap in a try / finally that closes it, everywhere needed, so that the calls to StripesFilter.getConfiguration() work.

Now the question. Why is the Configuration thing so complicated ? I mean, why not just a static ?

The javadocs mention several configurations per class loader... What for ? I mean, a webapp runs in its own classloader anyway...

If anyone knows the rationale for this design (configurations, configurationsStash et al), please tell me !

Cheers

Remi 



------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Stripes-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-development