Author: henning
Date: Sun Oct 30 06:54:06 2005
New Revision: 329578

URL: http://svn.apache.org/viewcvs?rev=329578&view=rev
Log:
add tests for the macro exception case checking whether macro def and
invocation correctly generate line and column information.


Modified:
    
jakarta/velocity/core/trunk/src/test/org/apache/velocity/test/ParseExceptionTestCase.java

Modified: 
jakarta/velocity/core/trunk/src/test/org/apache/velocity/test/ParseExceptionTestCase.java
URL: 
http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/test/org/apache/velocity/test/ParseExceptionTestCase.java?rev=329578&r1=329577&r2=329578&view=diff
==============================================================================
--- 
jakarta/velocity/core/trunk/src/test/org/apache/velocity/test/ParseExceptionTestCase.java
 (original)
+++ 
jakarta/velocity/core/trunk/src/test/org/apache/velocity/test/ParseExceptionTestCase.java
 Sun Oct 30 06:54:06 2005
@@ -136,5 +136,74 @@
         }
     }
     
+    /**
+     * Tests that parseException has useful info when thrown in 
VelocityEngine.evaluate()
+     * and the problem comes from a macro definition
+     * @throws Exception
+     */
+    public void testParseExceptionFromMacroDef ()
+            throws Exception
+    {
+        VelocityEngine ve = new VelocityEngine();
+        ve.init();
+        
+        VelocityContext context = new VelocityContext();
+        
+        Writer writer = new StringWriter();
+        
+        try 
+        {
+            ve.evaluate(context,writer,"testMacro","#macro($blarg) foo #end"); 
    
+            fail("Should have thown a ParseErrorException");
+        } 
+        catch (ParseErrorException e) 
+        {
+            assertEquals("testMacro",e.getTemplateName());
+            assertEquals(1,e.getLineNumber());
+            assertEquals(7,e.getColumnNumber());
+        } 
+        finally
+        {
+            if (writer != null)
+            {
+                writer.close();
+            }
+        }
+    }
+ 
+    /**
+     * Tests that parseException has useful info when thrown in 
VelocityEngine.evaluate()
+     * and the problem comes from a macro invocation
+     * @throws Exception
+     */
+    public void testParseExceptionFromMacroInvoke ()
+            throws Exception
+    {
+        VelocityEngine ve = new VelocityEngine();
+        ve.init();
+        
+        VelocityContext context = new VelocityContext();
+        
+        Writer writer = new StringWriter();
+        
+        try 
+        {
+            ve.evaluate(context,writer,"testMacroInvoke", "#macro(   foo $a) 
$a #end #foo(woogie)");     
+            fail("Should have thown a ParseErrorException");
+        } 
+        catch (ParseErrorException e) 
+        {
+            assertEquals("testMacroInvoke",e.getTemplateName());
+            assertEquals(1,e.getLineNumber());
+            assertEquals(31,e.getColumnNumber());
+        } 
+        finally
+        {
+            if (writer != null)
+            {
+                writer.close();
+            }
+        }
+    }
  
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to