Author: wglass
Date: Tue Nov  3 02:05:39 2009
New Revision: 832262

URL: http://svn.apache.org/viewvc?rev=832262&view=rev
Log:
test that macros are blocked from loading with null return from 
IncludeEventHandler

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

Modified: 
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java?rev=832262&r1=832261&r2=832262&view=diff
==============================================================================
--- 
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
 (original)
+++ 
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
 Tue Nov  3 02:05:39 2009
@@ -23,6 +23,8 @@
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -215,6 +217,36 @@
                 RESULT_FILE_EXT, CMP_FILE_EXT));
     }
 
+    /**
+     * Check bug VELOCITY-717.
+     */
+    public void testIncludeEventHandlingBlockMacros()
+            throws Exception
+    {
+        Template template = engine.getTemplate(
+            getFileName(null, "test7", TMPL_FILE_EXT));
+
+        FileOutputStream fos =
+            new FileOutputStream (
+                getFileName(RESULTS_DIR, "test7", RESULT_FILE_EXT));
+
+        Writer writer = new BufferedWriter(new OutputStreamWriter(fos));
+
+        // set up handler
+        Context context = new VelocityContext();
+        EventCartridge ec = new EventCartridge();
+        ec.addEventHandler(this);
+        ec.attachToContext( context );
+        
+        EventHandlerBehavior = BLOCK;
+        template.merge(context, writer);
+        writer.flush();
+        writer.close();
+
+        assertTrue("Output incorrect.", isMatch(RESULTS_DIR, COMPARE_DIR, 
"test7",
+                RESULT_FILE_EXT, CMP_FILE_EXT));
+    }
+
 
     public void setRuntimeServices( RuntimeServices rs )
     {


Reply via email to