You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/08/19 17:54:28 UTC

svn commit: r687080 - /velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java

Author: nbubna
Date: Tue Aug 19 08:54:27 2008
New Revision: 687080

URL: http://svn.apache.org/viewvc?rev=687080&view=rev
Log:
make it easier to debug extensions

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

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java?rev=687080&r1=687079&r2=687080&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java Tue Aug 19 08:54:27 2008
@@ -37,6 +37,7 @@
 {
     protected VelocityEngine engine;
     protected VelocityContext context;
+    protected boolean DEBUG = false;
 
     public BaseEvalTestCase(String name)
     {
@@ -81,22 +82,32 @@
 
     protected void assertEvalEquals(String expected, String template)
     {
+        assertEquals(expected, evaluate(template));
+    }
+
+    protected String evaluate(String template)
+    {
+        StringWriter writer = new StringWriter();
         try
         {
-            String result = evaluate(template);
-            assertEquals(expected, result);
+            if (DEBUG)
+            {
+                engine.getLog().info("Template: "+template);
+            }
+
+            // use template as its own name, since our templates are short
+            engine.evaluate(context, writer, template, template);
+
+            String result = writer.toString();
+            if (DEBUG)
+            {
+                engine.getLog().info("Result: "+result);
+            }
+            return result;
         }
         catch (Exception e)
         {
             throw new RuntimeException(e);
         }
     }
-
-    protected String evaluate(String template) throws Exception
-    {
-        StringWriter writer = new StringWriter();
-        // use template as its own name, since our templates are short
-        engine.evaluate(context, writer, template, template);
-        return writer.toString();
-    }
 }