velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wgl...@apache.org
Subject svn commit: r676433 - in /velocity/engine/trunk: src/test/org/apache/velocity/test/EvaluateTestCase.java test/evaluate/compare/eval2.cmp test/evaluate/eval2.vm
Date Sun, 13 Jul 2008 20:09:13 GMT
Author: wglass
Date: Sun Jul 13 13:09:13 2008
New Revision: 676433

URL: http://svn.apache.org/viewvc?rev=676433&view=rev
Log:
test case for VELOCITY-591

Added:
    velocity/engine/trunk/test/evaluate/compare/eval2.cmp   (with props)
    velocity/engine/trunk/test/evaluate/eval2.vm   (with props)
Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java?rev=676433&r1=676432&r2=676433&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java Sun Jul
13 13:09:13 2008
@@ -24,6 +24,9 @@
 import java.io.OutputStreamWriter;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -102,7 +105,30 @@
     public void testEvaluate()
     throws Exception
     {
-        testFile("eval1");
+        testFile("eval1", new HashMap());
+    }
+
+    /**
+     * Test evaluate directive preserves macros (VELOCITY-591)
+     * @throws Exception
+     */
+    public void testEvaluateMacroPreserve()
+    throws Exception
+    {
+        Map properties = new HashMap();
+        properties.clear();
+        properties.put(RuntimeConstants.VM_CONTEXT_LOCALSCOPE,"false");
+        testFile("eval2", properties);
+
+        properties.clear();
+        properties.put(RuntimeConstants.VM_CONTEXT_LOCALSCOPE,"true");
+        testFile("eval2", properties);
+
+        properties.clear();
+        properties.put(RuntimeConstants.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL,"false");
+        testFile("eval2", properties);
+
+
     }
 
     /**
@@ -112,7 +138,7 @@
     public void testEvaluateVMContext()
     throws Exception
     {
-        testFile("evalvmcontext");
+        testFile("evalvmcontext", new HashMap());
     }
 
     /**
@@ -241,11 +267,19 @@
      * @param basefilename
      * @throws Exception
      */
-    private void testFile(String basefilename)
+    private void testFile(String basefilename, Map properties)
     throws Exception
     {
         VelocityEngine ve = new VelocityEngine();
         ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+     
+        for (Iterator i = properties.keySet().iterator(); i.hasNext();)
+        {
+            String key = (String) i.next();
+            String value = (String) properties.get(key);
+            ve.addProperty(key, value);
+        }
+        
         ve.init();
         
         Template template;

Added: velocity/engine/trunk/test/evaluate/compare/eval2.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/evaluate/compare/eval2.cmp?rev=676433&view=auto
==============================================================================
--- velocity/engine/trunk/test/evaluate/compare/eval2.cmp (added)
+++ velocity/engine/trunk/test/evaluate/compare/eval2.cmp Sun Jul 13 13:09:13 2008
@@ -0,0 +1,7 @@
+test 1: a: 12
+basic string
+test 2: a: 22
+
+test 3: inner eval: 33
+basic string
+test 4: inner eval: 44

Propchange: velocity/engine/trunk/test/evaluate/compare/eval2.cmp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/evaluate/compare/eval2.cmp
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/engine/trunk/test/evaluate/eval2.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/evaluate/eval2.vm?rev=676433&view=auto
==============================================================================
--- velocity/engine/trunk/test/evaluate/eval2.vm (added)
+++ velocity/engine/trunk/test/evaluate/eval2.vm Sun Jul 13 13:09:13 2008
@@ -0,0 +1,23 @@
+##
+## Test evaluate preserves macros 
+##
+#macro (test $a)
+a: $a
+#end
+test 1: #test(12)
+#evaluate("basic string")
+
+test 2: #test(22)
+
+##
+## Test again while doing evaluate within macro 
+##
+#macro (test2 $a)
+#evaluate("inner eval: $a")
+#end
+test 3: #test2(33)
+
+#evaluate("basic string")
+
+test 4: #test2(44)
+

Propchange: velocity/engine/trunk/test/evaluate/eval2.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/evaluate/eval2.vm
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision



Mime
View raw message