Author: doogie
Date: Tue Feb 23 15:43:17 2010
New Revision: 915392
URL:
http://svn.apache.org/viewvc?rev=915392&view=revLog:
Create an fmaTest helper method.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java?rev=915392&r1=915391&r2=915392&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/test/FlexibleMapAccessorTests.java Tue Feb 23 15:43:17 2010
@@ -34,18 +34,18 @@
super(name);
}
+ private static <T, V> void fmaTest(String label, String fmaText, String fseText, T var, V value) {
+ Map<String, Object> testMap = new HashMap<String, Object>();
+ FlexibleMapAccessor<T> fma = FlexibleMapAccessor.getInstance(fmaText);
+ fma.put(testMap, var);
+ FlexibleStringExpander fse = FlexibleStringExpander.getInstance(fseText);
+ assertEquals(label, value, fse.expandString(testMap));
+
+ }
// These tests rely upon FlexibleStringExpander, so they
// should follow the FlexibleStringExpander tests.
public void testFlexibleMapAccessor() {
- String compare = "Hello World!";
- Map<String, Object> testMap = new HashMap<String, Object>();
- FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance("parameters.var");
- fma.put(testMap, "World");
- FlexibleStringExpander fse = FlexibleStringExpander.getInstance("Hello ${parameters.var}!");
- assertEquals("UEL auto-vivify Map", compare, fse.expandString(testMap));
- fma = FlexibleMapAccessor.getInstance("parameters.someList[+0]");
- fma.put(testMap, "World");
- fse = FlexibleStringExpander.getInstance("Hello ${parameters.someList[0]}!");
- assertEquals("UEL auto-vivify List", compare, fse.expandString(testMap));
+ fmaTest("UEL auto-vivify Map", "parameters.var", "Hello ${parameters.var}!", "World", "Hello World!");
+ fmaTest("UEL auto-vivify List", "parameters.someList[+0]", "Hello ${parameters.someList[0]}!", "World", "Hello World!");
}
}