Here's another little patch. Basically I hit this error when trying to
test an ActionBean with some validation outside of the container (and
outside of the MockServletContext), I just tried passing in an
ActionBeanContext to my ActionBean in the test case then was trying to
view the validation error messages and hit a NullPointerException.

With this patch applied I can test ActionBean's nicely and look any
validation error messages in test cases etc.

--

James
-------
http://radio.weblogs.com/0112098/
Index: stripes/src/net/sourceforge/stripes/localization/LocalizationUtility.java
===================================================================
--- stripes/src/net/sourceforge/stripes/localization/LocalizationUtility.java   
(revision 410)
+++ stripes/src/net/sourceforge/stripes/localization/LocalizationUtility.java   
(working copy)
@@ -58,8 +58,17 @@
         ResourceBundle bundle = null;
 
         try {
-            bundle = 
StripesFilter.getConfiguration().getLocalizationBundleFactory()
-                    .getFormFieldBundle(locale);
+            Configuration configuration = StripesFilter.getConfiguration();
+            if (configuration == null) {
+                // we are probably being run from inside a mock test case
+                return null;
+            }
+            LocalizationBundleFactory bundleFactory = 
configuration.getLocalizationBundleFactory();
+            if (bundleFactory == null) {
+                // we are probably being run from inside a mock test case
+                return null;
+            }
+            bundle = bundleFactory.getFormFieldBundle(locale);
         }
         catch (MissingResourceException mre) {
             log.error(mre);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to