Anonymous avatar Anonymous committed 615e3f1

Make Jalopy happy.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@333 e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (6)

src/java/com/opensymphony/xwork/interceptor/ParametersInterceptor.java

             }
 
             ActionContext invocationContext = invocation.getInvocationContext();
+
             try {
                 invocationContext.put(InstantiatingNullHandler.CREATE_NULL_OBJECTS, Boolean.TRUE);
                 invocationContext.put(XWorkMethodAccessor.DENY_METHOD_EXECUTION, Boolean.TRUE);

src/java/com/opensymphony/xwork/util/LocalizedTextUtil.java

     }
 
     /**
- * Returns a localized message for the specified key, aTextName.  Neither the key nor the
- * message is evaluated.
- *
- * @param aTextName the message key
- * @param locale    the locale the message should be for
- * @return a localized message based on the specified key
- * @throws MissingResourceException if no message can be found for the specified key
- */
+     * Returns a localized message for the specified key, aTextName.  Neither the key nor the
+     * message is evaluated.
+     *
+     * @param aTextName the message key
+     * @param locale    the locale the message should be for
+     * @return a localized message based on the specified key
+     * @throws MissingResourceException if no message can be found for the specified key
+     */
     public static String findDefaultText(String aTextName, Locale locale) throws MissingResourceException {
         MissingResourceException e = null;
         List localList = new ArrayList(DEFAULT_RESOURCE_BUNDLES);
     }
 
     /**
- * Returns a localized message for the specified key, aTextName, substituting variables from the
- * array of params into the message.  Neither the key nor the message is evaluated.
- *
- * @param aTextName the message key
- * @param locale    the locale the message should be for
- * @param params    an array of objects to be substituted into the message text
- * @return A formatted message based on the specified key
- * @throws MissingResourceException if no message can be found for the specified key
- */
+     * Returns a localized message for the specified key, aTextName, substituting variables from the
+     * array of params into the message.  Neither the key nor the message is evaluated.
+     *
+     * @param aTextName the message key
+     * @param locale    the locale the message should be for
+     * @param params    an array of objects to be substituted into the message text
+     * @return A formatted message based on the specified key
+     * @throws MissingResourceException if no message can be found for the specified key
+     */
     public static String findDefaultText(String aTextName, Locale locale, Object[] params) throws MissingResourceException {
         MessageFormat mf = buildMessageFormat(findDefaultText(aTextName, locale), locale);
 
     }
 
     /**
- * Calls {@link #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)}
- * with aTextName as the default message.
- *
- * @see #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
- */
+     * Calls {@link #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)}
+     * with aTextName as the default message.
+     *
+     * @see #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
+     */
     public static String findText(Class aClass, String aTextName, Locale locale) {
         return findText(aClass, aTextName, locale, aTextName, new Object[0]);
     }
 
     /**
- * Finds a localized text message for the given key, aTextName. Both the key and the message
- * itself is evaluated as required.  The following algorithm is used to find the requested
- * message:
- * <p />
- * <ol>
- * <li>Look for message in aClass' class hierarchy.
- * <ol>
- * <li>Look for the message in a resource bundle for aClass</li>
- * <li>If not found, look for the message in a resource bundle for any implemented interface</li>
- * <li>If not found, traverse up the Class' hierarchy and repeat from the first sub-step</li>
- * </ol></li>
- * <li>If not found and aClass is a {@link ModelDriven} Action, then look for message in
- * the model's class hierarchy (repeat sub-steps listed above).</li>
- * <li>If not found, look for message in child property.  This is determined by evaluating
- * the message key as an OGNL expression.  For example, if the key is
- * <i>user.address.state</i>, then it will attempt to see if "user" can be resolved into an
- * object.  If so, repeat the entire process fromthe beginning with the object's class as
- * aClass and "address.state" as the message key.</li>
- * <li>If not found, look for the message in aClass' package hierarchy.</li>
- * <li>If still not found, look for the message in the default resource bundles.</li>
- * <li>Return defaultMessage</li>
- * </ol>
- * <p />
- * When looking for the message, if the key indexes a collection (e.g. user.phone[0]) and a
- * message for that specific key cannot be found, the general form will also be looked up
- * (i.e. user.phone[*]).
- * <p />
- * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
- * will be treated as an OGNL expression and evaluated as such.
- *
- * @param aClass         the class whose name to use as the start point for the search
- * @param aTextName      the key to find the text message for
- * @param locale         the locale the message should be for
- * @param defaultMessage the message to be returned if no text message can be found in any
- *                       resource bundle
- * @return the localized text, or null if none can be found and no defaultMessage is provided
- */
+     * Finds a localized text message for the given key, aTextName. Both the key and the message
+     * itself is evaluated as required.  The following algorithm is used to find the requested
+     * message:
+     * <p />
+     * <ol>
+     * <li>Look for message in aClass' class hierarchy.
+     * <ol>
+     * <li>Look for the message in a resource bundle for aClass</li>
+     * <li>If not found, look for the message in a resource bundle for any implemented interface</li>
+     * <li>If not found, traverse up the Class' hierarchy and repeat from the first sub-step</li>
+     * </ol></li>
+     * <li>If not found and aClass is a {@link ModelDriven} Action, then look for message in
+     * the model's class hierarchy (repeat sub-steps listed above).</li>
+     * <li>If not found, look for message in child property.  This is determined by evaluating
+     * the message key as an OGNL expression.  For example, if the key is
+     * <i>user.address.state</i>, then it will attempt to see if "user" can be resolved into an
+     * object.  If so, repeat the entire process fromthe beginning with the object's class as
+     * aClass and "address.state" as the message key.</li>
+     * <li>If not found, look for the message in aClass' package hierarchy.</li>
+     * <li>If still not found, look for the message in the default resource bundles.</li>
+     * <li>Return defaultMessage</li>
+     * </ol>
+     * <p />
+     * When looking for the message, if the key indexes a collection (e.g. user.phone[0]) and a
+     * message for that specific key cannot be found, the general form will also be looked up
+     * (i.e. user.phone[*]).
+     * <p />
+     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
+     * will be treated as an OGNL expression and evaluated as such.
+     *
+     * @param aClass         the class whose name to use as the start point for the search
+     * @param aTextName      the key to find the text message for
+     * @param locale         the locale the message should be for
+     * @param defaultMessage the message to be returned if no text message can be found in any
+     *                       resource bundle
+     * @return the localized text, or null if none can be found and no defaultMessage is provided
+     */
     public static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args) {
         ActionContext context = ActionContext.getContext();
         OgnlValueStack valueStack = context.getValueStack();
     }
 
     /**
- * Finds a localized text message for the given key, aTextName, in the specified resource bundle
- * with aTextName as the default message.
- * <p />
- * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
- * will be treated as an OGNL expression and evaluated as such.
- *
- * @see #findText(java.util.ResourceBundle, java.lang.String, java.util.Locale, java.lang.String, java.lang.Object[])
- */
+     * Finds a localized text message for the given key, aTextName, in the specified resource bundle
+     * with aTextName as the default message.
+     * <p />
+     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
+     * will be treated as an OGNL expression and evaluated as such.
+     *
+     * @see #findText(java.util.ResourceBundle, java.lang.String, java.util.Locale, java.lang.String, java.lang.Object[])
+     */
     public static String findText(ResourceBundle bundle, String aTextName, Locale locale) {
         return findText(bundle, aTextName, locale, aTextName, new Object[0]);
     }
 
     /**
- * Finds a localized text message for the given key, aTextName, in the specified resource
- * bundle.
- * <p />
- * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
- * will be treated as an OGNL expression and evaluated as such.
- */
+     * Finds a localized text message for the given key, aTextName, in the specified resource
+     * bundle.
+     * <p />
+     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
+     * will be treated as an OGNL expression and evaluated as such.
+     */
     public static String findText(ResourceBundle bundle, String aTextName, Locale locale, String defaultMessage, Object[] args) {
         OgnlValueStack valueStack = ActionContext.getContext().getValueStack();
 
     }
 
     /**
- * Gets the default message.
- */
+     * Gets the default message.
+     */
     private static String getDefaultMessage(String key, Locale locale, OgnlValueStack valueStack, Object[] args, String defaultMessage) {
         if (key != null) {
             String message = null;
     }
 
     /**
- * Gets the message from the named resource bundle.
- */
+     * Gets the message from the named resource bundle.
+     */
     private static String getMessage(String bundleName, Locale locale, String key, OgnlValueStack valueStack, Object[] args) {
         try {
             ResourceBundle bundle = findResourceBundle(bundleName, locale);
     }
 
     /**
- * Traverse up class hierarchy looking for message.  Looks at class, then implemented interface,
- * before going up hierarchy.
- */
+     * Traverse up class hierarchy looking for message.  Looks at class, then implemented interface,
+     * before going up hierarchy.
+     */
     private static String findMessage(Class clazz, String key, String indexedKey, Locale locale, Object[] args, Set checked, OgnlValueStack valueStack) {
         if (checked == null) {
             checked = new TreeSet();

src/java/com/opensymphony/xwork/validator/ActionValidatorManager.java

             if (validator instanceof FieldValidator) {
                 fValidator = (FieldValidator) validator;
                 fullFieldName = fValidator.getValidatorContext().getFullFieldName(fValidator.getFieldName());
+
                 if ((shortcircuitedFields != null) && shortcircuitedFields.contains(fullFieldName)) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Short-circuited, skipping");

src/java/com/opensymphony/xwork/validator/validators/ValidatorSupport.java

 import com.opensymphony.xwork.validator.ValidationException;
 import com.opensymphony.xwork.validator.Validator;
 import com.opensymphony.xwork.validator.ValidatorContext;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

src/test/com/opensymphony/xwork/util/LocalizedTextUtilTest.java

 package com.opensymphony.xwork.util;
 
 import com.mockobjects.dynamic.Mock;
+
 import com.opensymphony.xwork.*;
 import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.test.ModelDrivenAction2;
 import com.opensymphony.xwork.test.TestBean2;
+
 import junit.framework.TestCase;
 
 import java.util.Collections;
 public class LocalizedTextUtilTest extends TestCase {
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public void testActionGetTextXXX() {
+    public void testActionGetText() {
         try {
-            LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork/util/FindMe");
-
-            SimpleAction action = new SimpleAction();
+            ModelDrivenAction2 action = new ModelDrivenAction2();
+            TestBean2 bean = (TestBean2) action.getModel();
+            Bar bar = new Bar();
+            bean.setBarObj(bar);
 
             Mock mockActionInvocation = new Mock(ActionInvocation.class);
             mockActionInvocation.expectAndReturn("getAction", action);
             ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
             ActionContext.getContext().getValueStack().push(action);
+            ActionContext.getContext().getValueStack().push(action.getModel());
 
-            String message = action.getText("bean.name");
-            String foundBean2 = action.getText("bean2.name");
-
-            assertEquals("Okay! You found Me!", foundBean2);
-            assertEquals("Haha you cant FindMe!", message);
-
+            String message = action.getText("barObj.title");
+            assertEquals("Title:", message);
         } catch (MissingResourceException ex) {
             ex.printStackTrace();
             fail(ex.getMessage());
         }
     }
 
-    public void testActionGetText() {
+    public void testActionGetTextXXX() {
         try {
-            ModelDrivenAction2 action = new ModelDrivenAction2();
-            TestBean2 bean = (TestBean2) action.getModel();
-            Bar bar = new Bar();
-            bean.setBarObj(bar);
+            LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork/util/FindMe");
+
+            SimpleAction action = new SimpleAction();
 
             Mock mockActionInvocation = new Mock(ActionInvocation.class);
             mockActionInvocation.expectAndReturn("getAction", action);
             ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
             ActionContext.getContext().getValueStack().push(action);
-            ActionContext.getContext().getValueStack().push(action.getModel());
 
-            String message = action.getText("barObj.title");
-            assertEquals("Title:", message);
+            String message = action.getText("bean.name");
+            String foundBean2 = action.getText("bean2.name");
+
+            assertEquals("Okay! You found Me!", foundBean2);
+            assertEquals("Haha you cant FindMe!", message);
         } catch (MissingResourceException ex) {
             ex.printStackTrace();
             fail(ex.getMessage());
 
     public void testParameterizedDefaultMessage() {
         try {
-            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, Locale.getDefault(), new String[]{
-                "AddUser"
-            });
+            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, Locale.getDefault(), new String[] {
+                    "AddUser"
+                });
             assertEquals("There is no Action mapped for action name AddUser", message);
         } catch (MissingResourceException e) {
             e.printStackTrace();
 
     public void testParameterizedDefaultMessageWithPackage() {
         try {
-            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, Locale.getDefault(), new String[]{
-                "blah", "AddUser"
-            });
+            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, Locale.getDefault(), new String[] {
+                    "blah", "AddUser"
+                });
             assertEquals("There is no Action mapped for namespace blah and action name AddUser", message);
         } catch (MissingResourceException e) {
             e.printStackTrace();

src/test/com/opensymphony/xwork/validator/ActionValidatorManagerTest.java

             bean.setName("foo");
             bean.setCount(99);
 
-
             ValidatorContext context = new GenericValidatorContext(bean);
             ActionValidatorManager.validate(bean, "beanMessageBundle", context);
             assertTrue(context.hasErrors());
         }
     }
 
-    public void testMessageInterpolation() {
-        // get validators
-        List validatorList = ActionValidatorManager.getValidators(TestBean.class, "beanMessageBundle");
-        assertEquals(3, validatorList.size());
-
-        try {
-            TestBean bean = new TestBean();
-            bean.setName("foo");
-            bean.setCount(150);
-
-
-            ValidatorContext context = new GenericValidatorContext(bean);
-            ActionValidatorManager.validate(bean, "beanMessageBundle", context);
-            assertTrue(context.hasErrors());
-            assertTrue(context.hasFieldErrors());
-
-            List l = (List) context.getFieldErrors().get("count");
-            assertNotNull(l);
-            assertEquals(1, l.size());
-            assertEquals("Count must be between 1 and 100, current value is 150.", l.get(0));
-        } catch (ValidationException ex) {
-            ex.printStackTrace();
-            fail("Validation error: " + ex.getMessage());
-        }
-    }
-
     public void testGetValidatorsForInterface() {
         List validatorList = ActionValidatorManager.getValidators(DataAware2.class, alias);
 
         assertTrue(dataValidator2 instanceof RequiredStringValidator);
     }
 
+    public void testMessageInterpolation() {
+        // get validators
+        List validatorList = ActionValidatorManager.getValidators(TestBean.class, "beanMessageBundle");
+        assertEquals(3, validatorList.size());
+
+        try {
+            TestBean bean = new TestBean();
+            bean.setName("foo");
+            bean.setCount(150);
+
+            ValidatorContext context = new GenericValidatorContext(bean);
+            ActionValidatorManager.validate(bean, "beanMessageBundle", context);
+            assertTrue(context.hasErrors());
+            assertTrue(context.hasFieldErrors());
+
+            List l = (List) context.getFieldErrors().get("count");
+            assertNotNull(l);
+            assertEquals(1, l.size());
+            assertEquals("Count must be between 1 and 100, current value is 150.", l.get(0));
+        } catch (ValidationException ex) {
+            ex.printStackTrace();
+            fail("Validation error: " + ex.getMessage());
+        }
+    }
+
     public void testSameAliasWithDifferentClass() {
         List validatorList = ActionValidatorManager.getValidators(SimpleAction.class, alias);
         List validatorList2 = ActionValidatorManager.getValidators(SimpleAction2.class, alias);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.