Commits

Anonymous committed 80b5b49

i18n and ww:text tag can throw an exception under certain conditions
o added missing check for clazz.isPrimitive()
Issue Number: WW-1321

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/xwork_1-2/src@1073e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (3)

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

                 }
             }
         } else {
-            if (!clazz.equals(Object.class)) {
+            if (!clazz.equals(Object.class) && !clazz.isPrimitive()) {
                 return findMessage(clazz.getSuperclass(), key, indexedKey, locale, args, checked, valueStack);
             }
         }

test/com/opensymphony/xwork/util/FindMe.properties

 bean.name=Haha you cant FindMe!
 bean2.name=Okay! You found Me!
+bar=Test
+bar.name=Sausalitos!
+foo.name=My Foo!
+percentage=Nothing

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

         assertEquals("Haha you cant FindMe!", message);
     }
 
+    public void testActionGetTextPrimitive() throws Exception {
+        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);
+
+        String bar = action.getText("bar");
+        String percentage = action.getText("percentage");
+        String barname = action.getText("bar.name");
+        String fooname = action.getText("foo.name");
+
+        assertEquals("Test", bar);
+        assertEquals("Nothing", percentage);
+        assertEquals("Sausalitos!", barname);
+        assertEquals("My Foo!", fooname);
+
+    }
+
     public void testAddDefaultResourceBundle() {
         String text = LocalizedTextUtil.findDefaultText("foo.range", Locale.getDefault());
         assertNull("Found message when it should not be available.", null);