velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From by...@apache.org
Subject svn commit: r736575 - /velocity/engine/trunk/src/test/org/apache/velocity/test/StrictEscapeTestCase.java
Date Thu, 22 Jan 2009 06:16:55 GMT
Author: byron
Date: Wed Jan 21 22:16:55 2009
New Revision: 736575

URL: http://svn.apache.org/viewvc?rev=736575&view=rev
Log:
VELOCITY-623 Additional test cases for strict escapes setting

Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/StrictEscapeTestCase.java

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/StrictEscapeTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StrictEscapeTestCase.java?rev=736575&r1=736574&r2=736575&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/StrictEscapeTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/StrictEscapeTestCase.java Wed
Jan 21 22:16:55 2009
@@ -37,17 +37,16 @@
   {
       super.setUp();
       engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE, Boolean.TRUE);
+      DEBUG=true;
       context.put("pow", "bang");
   }
   
-  /**
-   * Test that escaping works in strict mode
-   */
   public void testVarEscape()
   {
-      assertEvalEquals("\\$bogus", "\\\\$bogus");
-      assertEvalEquals("\\\\$bogus", "\\\\\\\\$bogus");
-      assertEvalEquals("\\$bogus", "#set($foo = \"\\\\$bogus\")$foo");
+      engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, Boolean.TRUE);
+
+      assertEvalException("\\\\$bogus");
+      assertEvalException("\\\\\\\\$bogus");
     
       assertEvalEquals("$bogus", "\\$bogus");
       assertEvalEquals("$bogus.xyz", "\\$bogus.xyz");
@@ -61,14 +60,13 @@
       assertEvalEquals("\\bang", "#set($foo = \"\\\\$pow\")$foo");
       assertEvalEquals("\\$pow", "#set($foo = \"\\\\\\$pow\")$foo");
       
-      assertEvalEquals("\\$%", "\\$%");      
+      assertEvalEquals("\\$%", "\\$%");
   } 
-  
-  
+    
   public void testMacroEscape()
   {
-      assertEvalEquals("#bogus()", "\\#bogus()");
-      assertEvalEquals("\\#bogus", "\\\\#bogus");
+      engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, Boolean.TRUE);
+      assertEvalException("\\\\#bogus()");
 
       // define the foo macro
       assertEvalEquals("", "#macro(foo)bar#end");
@@ -88,6 +86,21 @@
       assertEvalEquals("#end #foreach #define() #elseif", "\\#end \\#foreach \\#define()
\\#elseif");
       assertEvalEquals("#{end} #{foreach} #{define}() #{elseif}", "\\#{end} \\#{foreach}
\\#{define}() \\#{elseif}");
       assertEvalEquals("#macro(foo) #end", "\\#macro(foo) \\#end");
-      
+            
+      assertEvalException("\\\\#end");
+      assertEvalException("\\\\#if()");      
   }
+
+  /**
+   * Tests for non strict-mode
+   */
+  public void testStrictMode()
+  {
+      assertEvalEquals("#bogus()", "\\#bogus()");
+      assertEvalEquals("\\#bogus", "\\\\#bogus");
+      
+      assertEvalEquals("\\$bogus", "\\\\$bogus");
+      assertEvalEquals("\\\\$bogus", "\\\\\\\\$bogus");
+      assertEvalEquals("\\$bogus", "#set($foo = \"\\\\$bogus\")$foo");    
+  }  
 }



Mime
View raw message