svn commit: r912280 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string: FlexibleStringExpander.java test/FlexibleStringExpanderTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r912280 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string: FlexibleStringExpander.java test/FlexibleStringExpanderTests.java

doogie-3
Author: doogie
Date: Sun Feb 21 01:31:30 2010
New Revision: 912280

URL: http://svn.apache.org/viewvc?rev=912280&view=rev
Log:
BUG FIX: Fix parsing of currency, by using the correct subExpression,
instead of the entire parent expression.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=912280&r1=912279&r2=912280&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java Sun Feb 21 01:31:30 2010
@@ -214,7 +214,7 @@
                 if (escapedExpression) {
                     strElems.add(new ConstElem(expression.substring(start, end + 1)));
                 } else if (subExpression.contains("?currency(")) {
-                    strElems.add(new CurrElem(expression));
+                    strElems.add(new CurrElem(subExpression));
                 } else if (subExpression.contains(openBracket)) {
                     strElems.add(new NestedVarElem(subExpression));
                 } else {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java?rev=912280&r1=912279&r2=912280&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java Sun Feb 21 01:31:30 2010
@@ -84,13 +84,13 @@
         parserTest("currency", "${price?currency(usd)", "${price?currency(usd)");
         // CurrElem doesn't protected itself
         //parserTest("currency", "${?currency(}", "${?currency(}");
-        parserTest("currency", "${?currency()}", "${?currency()}");
+        parserTest("currency", "${?currency()}", "?currency()");
         //parserTest("currency", "${?currency(usd}", "${?currency(usd}");
-        parserTest("currency", "${?currency(usd)}", "${?currency(usd)}");
+        parserTest("currency", "${?currency(usd)}", "?currency(usd)");
         //parserTest("currency", "${price?currency(}", "${price?currency(}");
-        parserTest("currency", "${price?currency()}", "${price?currency()}");
+        parserTest("currency", "${price?currency()}", "price?currency()");
         //parserTest("currency", "${price?currency(usd}", "${price?currency(usd}");
-        parserTest("currency", "${price?currency(usd)}", "${price?currency(usd)}");
+        parserTest("currency", "${price?currency(usd)}", "price?currency(usd)");
         parserTest("currency", "a${price?currency(usd)}b", "a${price?currency(usd)}b");
     }
 
@@ -271,10 +271,10 @@
         fseTest("just bad", "${foobar", testMap, "${foobar", false);
         fseTest("constant and bad", "Hello${foobar", testMap, "Hello${foobar", false);
         fseTest("good and bad", "Hello ${var}${foobar", testMap, "Hello World${foobar", false);
-        //fseTest("currency(USD)", "The total is ${amount?currency(${usd})}.", testMap, null, localeToTest, "The total is $1,234,567.89.", false);
-        //fseTest("currency(USD): null", "The total is ${testMap.missing?currency(${usd})}.", testMap, null, localeToTest, "The total is .", false);
-        //fseTest("currency(USD): missing", "The total is ${noList[0]?currency(${usd})}.", testMap, null, localeToTest, "The total is .", false);
-        //fseTest("currency(USD): exception", "The total is ${throwException.value?currency(${usd})}.", testMap, null, localeToTest, "The total is .", false);
+        fseTest("currency(USD)", "The total is ${amount?currency(${usd})}.", testMap, null, localeToTest, "The total is $1,234,567.89.", false);
+        fseTest("currency(USD): null", "The total is ${testMap.missing?currency(${usd})}.", testMap, null, localeToTest, "The total is .", false);
+        fseTest("currency(USD): missing", "The total is ${noList[0]?currency(${usd})}.", testMap, null, localeToTest, "The total is .", false);
+        fseTest("currency(USD): exception", "The total is ${throwException.value?currency(${usd})}.", testMap, null, localeToTest, "The total is .", false);
         fseTest("null nested", "${${nullVar}}!", testMap, "!", false);
         fseTest("bsh: script", "${bsh:return \"Hello \" + var + \"!\";}", testMap, "Hello World!", false);
         fseTest("bsh: null", "${bsh:return null;}!", testMap, "!", false);