Commits

Anonymous committed 11a2c00

Fix for XW-182 and test cases to make sure it doesn't happen again.

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

  • Participants
  • Parent commits 051b5ae

Comments (0)

Files changed (5)

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

                     String message = TextParseUtil.translateVariables(bundle.getString(aTextName), valueStack);
 
                     return MessageFormat.format(message, args);
+                } else {
+                    clazz = clazz.getSuperclass();
                 }
             } catch (MissingResourceException ex) {
                 clazz = clazz.getSuperclass();

src/test/PackagelessAction.java

+
+import com.opensymphony.xwork.ActionSupport;
+
+
+/**
+ * @author Mark Woon
+ */
+public class PackagelessAction extends ActionSupport {
+
+    /**
+     * Default constructor.
+     */
+    public PackagelessAction() {
+    }
+
+    public String execute() {
+        // from action's bundle
+        System.out.println(getText("actionProperty"));
+        // from default bundle
+        System.out.println(getText("foo.range"));
+        // nonexistant
+        System.out.println(getText("non.existant"));
+        return NONE;
+    }
+}

src/test/PackagelessAction.properties

+actionProperty = action property

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

 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.ActionInvocation;
 import com.opensymphony.xwork.XWorkMessages;
+import com.opensymphony.xwork.ActionProxyFactory;
+import com.opensymphony.xwork.ActionProxy;
 import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.test.ModelDrivenAction2;
 
 
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.Collections;
 
 
 /**
         }
     }
 
+    public void testAddDefaultResourceBundle2() {
+
+        LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork/SimpleAction");
+
+        try {
+            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("/", "packagelessAction", Collections.EMPTY_MAP, false);
+            proxy.execute();
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+
     public void testDefaultMessage() {
         try {
             String message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());

src/test/xwork.xml

             <interceptor-ref name="defaultStack"/>
         </action>
 
+        <action name="packagelessAction" class="PackagelessAction">
+        </action>
+
         <action name="Bar" class="com.opensymphony.xwork.SimpleAction">
             <param name="foo">17</param>
             <param name="bar">23</param>