You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by wg...@apache.org on 2005/09/12 00:24:43 UTC
svn commit: r280189 [2/2] - in /jakarta/velocity/core/trunk: ./ build/
build/lib/ src/java/org/apache/velocity/app/event/
src/java/org/apache/velocity/app/event/implement/
src/java/org/apache/velocity/context/ src/java/org/apache/velocity/runtime/
src/...
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties Sun Sep 11 15:24:20 2005
@@ -140,6 +140,19 @@
resource.manager.class = org.apache.velocity.runtime.resource.ResourceManagerImpl
resource.manager.cache.class = org.apache.velocity.runtime.resource.ResourceCacheImpl
+
+#----------------------------------------------------------------------------
+# EVENT HANDLER
+#----------------------------------------------------------------------------
+# Allows alternative event handlers to be plugged in. Note that each
+# class property is actually a comma-separated list of classes (which will
+# be called in order).
+#----------------------------------------------------------------------------
+#eventhandler.referenceinsertion.class =
+#eventhandler.nullset.class =
+#eventhandler.methodexception.class =
+#eventhandler.include.class =
+
#----------------------------------------------------------------------------
# PLUGGABLE INTROSPECTOR
#----------------------------------------------------------------------------
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java Sun Sep 11 15:24:20 2005
@@ -215,7 +215,9 @@
*/
public EventCartridge attachEventCartridge(EventCartridge ec)
{
- return innerContext.attachEventCartridge(ec);
+ EventCartridge cartridge = innerContext.attachEventCartridge( ec );
+
+ return cartridge;
}
/**
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Include.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Include.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Include.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Include.java Sun Sep 11 15:24:20 2005
@@ -17,19 +17,19 @@
* limitations under the License.
*/
-import java.io.Writer;
import java.io.IOException;
+import java.io.Writer;
+import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.resource.Resource;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
/**
* Pluggable directive that handles the #include() statement in VTL.
* This #include() can take multiple arguments of either
@@ -158,22 +158,20 @@
* @param writer output Writer
* @return boolean success or failure. failures are logged
*/
- private boolean renderOutput( Node node, InternalContextAdapter context,
+ private boolean renderOutput( Node node, InternalContextAdapter context,
Writer writer )
throws IOException, MethodInvocationException,
ResourceNotFoundException
{
- String arg = "";
-
if ( node == null )
{
rsvc.error("#include() error : null argument");
return false;
}
-
+
/*
* does it have a value? If you have a null reference, then no.
- */
+ */
Object value = node.value( context );
if ( value == null)
{
@@ -184,39 +182,63 @@
/*
* get the path
*/
- arg = value.toString();
+ String sourcearg = value.toString();
+
+ /*
+ * check to see if the argument will be changed by the event handler
+ */
+
+ String arg = EventHandlerUtil.includeEvent( rsvc, context, sourcearg, context.getCurrentTemplateName(), getName() );
+
+ /*
+ * a null return value from the event cartridge indicates we should not
+ * input a resource.
+ */
+ boolean blockinput = false;
+ if (arg == null)
+ blockinput = true;
Resource resource = null;
try
{
- resource = rsvc.getContent(arg, getInputEncoding(context));
+ if (!blockinput)
+ resource = rsvc.getContent(arg, getInputEncoding(context));
}
catch ( ResourceNotFoundException rnfe )
{
- /*
- * the arg wasn't found. Note it and throw
- */
-
- rsvc.error("#include(): cannot find resource '" + arg +
+ /*
+ * the arg wasn't found. Note it and throw
+ */
+
+ rsvc.error("#include(): cannot find resource '" + arg +
"', called from template " +
context.getCurrentTemplateName() + " at (" +
getLine() + ", " + getColumn() + ")" );
- throw rnfe;
+ throw rnfe;
}
catch (Exception e)
{
- rsvc.error("#include(): arg = '" + arg +
+ rsvc.error("#include(): arg = '" + arg +
"', called from template " +
context.getCurrentTemplateName() + " at (" +
getLine() + ", " + getColumn() + ") : " + e);
- }
-
- if ( resource == null )
+ }
+
+
+ /*
+ * note - a blocked input is still a successful operation as this is
+ * expected behavior.
+ */
+
+ if ( blockinput )
+ return true;
+
+ else if ( resource == null )
return false;
-
- writer.write((String)resource.getData());
+
+ writer.write((String)resource.getData());
return true;
}
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java Sun Sep 11 15:24:20 2005
@@ -19,16 +19,15 @@
import java.io.IOException;
import java.io.Writer;
-import org.apache.velocity.context.InternalContextAdapter;
-
import org.apache.velocity.Template;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.parser.node.Node;
-import org.apache.velocity.runtime.parser.node.SimpleNode;
-
+import org.apache.velocity.app.event.EventHandlerUtil;
+import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.runtime.parser.node.SimpleNode;
/**
* Pluggable directive that handles the <code>#parse()</code>
@@ -78,7 +77,7 @@
* argument that is appropriate. Any non appropriate
* arguments are logged, but render() continues.
*/
- public boolean render( InternalContextAdapter context,
+ public boolean render( InternalContextAdapter context,
Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException,
MethodInvocationException
@@ -91,7 +90,7 @@
rsvc.error( "#parse() error : null argument" );
return false;
}
-
+
/*
* does it have a value? If you have a null reference, then no.
*/
@@ -106,8 +105,23 @@
/*
* get the path
*/
- String arg = value.toString();
-
+ String sourcearg = value.toString();
+
+ /*
+ * check to see if the argument will be changed by the event cartridge
+ */
+
+
+ String arg = EventHandlerUtil.includeEvent( rsvc, context, sourcearg, context.getCurrentTemplateName(), getName());
+
+ /*
+ * a null return value from the event cartridge indicates we should not
+ * input a resource.
+ */
+ boolean blockinput = false;
+ if (arg == null)
+ blockinput = true;
+
/*
* see if we have exceeded the configured depth.
* If it isn't configured, put a stop at 20 just in case.
@@ -115,7 +129,7 @@
Object[] templateStack = context.getTemplateNameStack();
- if ( templateStack.length >=
+ if ( templateStack.length >=
rsvc.getInt(RuntimeConstants.PARSE_DIRECTIVE_MAXDEPTH, 20) )
{
StringBuffer path = new StringBuffer();
@@ -125,7 +139,7 @@
path.append( " > " + templateStack[i] );
}
- rsvc.error( "Max recursion depth reached (" +
+ rsvc.error( "Max recursion depth reached (" +
templateStack.length + ")" + " File stack:" + path );
return false;
}
@@ -133,55 +147,58 @@
/*
* now use the Runtime resource loader to get the template
*/
-
+
Template t = null;
- try
+ try
{
- t = rsvc.getTemplate( arg, getInputEncoding(context) );
+ if (!blockinput)
+ t = rsvc.getTemplate( arg, getInputEncoding(context) );
}
catch ( ResourceNotFoundException rnfe )
{
- /*
- * the arg wasn't found. Note it and throw
- */
-
- rsvc.error("#parse(): cannot find template '" + arg +
+ /*
+ * the arg wasn't found. Note it and throw
+ */
+
+ rsvc.error("#parse(): cannot find template '" + arg +
"', called from template " +
context.getCurrentTemplateName() + " at (" +
getLine() + ", " + getColumn() + ")" );
- throw rnfe;
+ throw rnfe;
}
catch ( ParseErrorException pee )
{
- /*
- * the arg was found, but didn't parse - syntax error
- * note it and throw
- */
+ /*
+ * the arg was found, but didn't parse - syntax error
+ * note it and throw
+ */
- rsvc.error("#parse(): syntax error in #parse()-ed template '" +
+ rsvc.error("#parse(): syntax error in #parse()-ed template '" +
arg + "', called from template " +
context.getCurrentTemplateName() + " at (" +
getLine() + ", " + getColumn() + ")" );
-
- throw pee;
- }
+
+ throw pee;
+ }
catch ( Exception e)
- {
- rsvc.error("#parse() : arg = " + arg + ". Exception : " + e);
+ {
+ rsvc.error("#parse() : arg = " + arg + ". Exception : " + e);
return false;
}
-
+
/*
* and render it
*/
try
{
- context.pushCurrentTemplateName(arg);
- ((SimpleNode) t.getData()).render( context, writer );
+ if (!blockinput) {
+ context.pushCurrentTemplateName(arg);
+ ((SimpleNode) t.getData()).render( context, writer );
+ }
}
catch ( Exception e )
- {
+ {
/*
* if it's a MIE, it came from the render.... throw it...
*/
@@ -196,10 +213,17 @@
}
finally
{
- context.popCurrentTemplateName();
+ if (!blockinput)
+ context.popCurrentTemplateName();
}
+ /*
+ * note - a blocked input is still a successful operation as this is
+ * expected behavior.
+ */
+
return true;
}
+
}
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java Sun Sep 11 15:24:20 2005
@@ -16,17 +16,17 @@
* limitations under the License.
*/
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.runtime.parser.Parser;
-import org.apache.velocity.util.introspection.IntrospectionCacheData;
import org.apache.velocity.util.introspection.Info;
+import org.apache.velocity.util.introspection.IntrospectionCacheData;
import org.apache.velocity.util.introspection.VelPropertyGet;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.app.event.EventCartridge;
-
-import java.lang.reflect.InvocationTargetException;
-
/**
* ASTIdentifier.java
*
@@ -165,12 +165,11 @@
* also, let non-Exception Throwables go...
*/
- if (ec != null
- && ite.getTargetException() instanceof java.lang.Exception)
+ if (ite.getTargetException() instanceof java.lang.Exception)
{
try
{
- return ec.methodException(o.getClass(), vg.getMethodName(),
+ return EventHandlerUtil.methodException(rsvc, context, o.getClass(), vg.getMethodName(),
(Exception)ite.getTargetException());
}
catch(Exception e)
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java Sun Sep 11 15:24:20 2005
@@ -16,16 +16,15 @@
* limitations under the License.
*/
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.parser.*;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.runtime.parser.Parser;
+import org.apache.velocity.util.introspection.Info;
import org.apache.velocity.util.introspection.IntrospectionCacheData;
import org.apache.velocity.util.introspection.VelMethod;
-import org.apache.velocity.util.introspection.Info;
-
-import org.apache.velocity.exception.MethodInvocationException;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.velocity.app.event.EventCartridge;
/**
* ASTMethod.java
@@ -226,18 +225,15 @@
* above
*/
- EventCartridge ec = context.getEventCartridge();
-
/*
- * if we have an event cartridge, see if it wants to veto
- * also, let non-Exception Throwables go...
+ * let non-Exception Throwables go...
*/
- if ( ec != null && ite.getTargetException() instanceof java.lang.Exception)
+ if ( ite.getTargetException() instanceof java.lang.Exception)
{
try
{
- return ec.methodException( o.getClass(), methodName, (Exception)ite.getTargetException() );
+ return EventHandlerUtil.methodException( rsvc, context, o.getClass(), methodName, (Exception)ite.getTargetException() );
}
catch( Exception e )
{
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java Sun Sep 11 15:24:20 2005
@@ -16,22 +16,20 @@
* limitations under the License.
*/
-import java.io.Writer;
import java.io.IOException;
+import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
+import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.exception.ReferenceException;
-import org.apache.velocity.runtime.parser.*;
-
-import org.apache.velocity.util.introspection.VelPropertySet;
+import org.apache.velocity.runtime.parser.Parser;
+import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.util.introspection.Info;
-
-import org.apache.velocity.exception.MethodInvocationException;
-
-import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.util.introspection.VelPropertySet;
/**
* This class is responsible for handling the references in
@@ -258,12 +256,7 @@
* if we have an event cartridge, get a new value object
*/
- EventCartridge ec = context.getEventCartridge();
-
- if (ec != null)
- {
- value = ec.referenceInsert(literal(), value);
- }
+ value = EventHandlerUtil.referenceInsert(rsvc, context, literal(), value);
/*
* if value is null...
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java Sun Sep 11 15:24:20 2005
@@ -19,14 +19,12 @@
import java.io.IOException;
import java.io.Writer;
+import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.parser.Parser;
-import org.apache.velocity.exception.MethodInvocationException;
-
-import org.apache.velocity.app.event.EventCartridge;
-
/**
* Node for the #set directive
*
@@ -105,17 +103,8 @@
*/
if(blather)
{
- EventCartridge ec = context.getEventCartridge();
-
- boolean doit = true;
- /*
- * if we have an EventCartridge...
- */
- if (ec != null)
- {
- doit = ec.shouldLogOnNullSet( left.literal(), right.literal() );
- }
+ boolean doit = EventHandlerUtil.shouldLogOnNullSet( rsvc, context, left.literal(), right.literal() );
if (doit)
{
Added: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/BuiltInEventHandlerTest.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/BuiltInEventHandlerTest.java?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/BuiltInEventHandlerTest.java (added)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/BuiltInEventHandlerTest.java Sun Sep 11 15:24:20 2005
@@ -0,0 +1,329 @@
+package org.apache.velocity.test;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.app.event.implement.EscapeHtmlReference;
+import org.apache.velocity.app.event.implement.EscapeJavaScriptReference;
+import org.apache.velocity.app.event.implement.EscapeReference;
+import org.apache.velocity.app.event.implement.EscapeSqlReference;
+import org.apache.velocity.app.event.implement.EscapeXmlReference;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * Tests the operation of the built in event handlers.
+ *
+ * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
+ * @version $Id: EventCartridge.java,v 1.5 2004/03/19 17:13:33 dlr Exp $
+ */
+public class BuiltInEventHandlerTest extends BaseTestCase {
+
+
+ /**
+ * VTL file extension.
+ */
+ private static final String TMPL_FILE_EXT = "vm";
+
+ /**
+ * Comparison file extension.
+ */
+ private static final String CMP_FILE_EXT = "cmp";
+
+ /**
+ * Comparison file extension.
+ */
+ private static final String RESULT_FILE_EXT = "res";
+
+ /**
+ * Path for templates. This property will override the
+ * value in the default velocity properties file.
+ */
+ private final static String FILE_RESOURCE_LOADER_PATH = "../test/includeevent";
+
+ /**
+ * Results relative to the build directory.
+ */
+ private static final String RESULTS_DIR = "../test/includeevent/results";
+
+ /**
+ * Results relative to the build directory.
+ */
+ private static final String COMPARE_DIR = "../test/includeevent/compare";
+
+ /**
+ * Default constructor.
+ */
+ public BuiltInEventHandlerTest()
+ {
+ super("BuiltInEventHandlerTestCase");
+ }
+
+ public BuiltInEventHandlerTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(BuiltInEventHandlerTest.class);
+ }
+
+
+ /**
+ * Test escaping
+ * @throws Exception
+ */
+ public void testEscapeHtml() throws Exception
+ {
+ EscapeReference esc = new EscapeHtmlReference();
+ assertEquals("test string&another<b>bold</b>test",esc.referenceInsert("","test string&another<b>bold</b>test"));
+ assertEquals("<">",esc.referenceInsert("","<\">"));
+ assertEquals("test string",esc.referenceInsert("","test string"));
+ }
+
+ /**
+ * Test escaping
+ * @throws Exception
+ */
+ public void testEscapeXml() throws Exception
+ {
+ EscapeReference esc = new EscapeXmlReference();
+ assertEquals("test string&another<b>bold</b>test",esc.referenceInsert("","test string&another<b>bold</b>test"));
+ assertEquals("<">",esc.referenceInsert("","<\">"));
+ assertEquals("'",esc.referenceInsert("","'"));
+ assertEquals("test string",esc.referenceInsert("","test string"));
+ }
+
+ /**
+ * Test escaping
+ * @throws Exception
+ */
+ public void testEscapeSql() throws Exception
+ {
+ EscapeReference esc = new EscapeSqlReference();
+ assertEquals("Jimmy''s Pizza",esc.referenceInsert("","Jimmy's Pizza"));
+ assertEquals("test string",esc.referenceInsert("","test string"));
+ }
+
+ /**
+ * Test escaping
+ * @throws Exception
+ */
+ public void testEscapeJavaScript() throws Exception
+ {
+ EscapeReference esc = new EscapeJavaScriptReference();
+ assertEquals("Jimmy\\'s Pizza",esc.referenceInsert("","Jimmy's Pizza"));
+ assertEquals("test string",esc.referenceInsert("","test string"));
+ }
+
+ /**
+ * test that escape reference handler works with no match restrictions
+ * @throws Exception
+ */
+ public void testEscapeReferenceMatchAll() throws Exception
+ {
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, "org.apache.velocity.app.event.implement.EscapeHtmlReference");
+ ve.init();
+
+ Context context;
+ Writer writer;
+
+ // test normal reference
+ context = new VelocityContext();
+ writer = new StringWriter();
+ context.put("bold","<b>");
+ ve.evaluate(context,writer,"test","$bold test & test");
+ assertEquals("<b> test & test",writer.toString());
+
+ // test method reference
+ context = new VelocityContext();
+ writer = new StringWriter();
+ context.put("bold","<b>");
+ ve.evaluate(context,writer,"test","$bold.substring(0,1)");
+ assertEquals("<",writer.toString());
+ }
+
+ /**
+ * test that escape reference handler works with match restrictions
+ * @throws Exception
+ */
+ public void testEscapeReferenceMatch() throws Exception
+ {
+ // set up HTML match on everything, JavaScript match on _js*
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, "org.apache.velocity.app.event.implement.EscapeHtmlReference,org.apache.velocity.app.event.implement.EscapeJavaScriptReference");
+ ve.setProperty("eventhandler.escape.javascript.match", "/.*_js*/");
+ ve.init();
+
+ Writer writer;
+
+ // Html no JavaScript
+ writer = new StringWriter();
+ ve.evaluate(newEscapeContext(),writer,"test","$test1");
+ assertEquals("Jimmy's <b>pizza</b>",writer.toString());
+
+ // JavaScript and HTML
+ writer = new StringWriter();
+ ve.evaluate(newEscapeContext(),writer,"test","$test1_js");
+ assertEquals("Jimmy\\'s <b>pizza</b>",writer.toString());
+
+ // JavaScript and HTML
+ writer = new StringWriter();
+ ve.evaluate(newEscapeContext(),writer,"test","$test1_js_test");
+ assertEquals("Jimmy\\'s <b>pizza</b>",writer.toString());
+
+ // JavaScript and HTML (method call)
+ writer = new StringWriter();
+ ve.evaluate(newEscapeContext(),writer,"test","$test1_js.substring(0,7)");
+ assertEquals("Jimmy\\'s",writer.toString());
+ }
+
+ private Context newEscapeContext()
+ {
+ Context context = new VelocityContext();
+ context.put("test1","Jimmy's <b>pizza</b>");
+ context.put("test1_js","Jimmy's <b>pizza</b>");
+ context.put("test1_js_test","Jimmy's <b>pizza</b>");
+ return context;
+ }
+
+ public void testPrintExceptionHandler() throws Exception
+ {
+ VelocityEngine ve1 = new VelocityEngine();
+ ve1.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, "org.apache.velocity.app.event.implement.PrintExceptions");
+ ve1.init();
+
+ VelocityEngine ve2 = new VelocityEngine();
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, "org.apache.velocity.app.event.implement.PrintExceptions");
+ ve2.setProperty("eventhandler.methodexception.message","true");
+ ve2.init();
+
+ VelocityEngine ve3 = new VelocityEngine();
+ ve3.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, "org.apache.velocity.app.event.implement.PrintExceptions");
+ ve3.setProperty("eventhandler.methodexception.stacktrace","true");
+ ve3.init();
+
+ Context context;
+ StringWriter writer;
+
+ context = new VelocityContext();
+ context.put("list",new ArrayList());
+
+ try {
+ // exception only
+ writer = new StringWriter();
+ ve1.evaluate(context,writer,"test","$list.get(0)");
+ assertTrue(writer.toString().indexOf("IndexOutOfBoundsException") != -1);
+ assertTrue(writer.toString().indexOf("Index: 0, Size: 0") == -1);
+ assertTrue(writer.toString().indexOf("ArrayList") == -1);
+
+ // message
+ writer = new StringWriter();
+ ve2.evaluate(context,writer,"test","$list.get(0)");
+ assertTrue(writer.toString().indexOf("IndexOutOfBoundsException") != -1);
+ assertTrue(writer.toString().indexOf("Index: 0, Size: 0") != -1);
+ assertTrue(writer.toString().indexOf("ArrayList") == -1);
+
+ // stack trace
+ writer = new StringWriter();
+ ve3.evaluate(context,writer,"test","$list.get(0)");
+ assertTrue(writer.toString().indexOf("IndexOutOfBoundsException") != -1);
+ assertTrue(writer.toString().indexOf("ArrayList") != -1);
+
+
+ } catch (Exception E)
+ {
+ fail("Shouldn't have thrown exception. " + E);
+ }
+ }
+
+ public void testIncludeNotFound() throws Exception
+ {
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, "org.apache.velocity.app.event.implement.IncludeNotFound");
+ ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ ve.init();
+
+ Template template;
+ FileOutputStream fos;
+ Writer fwriter;
+ Context context;
+
+ template = ve.getTemplate( getFileName(null, "test6", TMPL_FILE_EXT) );
+
+ fos = new FileOutputStream (
+ getFileName(RESULTS_DIR, "test6", RESULT_FILE_EXT));
+
+ fwriter = new BufferedWriter( new OutputStreamWriter(fos) );
+
+ context = new VelocityContext();
+ template.merge(context, fwriter);
+ fwriter.flush();
+ fwriter.close();
+
+ if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test6", RESULT_FILE_EXT, CMP_FILE_EXT))
+ {
+ fail("Output incorrect.");
+ }
+ }
+
+ public void testIncludeRelativePath() throws Exception
+ {
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, "org.apache.velocity.app.event.implement.IncludeRelativePath");
+ ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ ve.init();
+
+ Template template;
+ FileOutputStream fos;
+ Writer fwriter;
+ Context context;
+
+ template = ve.getTemplate( getFileName(null, "subdir/test2", TMPL_FILE_EXT) );
+
+ fos = new FileOutputStream (
+ getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT));
+
+ fwriter = new BufferedWriter( new OutputStreamWriter(fos) );
+
+ context = new VelocityContext();
+ template.merge(context, fwriter);
+ fwriter.flush();
+ fwriter.close();
+
+ if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test2", RESULT_FILE_EXT, CMP_FILE_EXT))
+ {
+ fail("Output incorrect.");
+ }
+ }
+
+
+}
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/EventHandlingTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/EventHandlingTestCase.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/EventHandlingTestCase.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/EventHandlingTestCase.java Sun Sep 11 15:24:20 2005
@@ -20,59 +20,63 @@
import junit.framework.TestCase;
-import org.apache.velocity.app.Velocity;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.runtime.log.LogSystem;
-
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.MethodInvocationException;
-
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.app.event.ContextAware;
import org.apache.velocity.app.event.EventCartridge;
-import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
import org.apache.velocity.app.event.MethodExceptionEventHandler;
import org.apache.velocity.app.event.NullSetEventHandler;
-
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.app.event.RuntimeServicesAware;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.log.LogSystem;
/**
- * Tests event handling
+ * Tests event handling for all event handlers except IncludeEventHandler. This is tested
+ * separately due to its complexity.
*
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
* @version $Id$
*/
-public class EventHandlingTestCase extends TestCase implements ReferenceInsertionEventHandler,
+public class EventHandlingTestCase extends TestCase implements ReferenceInsertionEventHandler,
NullSetEventHandler, MethodExceptionEventHandler,
- LogSystem
+ LogSystem,RuntimeServicesAware,ContextAware
{
-
+
private String logString = null;
- private boolean exceptionSwitch = true;
private static String NO_REFERENCE_VALUE = "<no reference value>";
private static String REFERENCE_VALUE = "<reference value>";
+ private RuntimeServices rs = null;
+
/**
* Default constructor.
*/
public EventHandlingTestCase()
{
super("EventHandlingTestCase");
+ }
- try
- {
- /*
- * use an alternative logger. Set it up here and pass it in.
- */
-
- Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
- Velocity.init();
- }
- catch (Exception e)
- {
- System.err.println("Cannot setup event handling test : " + e);
- System.exit(1);
- }
+ /**
+ * Required by EventHandler
+ */
+ public void setRuntimeServices( RuntimeServices rs )
+ {
+ // make sure this is only called once
+ if (this.rs == null)
+ this.rs = rs;
+
+ else
+ fail("initialize called more than once.");
}
+ /**
+ * Required by LogSystem
+ */
public void init( RuntimeServices rs )
{
/* don't need it...*/
@@ -83,20 +87,25 @@
return new EventHandlingTestCase();
}
- /**
- * Runs the test.
- */
- public void runTest ()
+ public void runTest() throws Exception
{
- /*
+ /**
+ * Test attaching the event cartridge to the context
+ */
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this);
+ ve.init();
+
+
+ /*
* lets make a Context and add the event cartridge
*/
-
+
VelocityContext inner = new VelocityContext();
/*
- * Now make an event cartridge, register all the
+ * Now make an event cartridge, register all the
* event handlers (at once) and attach it to the
* Context
*/
@@ -104,7 +113,7 @@
EventCartridge ec = new EventCartridge();
ec.addEventHandler(this);
ec.attachToContext( inner );
-
+
/*
* now wrap the event cartridge - we want to make sure that
* we can do this w/o harm
@@ -112,7 +121,39 @@
VelocityContext context = new VelocityContext( inner );
- context.put("name", "Velocity");
+ testEventHandlers( ve, context, "a" );
+
+
+
+ /**
+ * Test assigning the event handlers via properties
+ */
+ VelocityEngine ve2 = new VelocityEngine();
+ ve2.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this);
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, this.getClass().getName());
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET, this.getClass().getName());
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, this.getClass().getName());
+
+ ve2.init();
+
+ VelocityContext context2 = new VelocityContext();
+
+ testEventHandlers( ve2, context2, "b" );
+
+
+ }
+
+
+
+ /**
+ * Test all the event handlers using the given engine.
+ * @param ve
+ * @param vcontext
+ */
+ private void testEventHandlers(VelocityEngine ve, Context vcontext,String testcode)
+ {
+
+ vcontext.put("name", "Velocity");
try
{
@@ -121,24 +162,24 @@
*/
String s = "$name";
-
+
StringWriter w = new StringWriter();
- Velocity.evaluate( context, w, "mystring", s );
-
+ ve.evaluate( vcontext, w, "mystring", s );
+
if ( !w.toString().equals( REFERENCE_VALUE ))
{
- fail( "Reference insertion test 1");
+ fail( "Reference insertion test 1" + testcode);
}
/*
- * using the same handler, we can deal with
+ * using the same handler, we can deal with
* null references as well
*/
s = "$floobie";
w = new StringWriter();
- Velocity.evaluate( context, w, "mystring", s );
+ ve.evaluate( vcontext, w, "mystring", s );
if ( !w.toString().equals( NO_REFERENCE_VALUE ))
{
@@ -149,17 +190,17 @@
* now lets test setting a null value - this test
* should result in *no* log output.
*/
-
+
s = "#set($settest = $NotAReference)";
w = new StringWriter();
logString = null;
- Velocity.evaluate( context, w, "mystring", s );
-
+ ve.evaluate( vcontext, w, "mystring", s );
+
if( logString != null)
{
- fail( "NullSetEventHandler test 1");
+ fail( "NullSetEventHandler test 1" + testcode);
}
-
+
/*
* now lets test setting a null value - this test
* should result in log output.
@@ -167,60 +208,60 @@
s = "#set($logthis = $NotAReference)";
w = new StringWriter();
- logString = null;
- Velocity.evaluate( context, w, "mystring", s );
-
+ logString = null;
+ ve.evaluate( vcontext, w, "mystring", s );
+
if( logString == null)
{
- fail( "NullSetEventHandler test 1");
+ fail( "NullSetEventHandler test 2" + testcode);
}
/*
- * finally, we test a method exception event - we do this
- * by putting this class in the context, and calling
+ * finally, we test a method exception event - we do this
+ * by putting this class in the context, and calling
* a method that does nothing but throw an exception.
- * we use a little switch to turn the event handling
+ * we use flag in the context to turn the event handling
* on and off
*
* Note also how the reference insertion process
* happens as well
*/
-
- exceptionSwitch = true;
- context.put("this", this );
+ vcontext.put("allow_exception",Boolean.TRUE);
+
+ vcontext.put("this", this );
s = " $this.throwException()";
w = new StringWriter();
-
+
try
{
- Velocity.evaluate( context, w, "mystring", s );
+ ve.evaluate( vcontext, w, "mystring", s );
}
catch( MethodInvocationException mee )
{
- fail("MethodExceptionEvent test 1");
+ fail("MethodExceptionEvent test 1" + testcode);
}
catch( Exception e )
{
- fail("MethodExceptionEvent test 1");
+ fail("MethodExceptionEvent test 1" + testcode);
}
/*
- * now, we turn the switch off, and we can see that the
- * exception will propgate all the way up here, and
+ * now, we remove the exception flag, and we can see that the
+ * exception will propgate all the way up here, and
* wil be caught by the catch() block below
*/
- exceptionSwitch = false;
+ vcontext.remove("allow_exception");
s = " $this.throwException()";
w = new StringWriter();
try
{
- Velocity.evaluate( context, w, "mystring", s );
- fail("MethodExceptionEvent test 2");
+ ve.evaluate( vcontext, w, "mystring", s );
+ fail("MethodExceptionEvent test 2" + testcode);
}
catch( MethodInvocationException mee )
{
@@ -230,7 +271,7 @@
}
catch( Exception e )
{
- fail("MethodExceptionEvent test 2");
+ fail("MethodExceptionEvent test 2" + testcode);
}
}
catch( ParseErrorException pee )
@@ -262,11 +303,15 @@
*/
public Object referenceInsert( String reference, Object value )
{
+ // as a test, make sure this EventHandler is initialized
+ if (rs == null)
+ fail ("Event handler not initialized!");
+
+
/*
* if we have a value
* return a known value
*/
-
String s = null;
if( value != null )
@@ -289,15 +334,19 @@
/**
* Event handler for when the right hand side of
- * a #set() directive is null, which results in
+ * a #set() directive is null, which results in
* a log message. This method gives the application
* a chance to 'vote' on msg generation
*/
public boolean shouldLogOnNullSet( String lhs, String rhs )
{
+ // as a test, make sure this EventHandler is initialized
+ if (rs == null)
+ fail ("Event handler not initialized!");
+
if (lhs.equals("$settest"))
return false;
-
+
return true;
}
@@ -307,17 +356,34 @@
public Object methodException( Class claz, String method, Exception e )
throws Exception
{
- /*
- * only do processing if the switch is on
- */
+ // as a test, make sure this EventHandler is initialized
+ if (rs == null)
+ fail ("Event handler not initialized!");
- if( exceptionSwitch && method.equals("throwException"))
+ // only do processing if the switch is on
+ if (context != null)
{
- return "handler";
- }
+ boolean exceptionSwitch = context.containsKey("allow_exception");
- throw e;
- }
+ if( exceptionSwitch && method.equals("throwException"))
+ {
+ return "handler";
+ }
+ else
+ throw e;
+
+ } else
+
+ throw e;
+ }
+
+ Context context;
+
+
+ public void setContext(Context context)
+ {
+ this.context = context;
+ }
/**
* handler for LogSystem interface
Added: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/FilteredEventHandlingTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/FilteredEventHandlingTestCase.java?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/FilteredEventHandlingTestCase.java (added)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/FilteredEventHandlingTestCase.java Sun Sep 11 15:24:20 2005
@@ -0,0 +1,261 @@
+package org.apache.velocity.test;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.log.LogSystem;
+
+/**
+ * Tests event handling for all event handlers when multiple event handlers are
+ * assigned for each type.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: EventHandlingTestCase.java,v 1.7 2004/03/19 17:13:38 dlr Exp $
+ */
+public class FilteredEventHandlingTestCase extends BaseTestCase implements LogSystem
+{
+
+ /**
+ * VTL file extension.
+ */
+ private static final String TMPL_FILE_EXT = "vm";
+
+ /**
+ * Comparison file extension.
+ */
+ private static final String CMP_FILE_EXT = "cmp";
+
+ /**
+ * Comparison file extension.
+ */
+ private static final String RESULT_FILE_EXT = "res";
+
+ /**
+ * Path for templates. This property will override the
+ * value in the default velocity properties file.
+ */
+ private final static String FILE_RESOURCE_LOADER_PATH = "../test/includeevent";
+
+ /**
+ * Results relative to the build directory.
+ */
+ private static final String RESULTS_DIR = "../test/includeevent/results";
+
+ /**
+ * Results relative to the build directory.
+ */
+ private static final String COMPARE_DIR = "../test/includeevent/compare";
+
+
+ private String logString = null;
+
+ /**
+ * Default constructor.
+ */
+ public FilteredEventHandlingTestCase()
+ {
+ super("FilteredEventHandlingTestCase");
+ }
+
+
+ /**
+ * Required by LogSystem
+ */
+ public void init( RuntimeServices rs )
+ {
+ /* don't need it...*/
+ }
+
+ public static junit.framework.Test suite ()
+ {
+ return new FilteredEventHandlingTestCase();
+ }
+
+ public void runTest() throws Exception
+ {
+ String handler1 = "org.apache.velocity.test.eventhandler.Handler1";
+ String handler2 = "org.apache.velocity.test.eventhandler.Handler2";
+ String sequence1 = handler1 + "," + handler2;
+ String sequence2 = handler2 + "," + handler1;
+
+ assureResultsDirectoryExists(RESULTS_DIR);
+
+ /**
+ * Set up two VelocityEngines that will apply the handlers in both orders
+ */
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this);
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, sequence1);
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET, sequence1);
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, sequence1);
+ ve.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, sequence1);
+ ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ ve.init();
+
+ VelocityEngine ve2 = new VelocityEngine();
+ ve2.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this);
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, sequence2);
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET, sequence2);
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, sequence2);
+ ve2.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, sequence2);
+ ve2.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ ve2.init();
+
+ VelocityContext context;
+ StringWriter w;
+
+
+ // check reference insertion with both sequences
+ context = new VelocityContext();
+ w = new StringWriter();
+ context.put("test","abc");
+ ve.evaluate( context, w, "test", "$test" );
+ if ( !w.toString().equals( "ABCABC" ))
+ {
+ fail( "Reference insertion test 1");
+ }
+
+ context = new VelocityContext();
+ w = new StringWriter();
+ context.put("test","abc");
+ ve2.evaluate( context, w, "test", "$test" );
+ if ( !w.toString().equals( "ABCabc" ))
+ {
+ fail( "Reference insertion test 2");
+ }
+
+ // check method exception with both sequences
+
+ // sequence 1
+ context = new VelocityContext();
+ w = new StringWriter();
+ context.put("test",new ArrayList());
+ try {
+ ve.evaluate( context, w, "test", "$test.get(0)");
+ fail ( "Method exception event test 1" );
+ } catch( MethodInvocationException mee )
+ {
+ // correct if exception is raised
+ }
+ catch( Exception e )
+ {
+ fail ( "Method exception event test 1" );
+ }
+
+ // sequence2
+ context = new VelocityContext();
+ w = new StringWriter();
+ context.put("test",new ArrayList());
+ try {
+ ve2.evaluate( context, w, "test", "$test.get(0)");
+ }
+ catch( Exception e )
+ {
+ fail ( "Method exception event test 2" );
+ }
+
+
+ // check log on null set with both sequences
+ // sequence 1
+ context = new VelocityContext();
+ w = new StringWriter();
+ logString = null;
+ ve.evaluate( context, w, "test", "#set($test1 = $test2)" );
+ if ( logString != null)
+ {
+ fail( "log null set test 1");
+ }
+
+ // sequence 2
+ context = new VelocityContext();
+ w = new StringWriter();
+ logString = null;
+ ve2.evaluate( context, w, "test", "#set($test1 = $test2)" );
+ if ( logString != null)
+ {
+ fail( "log null set test 2");
+ }
+
+
+ // check include event handler with both sequences
+
+ // sequence 1
+ Template template;
+ FileOutputStream fos;
+ Writer fwriter;
+
+ template = ve.getTemplate( getFileName(null, "test4", TMPL_FILE_EXT) );
+
+ fos = new FileOutputStream (
+ getFileName(RESULTS_DIR, "test4", RESULT_FILE_EXT));
+
+ fwriter = new BufferedWriter( new OutputStreamWriter(fos) );
+
+ context = new VelocityContext();
+ template.merge(context, fwriter);
+ fwriter.flush();
+ fwriter.close();
+
+ if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test4", RESULT_FILE_EXT, CMP_FILE_EXT))
+ {
+ fail("Output incorrect.");
+ }
+
+ // sequence 2
+ template = ve2.getTemplate( getFileName(null, "test5", TMPL_FILE_EXT) );
+
+ fos = new FileOutputStream (
+ getFileName(RESULTS_DIR, "test5", RESULT_FILE_EXT));
+
+ fwriter = new BufferedWriter( new OutputStreamWriter(fos) );
+
+ context = new VelocityContext();
+ template.merge(context, fwriter);
+ fwriter.flush();
+ fwriter.close();
+
+ if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test5", RESULT_FILE_EXT, CMP_FILE_EXT))
+ {
+ fail("Output incorrect.");
+ }
+
+ }
+
+
+
+
+ /**
+ * handler for LogSystem interface
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ logString = message;
+ }
+
+}
Added: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/IncludeEventHandlingTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/IncludeEventHandlingTestCase.java?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/IncludeEventHandlingTestCase.java (added)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/IncludeEventHandlingTestCase.java Sun Sep 11 15:24:20 2005
@@ -0,0 +1,262 @@
+package org.apache.velocity.test;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.app.event.IncludeEventHandler;
+import org.apache.velocity.app.event.RuntimeServicesAware;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeSingleton;
+
+/**
+ * Tests event handling
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: EventHandlingTestCase.java,v 1.5 2001/08/07 22:20:28 geirm Exp $
+ */
+public class IncludeEventHandlingTestCase extends BaseTestCase implements IncludeEventHandler,RuntimeServicesAware
+{
+
+ /**
+ * VTL file extension.
+ */
+ private static final String TMPL_FILE_EXT = "vm";
+
+ /**
+ * Comparison file extension.
+ */
+ private static final String CMP_FILE_EXT = "cmp";
+
+ /**
+ * Comparison file extension.
+ */
+ private static final String RESULT_FILE_EXT = "res";
+
+ /**
+ * Path for templates. This property will override the
+ * value in the default velocity properties file.
+ */
+ private final static String FILE_RESOURCE_LOADER_PATH = "../test/includeevent";
+
+ /**
+ * Results relative to the build directory.
+ */
+ private static final String RESULTS_DIR = "../test/includeevent/results";
+
+ /**
+ * Results relative to the build directory.
+ */
+ private static final String COMPARE_DIR = "../test/includeevent/compare";
+
+
+ private static final int PASS_THROUGH=0;
+ private static final int RELATIVE_PATH=1;
+ private static final int BLOCK=2;
+
+ private int EventHandlerBehavior = PASS_THROUGH;
+
+ private RuntimeServices rs;
+
+
+ /**
+ * Default constructor.
+ */
+ public IncludeEventHandlingTestCase()
+ {
+ super("EventHandlingTestCase");
+
+ try
+ {
+ assureResultsDirectoryExists(RESULTS_DIR);
+
+ Velocity.addProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+
+ Velocity.init();
+
+
+ }
+ catch (Exception e)
+ {
+ System.err.println("Cannot setup include event handling test : " + e);
+ System.exit(1);
+ }
+ }
+
+
+ public static junit.framework.Test suite ()
+ {
+ return new IncludeEventHandlingTestCase();
+ }
+
+ /**
+ * Runs the test.
+ */
+ public void runTest ()
+ {
+ try
+ {
+ Template template1 = RuntimeSingleton.getTemplate(
+ getFileName(null, "test1", TMPL_FILE_EXT));
+
+ Template template2 = RuntimeSingleton.getTemplate(
+ getFileName(null, "subdir/test2", TMPL_FILE_EXT));
+
+ Template template3 = RuntimeSingleton.getTemplate(
+ getFileName(null, "test3", TMPL_FILE_EXT));
+
+ FileOutputStream fos1 =
+ new FileOutputStream (
+ getFileName(RESULTS_DIR, "test1", RESULT_FILE_EXT));
+
+ FileOutputStream fos2 =
+ new FileOutputStream (
+ getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT));
+
+ FileOutputStream fos3 =
+ new FileOutputStream (
+ getFileName(RESULTS_DIR, "test3", RESULT_FILE_EXT));
+
+ Writer writer1 = new BufferedWriter(new OutputStreamWriter(fos1));
+ Writer writer2 = new BufferedWriter(new OutputStreamWriter(fos2));
+ Writer writer3 = new BufferedWriter(new OutputStreamWriter(fos3));
+
+ /*
+ * lets make a Context and add the event cartridge
+ */
+
+ Context context = new VelocityContext();
+
+ /*
+ * Now make an event cartridge, register the
+ * input event handler and attach it to the
+ * Context
+ */
+
+ EventCartridge ec = new EventCartridge();
+ ec.addEventHandler(this);
+ ec.attachToContext( context );
+
+
+ // BEHAVIOR A: pass through #input and #parse with no change
+ EventHandlerBehavior = PASS_THROUGH;
+
+ template1.merge(context, writer1);
+ writer1.flush();
+ writer1.close();
+
+ // BEHAVIOR B: pass through #input and #parse with using a relative path
+ EventHandlerBehavior = RELATIVE_PATH;
+
+ template2.merge(context, writer2);
+ writer2.flush();
+ writer2.close();
+
+ // BEHAVIOR C: refuse to pass through #input and #parse
+ EventHandlerBehavior = BLOCK;
+
+ template3.merge(context, writer3);
+ writer3.flush();
+ writer3.close();
+
+ if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test1",
+ RESULT_FILE_EXT, CMP_FILE_EXT) ||
+ !isMatch(RESULTS_DIR, COMPARE_DIR, "test2",
+ RESULT_FILE_EXT, CMP_FILE_EXT) ||
+ !isMatch(RESULTS_DIR, COMPARE_DIR, "test3",
+ RESULT_FILE_EXT, CMP_FILE_EXT)
+ )
+ {
+ fail("Output incorrect.");
+ }
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+
+ public void setRuntimeServices( RuntimeServices rs )
+ {
+ this.rs = rs;
+ }
+
+ /**
+ * Sample handler with different behaviors for the different tests.
+ */
+ public String includeEvent( String includeResourcePath, String currentResourcePath, String directiveName)
+ {
+ if (EventHandlerBehavior == PASS_THROUGH)
+ return includeResourcePath;
+
+
+ // treat as relative path
+ else if (EventHandlerBehavior == RELATIVE_PATH)
+ {
+
+ // strip the starting slash from includeResourcePath, if it exists
+ if (includeResourcePath.startsWith("/") || includeResourcePath.startsWith("\\") )
+ includeResourcePath = includeResourcePath.substring(1);
+
+ int slashpos1 = currentResourcePath.lastIndexOf("/");
+ int slashpos2 = currentResourcePath.lastIndexOf("\\");
+ int lastslashpos = -1;
+ if ( (slashpos1 != -1) && (slashpos2 != -1) && (slashpos1 <= slashpos2) )
+ lastslashpos = slashpos2;
+
+ else if ( (slashpos1 != -1) && (slashpos2 != -1) && (slashpos1 > slashpos2) )
+ lastslashpos = slashpos1;
+
+ else if ( (slashpos1 != -1) && (slashpos2 == -1) )
+ lastslashpos = slashpos1;
+
+ else if ( (slashpos1 == -1) && (slashpos2 != -1) )
+ lastslashpos = slashpos2;
+
+ // root of resource tree
+ if ( (lastslashpos == -1) || (lastslashpos == 0) )
+ return includeResourcePath;
+
+ // prepend path to the input path
+ else
+ return currentResourcePath.substring(0,lastslashpos) + "/" + includeResourcePath;
+
+
+
+ } else if (EventHandlerBehavior == BLOCK)
+ return null;
+
+ // should never happen
+ else
+ return null;
+
+
+ }
+
+
+}
Added: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler1.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler1.java?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler1.java (added)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler1.java Sun Sep 11 15:24:20 2005
@@ -0,0 +1,77 @@
+package org.apache.velocity.test.eventhandler;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import org.apache.velocity.app.event.IncludeEventHandler;
+import org.apache.velocity.app.event.MethodExceptionEventHandler;
+import org.apache.velocity.app.event.NullSetEventHandler;
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * This is a test set of event handlers, used to test event handler sequences.
+ *
+ * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
+ * @version $Id: $
+ */
+public class Handler1
+ implements NullSetEventHandler, ReferenceInsertionEventHandler, MethodExceptionEventHandler, IncludeEventHandler {
+
+ private RuntimeServices rs;
+
+ /**
+ * never log
+ */
+ public boolean shouldLogOnNullSet(String lhs, String rhs)
+ {
+ return false;
+ }
+
+ /**
+ * display output twice, once uppercase and once lowercase
+ */
+ public Object referenceInsert(String reference, Object value)
+ {
+ if (value == null)
+ return null;
+ else
+ return value.toString().toUpperCase() + value.toString().toLowerCase();
+ }
+
+ /**
+ * throw the exception
+ */
+ public Object methodException(Class claz, String method, Exception e) throws Exception
+ {
+ throw e;
+ }
+
+ /*
+ * redirect all requests to a page "login.vm" (simulates access control).
+ */
+ public String includeEvent(
+ String includeResourcePath,
+ String currentResourcePath,
+ String directiveName)
+ {
+
+ return "notfound.vm";
+
+ }
+
+}
\ No newline at end of file
Added: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler2.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler2.java?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler2.java (added)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/eventhandler/Handler2.java Sun Sep 11 15:24:20 2005
@@ -0,0 +1,74 @@
+package org.apache.velocity.test.eventhandler;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import org.apache.velocity.app.event.IncludeEventHandler;
+import org.apache.velocity.app.event.MethodExceptionEventHandler;
+import org.apache.velocity.app.event.NullSetEventHandler;
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+
+/**
+ * This is a test set of event handlers, used to test event handler sequences.
+ *
+ * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
+ * @version $Id: $
+ */
+public class Handler2
+ implements NullSetEventHandler, ReferenceInsertionEventHandler, MethodExceptionEventHandler, IncludeEventHandler {
+
+ /**
+ * always log
+ */
+ public boolean shouldLogOnNullSet(String lhs, String rhs)
+ {
+ return true;
+ }
+
+ /**
+ * convert output to upper case
+ */
+ public Object referenceInsert(String reference, Object value)
+ {
+ if (value == null)
+ return null;
+ else
+ return value.toString().toUpperCase();
+ }
+
+ /**
+ * print the exception
+ */
+ public Object methodException(Class claz, String method, Exception e) throws Exception
+ {
+ return "Exception: " + e;
+ }
+
+ /*
+ * redirect all requests to a new directory "subdir" (simulates localization).
+ */
+ public String includeEvent(
+ String includeResourcePath,
+ String currentResourcePath,
+ String directiveName)
+ {
+
+ return "subdir/" + includeResourcePath;
+
+ }
+
+}
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/misc/Test.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/misc/Test.java?rev=280189&r1=280188&r2=280189&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/misc/Test.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/test/misc/Test.java Sun Sep 11 15:24:20 2005
@@ -20,37 +20,31 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStreamWriter;
-import java.io.Writer;
import java.io.StringWriter;
-
+import java.io.Writer;
import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Properties;
import java.util.Stack;
import java.util.Vector;
-import java.util.Enumeration;
-import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
-
+import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.FieldMethodizer;
import org.apache.velocity.app.Velocity;
-
+import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.app.event.MethodExceptionEventHandler;
+import org.apache.velocity.app.event.NullSetEventHandler;
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.velocity.exception.MethodInvocationException;
-
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.RuntimeSingleton;
import org.apache.velocity.test.provider.TestProvider;
-import org.apache.velocity.app.event.EventCartridge;
-import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
-import org.apache.velocity.app.event.MethodExceptionEventHandler;
-import org.apache.velocity.app.event.NullSetEventHandler;
-
-import org.apache.velocity.context.Context;
-
/**
* This class the testbed for Velocity. It is used to
@@ -68,6 +62,7 @@
* Cache of writers
*/
private static Stack writerStack = new Stack();
+ private RuntimeServices rs;
public Test(String templateFile, String encoding)
{
@@ -268,6 +263,12 @@
}
}
+
+ public void initialize( RuntimeServices rs )
+ {
+ this.rs = rs;
+ }
+
public Object referenceInsert( String reference, Object value )
{
Added: jakarta/velocity/core/trunk/test/includeevent/compare/test1.cmp
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/compare/test1.cmp?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/compare/test1.cmp (added)
+++ jakarta/velocity/core/trunk/test/includeevent/compare/test1.cmp Sun Sep 11 15:24:20 2005
@@ -0,0 +1,3 @@
+Test File 1
+include file a
+parse file a
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/compare/test2.cmp
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/compare/test2.cmp?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/compare/test2.cmp (added)
+++ jakarta/velocity/core/trunk/test/includeevent/compare/test2.cmp Sun Sep 11 15:24:20 2005
@@ -0,0 +1,3 @@
+Test File 2
+Good include file b
+Good parse file b
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/compare/test3.cmp
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/compare/test3.cmp?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/compare/test3.cmp (added)
+++ jakarta/velocity/core/trunk/test/includeevent/compare/test3.cmp Sun Sep 11 15:24:20 2005
@@ -0,0 +1,2 @@
+Test File 3
+
Added: jakarta/velocity/core/trunk/test/includeevent/compare/test4.cmp
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/compare/test4.cmp?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/compare/test4.cmp (added)
+++ jakarta/velocity/core/trunk/test/includeevent/compare/test4.cmp Sun Sep 11 15:24:20 2005
@@ -0,0 +1,2 @@
+Test File 4
+page not found (subdir)
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/compare/test5.cmp
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/compare/test5.cmp?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/compare/test5.cmp (added)
+++ jakarta/velocity/core/trunk/test/includeevent/compare/test5.cmp Sun Sep 11 15:24:20 2005
@@ -0,0 +1,2 @@
+Test File 5
+page not found
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/compare/test6.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/compare/test6.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/compare/test6.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/compare/test6.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+page not found
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/include-a.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/include-a.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/include-a.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/include-a.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+include file a
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/include-b.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/include-b.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/include-b.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/include-b.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+BAD include file b
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/include4.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/include4.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/include4.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/include4.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+should not be included
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/include5.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/include5.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/include5.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/include5.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+should not be included
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/notfound.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/notfound.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/notfound.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/notfound.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+page not found
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/parse-a.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/parse-a.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/parse-a.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/parse-a.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+parse file a
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/parse-b.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/parse-b.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/parse-b.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/parse-b.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+BAD parse file b
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/subdir/include-b.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/subdir/include-b.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/subdir/include-b.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/subdir/include-b.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+Good include file b
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/subdir/include4.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/subdir/include4.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/subdir/include4.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/subdir/include4.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+should not be included (subdir)
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/subdir/include5.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/subdir/include5.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/subdir/include5.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/subdir/include5.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+should not be included (subdir)
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/subdir/notfound.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/subdir/notfound.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/subdir/notfound.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/subdir/notfound.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+page not found (subdir)
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/subdir/parse-b.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/subdir/parse-b.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/subdir/parse-b.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/subdir/parse-b.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+Good parse file b
\ No newline at end of file
Added: jakarta/velocity/core/trunk/test/includeevent/subdir/test2.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/subdir/test2.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/subdir/test2.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/subdir/test2.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1,4 @@
+Test File 2
+#include("include-b.vm")
+
+#parse("parse-b.vm")
Added: jakarta/velocity/core/trunk/test/includeevent/test1.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/test1.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/test1.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/test1.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1,4 @@
+Test File 1
+#include("include-a.vm")
+
+#parse("parse-a.vm")
Added: jakarta/velocity/core/trunk/test/includeevent/test3.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/test3.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/test3.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/test3.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1,4 @@
+Test File 3
+#include("include-a.vm")
+
+#parse("parse-a.vm")
Added: jakarta/velocity/core/trunk/test/includeevent/test4.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/test4.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/test4.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/test4.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1,2 @@
+Test File 4
+#include("include4.vm")
Added: jakarta/velocity/core/trunk/test/includeevent/test5.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/test5.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/test5.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/test5.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1,2 @@
+Test File 5
+#include("include5.vm")
Added: jakarta/velocity/core/trunk/test/includeevent/test6.vm
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/test/includeevent/test6.vm?rev=280189&view=auto
==============================================================================
--- jakarta/velocity/core/trunk/test/includeevent/test6.vm (added)
+++ jakarta/velocity/core/trunk/test/includeevent/test6.vm Sun Sep 11 15:24:20 2005
@@ -0,0 +1 @@
+#include("badfile.vm")
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org