Author: nbubna
Date: Wed Mar 11 22:32:29 2009
New Revision: 752660

URL: http://svn.apache.org/viewvc?rev=752660&view=rev
Log:
ensure that debug log messages don't inadvertantly cause test failures

Modified:
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java?rev=752660&r1=752659&r2=752660&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
 Wed Mar 11 22:32:29 2009
@@ -130,30 +130,29 @@
 
     protected void info(String msg)
     {
-        if (DEBUG)
-        {
-            if (engine == null)
-            {
-                Velocity.getLog().info(msg);
-            }
-            else
-            {
-                engine.getLog().info(msg);
-            }
-        }
+        info(msg, null);
     }
 
     protected void info(String msg, Throwable t)
     {
         if (DEBUG)
         {
-            if (engine == null)
+            try
             {
-                Velocity.getLog().info(msg);
+                if (engine == null)
+                {
+                    Velocity.getLog().info(msg, t);
+                }
+                else
+                {
+                    engine.getLog().info(msg, t);
+                }
             }
-            else
+            catch (Throwable t2)
             {
-                engine.getLog().info(msg, t);
+                System.out.println("Failed to log: "+msg+(t!=null?" - "+t: 
""));
+                System.out.println("Cause: "+t2);
+                t2.printStackTrace();
             }
         }
     }
@@ -452,6 +451,10 @@
                                String resultExt,
                                String compareExt) throws Exception
     {
+        if (DEBUG)
+        {
+            info("Result: "+resultsDir+baseFileName+resultExt);
+        }
         String result = getFileContents(resultsDir, baseFileName, resultExt);
         return isMatch(result,compareDir,baseFileName,compareExt);
     }
@@ -484,8 +487,7 @@
         compare = normalizeNewlines(compare);
         if (DEBUG)
         {
-            info("Expection: "+compare);
-            info("Result: "+result);
+            info("Expection: "+compareDir+baseFileName+compareExt);
         }
         return result.equals(compare);
     }


Reply via email to