svn commit: r912276 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/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: r912276 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java

doogie-3
Author: doogie
Date: Sun Feb 21 01:29:29 2010
New Revision: 912276

URL: http://svn.apache.org/viewvc?rev=912276&view=rev
Log:
Extend fseTest to check isEmpty.

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

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=912276&r1=912275&r2=912276&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:29:29 2010
@@ -33,30 +33,29 @@
         super(name);
     }
 
-    private static void fseTest(String label, String input, Map<String, ? extends Object> context, Object compare) {
+    private static void fseTest(String label, String input, Map<String, ? extends Object> context, Object compare, boolean isEmpty) {
         FlexibleStringExpander fse = FlexibleStringExpander.getInstance(input);
         assertEquals(label, compare, fse.expandString(context));
+        assertEquals("isEmpty:" + label, isEmpty, fse.isEmpty());
     }
 
     public void testFlexibleStringExpander() {
-        FlexibleStringExpander fse = FlexibleStringExpander.getInstance(null);
-        assertTrue("null FlexibleStringExpander", fse.isEmpty());
-        fseTest("null FlexibleStringExpander", null, null, "");
-        fseTest("null context", "Hello World!", null, "Hello World!");
+        fseTest("null FlexibleStringExpander", null, null, "", true);
+        fseTest("null context", "Hello World!", null, "Hello World!", false);
         Map<String, Object> testMap = new HashMap<String, Object>();
         testMap.put("var", "World");
-        fseTest("simple replacement", "Hello ${var}!", testMap, "Hello World!");
+        fseTest("simple replacement", "Hello ${var}!", testMap, "Hello World!", false);
         testMap.put("nested", "Hello ${var}");
-        fseTest("hidden (runtime) nested replacement", "${nested}!", testMap, "Hello World!");
-        fseTest("visible nested replacement", "${'Hello ${var}'}!", testMap, "Hello World!");
-        fseTest("bsh: script", "${bsh:return \"Hello \" + var + \"!\";}", testMap, "Hello World!");
-        fseTest("groovy: script", "${groovy:return \"Hello \" + var + \"!\";}", testMap, "Hello World!");
+        fseTest("hidden (runtime) nested replacement", "${nested}!", testMap, "Hello World!", false);
+        fseTest("visible nested replacement", "${'Hello ${var}'}!", testMap, "Hello World!", false);
+        fseTest("bsh: script", "${bsh:return \"Hello \" + var + \"!\";}", testMap, "Hello World!", false);
+        fseTest("groovy: script", "${groovy:return \"Hello \" + var + \"!\";}", testMap, "Hello World!", false);
         testMap.put("testMap", testMap);
-        fseTest("UEL integration: Map", "Hello ${testMap.var}!", testMap, "Hello World!");
+        fseTest("UEL integration: Map", "Hello ${testMap.var}!", testMap, "Hello World!", false);
         List<String> testList = new ArrayList<String>();
         testList.add("World");
         testMap.put("testList", testList);
-        fseTest("UEL integration: List", "Hello ${testList[0]}!", testMap, "Hello World!");
-        fseTest("Escaped expression", "This is an \\${escaped} expression", testMap, "This is an ${escaped} expression");
+        fseTest("UEL integration: List", "Hello ${testList[0]}!", testMap, "Hello World!", false);
+        fseTest("Escaped expression", "This is an \\${escaped} expression", testMap, "This is an ${escaped} expression", false);
     }
 }