Hey Guys, I was chatting with cherro this morning who has been writing unit tests using Stripes' MockRoundtrip et al. One thing that came up as being very confusing is the fact that any test that uses the MockRoundtrip will emit a large log message when it tries to encrypt the _sourcePage and the CryptoUtil finds that it cannot access the Configuration through StripesFilter.getConfiguration().
This led me to do a bunch of poking around to see how we could fix that. The easiest way would probably be to add a method to CryptoUtil that can take in the Configuration object instead of having to look it up on the StripesFilter since the MockRoundtrip already has it's own trick to look up the Configuration. But then I realized, I don't think the new @Validate(encrypt=true) will work at all with our mock testing framework. Has anyone tried this? Does is it actually work? I can't seem to find any code that actually encrypts the values in the MockRequest before submitting them. At any rate, it seems like there is at least one place in the test code that requires access to the configuration that cannot get at it. This makes me wonder about a more general solution. How does the following strike you: 1. In the constructor to StripesFilter we could store the newly constructed instance (or the Configuration) object into a private static WeakHashSet. (Weak so that instance will get reaped as appropriate) 2. In StripesFilter.getConfiguration() we first check the thread local stash, and if it's present return that. Otherwise check our WeakHashSet and if it contains only one entry (which it would 99.9% of the time) just return that one. 3. If there are multiple entries in the WeakHashSet, we really don't know what do to so log the usual exception and return null Any downside to doing this? I think it'd give more code access to the Configuration reasonably cleanly without changing any APIs.... -t ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Stripes-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-development
