You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by ap...@apache.org on 2010/09/17 21:13:03 UTC
svn commit: r998264 [1/2] - in /velocity/sandbox/maven-reorg/engine/trunk:
./ src/changes/ velocity-engine-commons-logging/src/main/java/
velocity-engine-commons-logging/src/main/java/org/apache/velocity/runtime/log/
velocity-engine-commons-logging/src...
Author: apetrelli
Date: Fri Sep 17 19:13:02 2010
New Revision: 998264
URL: http://svn.apache.org/viewvc?rev=998264&view=rev
Log:
Merged from 2.0 branch to sandbox, from 1st September 2010.
Removed:
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExceptionUtils.java
Modified:
velocity/sandbox/maven-reorg/engine/trunk/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/src/changes/changes.xml
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/test/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerUtil.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/AvalonLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/HoldingLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/NullLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/SystemLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BlockMacroTestCase.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EventHandlingTestCase.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ScopeTestCase.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/WrappedExceptionTestCase.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler2.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-log4j/src/main/java/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-log4j/src/main/java/org/apache/velocity/runtime/log/Log4JLogChute.java
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-servlet/src/main/java/ (props changed)
velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-servlet/src/main/java/org/apache/velocity/runtime/log/ServletLogChute.java
Propchange: velocity/sandbox/maven-reorg/engine/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 17 19:13:02 2010
@@ -1 +1,2 @@
-/velocity/engine/branches/2.0_Exp:958513
+/velocity/engine/branches/2.0_Exp:958513,991637-995742
+/velocity/engine/trunk:992133
Modified: velocity/sandbox/maven-reorg/engine/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/src/changes/changes.xml?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/src/changes/changes.xml (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/src/changes/changes.xml Fri Sep 17 19:13:02 2010
@@ -26,6 +26,10 @@
<body>
<release version="2.0" date="In Subversion">
+ <action type="fix" dev="nbubna" issue="VELOCITY-751">
+ Removed all remaining "throws Exception" clauses and the now useless ExceptionUtils class.
+ </action>
+
<action type="add" dev="nbubna" issue="VELOCITY-731">
Remove directive.if.tostring.nullcheck crutch with intent
to replace testing of toString() null status with support for
@@ -69,6 +73,24 @@
</release>
<release version="1.7" date="In Subversion">
+ <action type="add" dev="nbubna">
+ Add access to template and directive debugging info via $<scope>.info.
+ </action>
+
+ <action type="fix" dev="nbubna" issue="VELOCITY-766">
+ LogManager now catches UnsupportedOperationExceptions during LogChute init.
+ </action>
+
+ <action type="fix" dev="nbubna" issue="VELOCITY-760" due-to="Jarkko Viinamäki">
+ Ensure that DataSourceResourceLoader closes PreparedStatements.
+ </action>
+
+ <action type="fix" dev="nbubna" issue="VELOCITY-753" due-to="Matt Ryall">
+ Mark optional dependencies as such in OSGi bundle manifest.
+ </action>
+ </release>
+
+ <release version="1.7-beta1" date="2010-04-10">
<action type="add" dev="nbubna" issue="VELOCITY-694">
Add support for OSGi-ready manifests in build/release tasks.
</action>
Propchange: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Sep 17 19:13:02 2010
@@ -0,0 +1,3 @@
+/velocity/engine/branches/2.0_Exp/src/java:991637-995742
+/velocity/engine/branches/2.0_Exp/velocity-engine-commons-logging/src/main/java:958513,991637-995742
+/velocity/engine/trunk/velocity-engine-commons-logging/src/main/java:992133
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/main/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java Fri Sep 17 19:13:02 2010
@@ -63,7 +63,7 @@ public class CommonsLogLogChute implemen
/********** LogChute methods *************/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
String name =
(String)rs.getProperty(LOGCHUTE_COMMONS_LOG_NAME);
Propchange: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-commons-logging/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Sep 17 19:13:02 2010
@@ -0,0 +1,3 @@
+/velocity/engine/branches/2.0_Exp/src/test:991639-992140
+/velocity/engine/branches/2.0_Exp/velocity-engine-commons-logging/src/test:958513,991637-995742
+/velocity/engine/trunk/velocity-engine-commons-logging/src/test:992133
Propchange: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 17 19:13:02 2010
@@ -1,2 +1,2 @@
-/velocity/engine/branches/2.0_Exp/src/java:958513
+/velocity/engine/branches/2.0_Exp/src/java:958513,991637-995742
/velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java:958513
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java Fri Sep 17 19:13:02 2010
@@ -265,10 +265,9 @@ public class EventCartridge
* is executed. Handlers will not be initialized more than once.
*
* @param rs
- * @throws Exception
* @since 1.5
*/
- public void initialize (RuntimeServices rs) throws Exception
+ public void initialize (RuntimeServices rs)
{
for ( Iterator i = referenceHandlers.iterator(); i.hasNext(); )
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java Fri Sep 17 19:13:02 2010
@@ -37,9 +37,8 @@ public interface EventHandlerMethodExecu
* If appropriate, the returned Object will be the return value.
*
* @param handler call the appropriate method on this handler
- * @exception Exception generic exception potentially thrown by event handlers
*/
- public void execute(EventHandler handler) throws Exception;
+ public void execute(EventHandler handler);
/**
* Called after execute() to see if iterating should stop. Should
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerUtil.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerUtil.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerUtil.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventHandlerUtil.java Fri Sep 17 19:13:02 2010
@@ -22,8 +22,8 @@ package org.apache.velocity.app.event;
import java.util.Iterator;
import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.util.ExceptionUtils;
import org.apache.velocity.util.introspection.Info;
@@ -106,7 +106,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Exception in event handler.",e);
+ throw new VelocityException("Exception in event handler.",e);
}
}
@@ -210,7 +210,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Exception in event handler.",e);
+ throw new VelocityException("Exception in event handler.",e);
}
}
@@ -323,7 +323,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Exception in event handler.",e);
+ throw new VelocityException("Exception in event handler.",e);
}
}
@@ -344,7 +344,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Couldn't initialize event cartridge : ", e);
+ throw new VelocityException("Couldn't initialize event cartridge : ", e);
}
}
}
@@ -356,13 +356,11 @@ public class EventHandlerUtil {
* @param applicationEventHandlerIterator Iterator that loops through all global event handlers declared at application level
* @param contextEventHandlerIterator Iterator that loops through all global event handlers attached to context
* @param eventExecutor Strategy object that executes event handler method
- * @exception Exception generic exception potentially thrown by event handlers
*/
private static void callEventHandlers(
Iterator applicationEventHandlerIterator,
Iterator contextEventHandlerIterator,
EventHandlerMethodExecutor eventExecutor)
- throws Exception
{
/**
* First loop through the event handlers configured at the app level
@@ -381,12 +379,10 @@ public class EventHandlerUtil {
*
* @param handlerIterator Iterator that loops through event handlers
* @param eventExecutor Strategy object that executes event handler method
- * @exception Exception generic exception potentially thrown by event handlers
*/
private static void iterateOverEventHandlers(
Iterator handlerIterator,
EventHandlerMethodExecutor eventExecutor)
- throws Exception
{
if (handlerIterator != null)
{
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java Fri Sep 17 19:13:02 2010
@@ -44,10 +44,9 @@ public interface MethodExceptionEventHan
* @param method the method
* @param e the thrown exception
* @return an object to insert in the page
- * @throws Exception an exception to be thrown instead inserting an object
+ * @throws RuntimeException an exception to be thrown instead inserting an object
*/
- public Object methodException( Class claz, String method, Exception e )
- throws Exception;
+ public Object methodException( Class claz, String method, Exception e );
/**
* Defines the execution strategy for methodException
@@ -81,7 +80,7 @@ public interface MethodExceptionEventHan
* @param handler call the appropriate method on this handler
* @exception Exception generic exception thrown by methodException event handler method call
*/
- public void execute(EventHandler handler) throws Exception
+ public void execute(EventHandler handler)
{
MethodExceptionEventHandler eh = (MethodExceptionEventHandler) handler;
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java Fri Sep 17 19:13:02 2010
@@ -55,9 +55,8 @@ public class PrintExceptions implements
* @param method the method
* @param e the thrown exception
* @return an object to insert in the page
- * @throws Exception an exception to be thrown instead inserting an object
*/
- public Object methodException(Class claz, String method, Exception e) throws Exception
+ public Object methodException(Class claz, String method, Exception e)
{
boolean showMessage = rs.getBoolean(SHOW_MESSAGE,false);
boolean showStackTrace = rs.getBoolean(SHOW_STACK_TRACE,false);
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java Fri Sep 17 19:13:02 2010
@@ -151,9 +151,9 @@ public class ParseErrorException extends
lineNumber = xpex.getLineNumber();
templateName = xpex.getTemplateName();
}
- else if (pex.getWrappedThrowable() instanceof ParseException)
+ else if (pex.getCause() instanceof ParseException)
{
- ParseException pex2 = (ParseException) pex.getWrappedThrowable();
+ ParseException pex2 = (ParseException) pex.getCause();
if (pex2.currentToken != null && pex2.currentToken.next != null)
{
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/VelocityException.java Fri Sep 17 19:13:02 2010
@@ -1,7 +1,5 @@
package org.apache.velocity.exception;
-import org.apache.velocity.util.ExceptionUtils;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,23 +26,19 @@ import org.apache.velocity.util.Exceptio
* @author <a href="mailto:kdowney@amberarcher.com">Kyle F. Downey</a>
* @version $Id$
*/
-public class VelocityException
- extends RuntimeException
+public class VelocityException extends RuntimeException
{
/**
* Version Id for serializable
*/
private static final long serialVersionUID = 1251243065134956045L;
- private final Throwable wrapped;
-
/**
* @param exceptionMessage The message to register.
*/
public VelocityException(final String exceptionMessage)
{
super(exceptionMessage);
- wrapped = null;
}
/**
@@ -54,9 +48,7 @@ public class VelocityException
*/
public VelocityException(final String exceptionMessage, final Throwable wrapped)
{
- super(exceptionMessage);
- this.wrapped = wrapped;
- ExceptionUtils.setCause(this, wrapped);
+ super(exceptionMessage, wrapped);
}
/**
@@ -65,9 +57,7 @@ public class VelocityException
*/
public VelocityException(final Throwable wrapped)
{
- super();
- this.wrapped = wrapped;
- ExceptionUtils.setCause(this, wrapped);
+ super(wrapped);
}
/**
@@ -76,9 +66,11 @@ public class VelocityException
*
* @return Throwable thrown by method invocation
* @since 1.5
+ * @deprecated Use {@link java.lang.RuntimeException#getCause()}
*/
public Throwable getWrappedThrowable()
{
- return wrapped;
+ return getCause();
}
+
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java Fri Sep 17 19:13:02 2010
@@ -24,8 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
-import org.apache.velocity.util.ExceptionUtils;
-
/**
* This is an input stream that is unicode BOM aware. This allows you to e.g. read
@@ -117,9 +115,7 @@ public class UnicodeInputStream
}
catch (IOException ioe)
{
- IllegalStateException ex = new IllegalStateException("Could not read BOM from Stream");
- ExceptionUtils.setCause(ex, ioe);
- throw ex;
+ throw new IllegalStateException("Could not read BOM from Stream", ioe);
}
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java Fri Sep 17 19:13:02 2010
@@ -23,6 +23,7 @@ import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.apache.velocity.Template;
/**
* This handles context scoping and metadata for directives.
@@ -32,9 +33,11 @@ import java.util.Set;
*/
public class Scope extends AbstractMap
{
+ private static final String setReturnValue = "";
private Map storage;
private Object replaced;
private Scope parent;
+ private Info info;
protected final Object owner;
public Scope(Object owner, Object previous)
@@ -85,6 +88,17 @@ public class Scope extends AbstractMap
}
/**
+ * Convenience method to call put(key,val) in a template
+ * without worrying about what is returned/rendered by the call.
+ * This should ALWAYS return an empty string.
+ */
+ public String set(Object key, Object value)
+ {
+ put(key, value);
+ return setReturnValue;
+ }
+
+ /**
* Allows #stop to easily trigger the proper StopCommand for this scope.
*/
protected void stop()
@@ -98,7 +112,7 @@ public class Scope extends AbstractMap
* instance and the topmost instance, plus one. This value
* will never be negative or zero.
*/
- public int getDepth()
+ protected int getDepth()
{
if (parent == null)
{
@@ -144,4 +158,141 @@ public class Scope extends AbstractMap
return replaced;
}
+ /**
+ * Returns info about the current scope for debugging purposes.
+ */
+ public Info getInfo()
+ {
+ if (info == null)
+ {
+ info = new Info(this, owner);
+ }
+ return info;
+ }
+
+ /**
+ * Class to encapsulate and provide access to info about
+ * the current scope for debugging.
+ */
+ public static class Info
+ {
+ private Scope scope;
+ private Directive directive;
+ private Template template;
+
+ public Info(Scope scope, Object owner)
+ {
+ if (owner instanceof Directive)
+ {
+ directive = (Directive)owner;
+ }
+ if (owner instanceof Template)
+ {
+ template = (Template)owner;
+ }
+ this.scope = scope;
+ }
+
+ public String getName()
+ {
+ if (directive != null)
+ {
+ return directive.getName();
+ }
+ if (template != null)
+ {
+ return template.getName();
+ }
+ return null;
+ }
+
+ public String getType()
+ {
+ if (directive != null)
+ {
+ switch (directive.getType())
+ {
+ case Directive.BLOCK:
+ return "block";
+ case Directive.LINE:
+ return "line";
+ }
+ }
+ if (template != null)
+ {
+ return template.getEncoding();
+ }
+ return null;
+ }
+
+ public int getDepth()
+ {
+ return scope.getDepth();
+ }
+
+ public String getTemplate()
+ {
+ if (directive != null)
+ {
+ return directive.getTemplateName();
+ }
+ if (template != null)
+ {
+ return template.getName();
+ }
+ return null;
+ }
+
+ public int getLine()
+ {
+ if (directive != null)
+ {
+ return directive.getLine();
+ }
+ return 0;
+ }
+
+ public int getColumn()
+ {
+ if (directive != null)
+ {
+ return directive.getColumn();
+ }
+ return 0;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ if (directive != null)
+ {
+ sb.append('#');
+ }
+ sb.append(getName());
+ sb.append("[type:").append(getType());
+ int depth = getDepth();
+ if (depth > 1)
+ {
+ sb.append(" depth:").append(depth);
+ }
+ if (template == null)
+ {
+ String vtl = getTemplate();
+ sb.append(" template:");
+ if (vtl.indexOf(" ") < 0)
+ {
+ sb.append(vtl);
+ }
+ else
+ {
+ sb.append('"').append(vtl).append('"');
+ }
+ sb.append(" line:").append(getLine());
+ sb.append(" column:").append(getColumn());
+ }
+ sb.append(']');
+ return sb.toString();
+ }
+ }
+
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/AvalonLogChute.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/AvalonLogChute.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/AvalonLogChute.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/AvalonLogChute.java Fri Sep 17 19:13:02 2010
@@ -30,6 +30,7 @@ import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
import org.apache.log.output.io.FileTarget;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
@@ -67,7 +68,7 @@ public class AvalonLogChute implements L
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
this.rsvc = rs;
@@ -92,7 +93,7 @@ public class AvalonLogChute implements L
}
// creates a file target using the specified file name
- private void initTarget(final String file, final RuntimeServices rsvc) throws Exception
+ private void initTarget(final String file, final RuntimeServices rsvc)
{
try
{
@@ -116,7 +117,7 @@ public class AvalonLogChute implements L
catch (IOException ioe)
{
rsvc.getLog().error("Unable to create log file for AvalonLogChute", ioe);
- throw new Exception("Error configuring AvalonLogChute : " + ioe);
+ throw new VelocityException("Error configuring AvalonLogChute", ioe);
}
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/HoldingLogChute.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/HoldingLogChute.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/HoldingLogChute.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/HoldingLogChute.java Fri Sep 17 19:13:02 2010
@@ -42,7 +42,7 @@ class HoldingLogChute implements LogChut
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogChute.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogChute.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogChute.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogChute.java Fri Sep 17 19:13:02 2010
@@ -68,7 +68,7 @@ public interface LogChute
* @param rs
* @throws Exception
*/
- void init(RuntimeServices rs) throws Exception;
+ void init(RuntimeServices rs);
/**
* Send a log message from Velocity.
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java Fri Sep 17 19:13:02 2010
@@ -63,7 +63,7 @@ public class LogManager
{
// Creates a new logging system or returns an existing one
// specified by the application.
- private static LogChute createLogChute(RuntimeServices rsvc) throws Exception
+ private static LogChute createLogChute(RuntimeServices rsvc)
{
Log log = rsvc.getLog();
@@ -170,6 +170,20 @@ public class LogManager
ncdfe);
}
}
+ catch(UnsupportedOperationException uoe)
+ {
+ // note these errors for anyone debugging the app
+ if (isProbablyProvidedLogChute(claz))
+ {
+ log.debug("Target log system for " + claz +
+ " is not supported (" + uoe.toString() +
+ "). Falling back to next log system...");
+ }
+ else
+ {
+ log.debug("Couldn't find necessary resources for "+claz, uoe);
+ }
+ }
catch(Exception e)
{
String msg = "Failed to initialize an instance of " + claz +
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/NullLogChute.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/NullLogChute.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/NullLogChute.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/NullLogChute.java Fri Sep 17 19:13:02 2010
@@ -35,7 +35,7 @@ public class NullLogChute implements Log
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/SystemLogChute.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/SystemLogChute.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/SystemLogChute.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/SystemLogChute.java Fri Sep 17 19:13:02 2010
@@ -40,7 +40,7 @@ public class SystemLogChute implements L
private int enabled = WARN_ID;
private int errLevel = TRACE_ID;
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
// look for a level config property
String level = (String)rs.getProperty(RUNTIME_LOG_LEVEL_KEY);
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java Fri Sep 17 19:13:02 2010
@@ -28,12 +28,12 @@ import org.apache.velocity.exception.Met
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.RuntimeMacro;
import org.apache.velocity.runtime.directive.BlockMacro;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Parser;
-import org.apache.velocity.util.ExceptionUtils;
/**
* This class is responsible for handling the pluggable
@@ -109,15 +109,15 @@ public class ASTDirective extends Simple
}
catch (InstantiationException e)
{
- throw ExceptionUtils.createRuntimeException("Couldn't initialize " +
- "directive of class " +
+ throw new VelocityException(
+ "Couldn't initialize directive of class " +
parser.getDirective(directiveName).getClass().getName(),
e);
}
catch (IllegalAccessException e)
{
- throw ExceptionUtils.createRuntimeException("Couldn't initialize " +
- "directive of class " +
+ throw new VelocityException(
+ "Couldn't initialize directive of class " +
parser.getDirective(directiveName).getClass().getName(),
e);
}
@@ -142,7 +142,7 @@ public class ASTDirective extends Simple
catch (TemplateInitException die)
{
throw new TemplateInitException(die.getMessage(),
- (ParseException) die.getWrappedThrowable(),
+ (ParseException) die.getCause(),
die.getTemplateName(),
die.getColumnNumber() + getColumn(),
die.getLineNumber() + getLine());
@@ -178,7 +178,7 @@ public class ASTDirective extends Simple
catch (TemplateInitException die)
{
throw new TemplateInitException(die.getMessage(),
- (ParseException) die.getWrappedThrowable(),
+ (ParseException) die.getCause(),
die.getTemplateName(),
die.getColumnNumber() + getColumn(),
die.getLineNumber() + getLine());
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java Fri Sep 17 19:13:02 2010
@@ -26,7 +26,6 @@ import org.apache.commons.lang.StringUti
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.util.ClassUtils;
-import org.apache.velocity.util.ExceptionUtils;
/**
* ClasspathResourceLoader is a simple loader that will load
@@ -120,7 +119,7 @@ public class ClasspathResourceLoader ext
}
catch( Exception fnfe )
{
- throw (ResourceNotFoundException) ExceptionUtils.createWithCause(ResourceNotFoundException.class, "problem with template: " + name, fnfe );
+ throw new ResourceNotFoundException("ClasspathResourceLoader problem with template: " + name, fnfe );
}
if (result == null)
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Fri Sep 17 19:13:02 2010
@@ -33,7 +33,6 @@ import org.apache.commons.collections.Ex
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.resource.Resource;
-import org.apache.velocity.util.ExceptionUtils;
import org.apache.velocity.util.StringUtils;
/**
@@ -225,10 +224,12 @@ public class DataSourceResourceLoader ex
Connection conn = null;
ResultSet rs = null;
+ PreparedStatement ps = null;
try
{
conn = openDbConnection();
- rs = readData(conn, templateColumn, name);
+ ps = getStatement(conn, templateColumn, name);
+ rs = ps.executeQuery();
if (rs.next())
{
@@ -269,6 +270,7 @@ public class DataSourceResourceLoader ex
finally
{
closeResultSet(rs);
+ closeStatement(ps);
closeDbConnection(conn);
}
}
@@ -297,11 +299,13 @@ public class DataSourceResourceLoader ex
{
Connection conn = null;
ResultSet rs = null;
+ PreparedStatement ps = null;
try
{
conn = openDbConnection();
- rs = readData(conn, timestampColumn, name);
+ ps = getStatement(conn, timestampColumn, name);
+ rs = ps.executeQuery();
if (rs.next())
{
@@ -322,7 +326,7 @@ public class DataSourceResourceLoader ex
+ operation + " of '" + name + "': ";
log.error(msg, sqle);
- throw ExceptionUtils.createRuntimeException(msg, sqle);
+ throw new VelocityException(msg, sqle);
}
catch (NamingException ne)
{
@@ -330,11 +334,12 @@ public class DataSourceResourceLoader ex
+ operation + " of '" + name + "': ";
log.error(msg, ne);
- throw ExceptionUtils.createRuntimeException(msg, ne);
+ throw new VelocityException(msg, ne);
}
finally
{
closeResultSet(rs);
+ closeStatement(ps);
closeDbConnection(conn);
}
}
@@ -411,9 +416,34 @@ public class DataSourceResourceLoader ex
}
}
}
+
+ /**
+ * Closes the PreparedStatement.
+ */
+ private void closeStatement(PreparedStatement ps)
+ {
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (RuntimeException re)
+ {
+ throw re;
+ }
+ catch (Exception e)
+ {
+ String msg = "DataSourceResourceLoader: problem when closing PreparedStatement ";
+ log.error(msg, e);
+ throw new VelocityException(msg, e);
+ }
+ }
+ }
+
/**
- * Reads the data from the datasource. It simply does the following query :
+ * Creates the following PreparedStatement query :
* <br>
* SELECT <i>columnNames</i> FROM <i>tableName</i> WHERE <i>keyColumn</i>
* = '<i>templateName</i>'
@@ -423,15 +453,15 @@ public class DataSourceResourceLoader ex
* @param conn connection to datasource
* @param columnNames columns to fetch from datasource
* @param templateName name of template to fetch
- * @return result set from query
+ * @return PreparedStatement
*/
- private ResultSet readData(final Connection conn,
+ private PreparedStatement getStatement(final Connection conn,
final String columnNames,
final String templateName) throws SQLException
{
PreparedStatement ps = conn.prepareStatement("SELECT " + columnNames + " FROM "+ tableName + " WHERE " + keyColumn + " = ?");
ps.setString(1, templateName);
- return ps.executeQuery();
+ return ps;
}
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java Fri Sep 17 19:13:02 2010
@@ -20,6 +20,7 @@ package org.apache.velocity.util.introsp
*/
import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Enumeration;
@@ -219,7 +220,6 @@ public class UberspectImpl implements Ub
* @param identifier
* @param i
* @return A Velocity Getter Method.
- * @throws Exception
*/
public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
{
@@ -273,7 +273,6 @@ public class UberspectImpl implements Ub
* @param arg
* @param i
* @return A Velocity Setter method.
- * @throws Exception
*/
public VelPropertySet getPropertySet(Object obj, String identifier,
Object arg, Info i)
@@ -345,7 +344,7 @@ public class UberspectImpl implements Ub
* @see VelMethod#invoke(java.lang.Object, java.lang.Object[])
*/
public Object invoke(Object o, Object[] actual)
- throws Exception
+ throws IllegalAccessException, InvocationTargetException
{
// if we're pretending an array is a list...
if (wrapArray)
@@ -374,7 +373,8 @@ public class UberspectImpl implements Ub
* has already been completed.
* @since 1.6
*/
- protected Object doInvoke(Object o, Object[] actual) throws Exception
+ protected Object doInvoke(Object o, Object[] actual)
+ throws IllegalAccessException, InvocationTargetException
{
return method.invoke(o, actual);
}
@@ -518,7 +518,7 @@ public class UberspectImpl implements Ub
* @see org.apache.velocity.util.introspection.VelPropertyGet#invoke(java.lang.Object)
*/
public Object invoke(Object o)
- throws Exception
+ throws IllegalAccessException, InvocationTargetException
{
return getExecutor.execute(o);
}
@@ -566,10 +566,9 @@ public class UberspectImpl implements Ub
* @param o is the Object to invoke it on.
* @param value in the Value to set.
* @return The resulting Object.
- * @throws Exception
*/
public Object invoke(final Object o, final Object value)
- throws Exception
+ throws IllegalAccessException, InvocationTargetException
{
return setExecutor.execute(o, value);
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java Fri Sep 17 19:13:02 2010
@@ -1,5 +1,7 @@
package org.apache.velocity.util.introspection;
+import java.lang.reflect.InvocationTargetException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -36,10 +38,10 @@ public interface VelMethod
* @param o
* @param params
* @return The resulting object.
- * @throws Exception
+ * @throws IllegalAccessException, InvocationTargetException
*/
public Object invoke(Object o, Object[] params)
- throws Exception;
+ throws IllegalAccessException, InvocationTargetException;
/**
* specifies if this VelMethod is cacheable and able to be
Propchange: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Sep 17 19:13:02 2010
@@ -0,0 +1,3 @@
+/velocity/engine/branches/2.0_Exp/src/test:991639-992140
+/velocity/engine/branches/2.0_Exp/velocity-engine-core/src/test/java:958513,991637-995742
+/velocity/engine/trunk/velocity-engine-core/src/test/java:992133
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BlockMacroTestCase.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BlockMacroTestCase.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BlockMacroTestCase.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BlockMacroTestCase.java Fri Sep 17 19:13:02 2010
@@ -128,5 +128,15 @@ public class BlockMacroTestCase extends
"#@foo()call:$bodyContent#end";
assertEvalEquals("start:call:call:call:$bodyContent", template);
}
+
+ public void testBlueJoesProblem()
+ {
+ engine.setProperty("macro."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, Boolean.TRUE);
+ addTemplate("a", "#macro(wrap $layout)$!macro.put($layout,$bodyContent)#parse($layout)#end"+
+ "#@wrap('b')a#end");
+ addTemplate("b", "#@wrap('c')b$!macro.get('b')b#end");
+ addTemplate("c", "c$!macro.get('c')c");
+ assertTmplEquals("cbabc", "a");
+ }
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EventHandlingTestCase.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EventHandlingTestCase.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EventHandlingTestCase.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EventHandlingTestCase.java Fri Sep 17 19:13:02 2010
@@ -237,7 +237,6 @@ public class EventHandlingTestCase exten
* Handles exceptions thrown during in-template method access
*/
public Object methodException( Class claz, String method, Exception e )
- throws Exception
{
// as a test, make sure this EventHandler is initialized
if (rs == null)
@@ -253,11 +252,11 @@ public class EventHandlingTestCase exten
return "handler";
}
else
- throw e;
+ throw new RuntimeException(e);
} else
- throw e;
+ throw new RuntimeException(e);
}
Context context;
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java Fri Sep 17 19:13:02 2010
@@ -106,7 +106,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -143,7 +143,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -175,7 +175,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -206,7 +206,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -244,7 +244,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ScopeTestCase.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ScopeTestCase.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ScopeTestCase.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ScopeTestCase.java Fri Sep 17 19:13:02 2010
@@ -1,325 +1,367 @@
-package org.apache.velocity.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.util.HashMap;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-
-
-/**
- * This class tests the directive scope controls
- */
-public class ScopeTestCase extends BaseTestCase
-{
- public ScopeTestCase(String name)
- {
- super(name);
- }
-
- protected void setUpEngine(VelocityEngine engine)
- {
- engine.setProperty("a.provide.scope.control", "true");
- engine.setProperty("define.provide.scope.control", "true");
- engine.setProperty("evaluate.provide.scope.control", "true");
- engine.setProperty("foo.provide.scope.control", "true");
- engine.setProperty("macro.provide.scope.control", "true");
- engine.setProperty("template.provide.scope.control", "true");
- engine.setProperty("vm.provide.scope.control", "true");
- }
-
- public void testRootTemplateMergeScope()
- {
- addTemplate("foo", "foo#break($template)bar");
- assertTmplEquals("foo", "foo");
- assertNull(context.get("template"));
- }
-
- public void testScopeGetLeakIntoInner()
- {
- addTemplate("foo", "#foreach($i in [1..1])#set($foreach.a=$i)"+
- "#foreach($j in [2..2])$foreach.a#set($foreach.a=$j)"+
- "#foreach($k in [3..3])$foreach.a#end#end#end");
- assertTmplEquals("12", "foo");
- }
-
- public void testScopeGetLeakDoesntHideNullset()
- {
- addTemplate("a", "#macro(a)#set($macro.a='a')#b()$macro.a#end"+
- "#macro(b)$macro.a#set($macro.a=$null)$!macro.a#end"+
- "#a()");
- assertTmplEquals("aa", "a");
- }
-
- public void testParseScope()
- {
- addTemplate("test", "$template.depth"+
- "$!parse.parent.depth"+
- "#set( $template.foo = 'bar' )"+
- "$template.foo"+
- "#break($template)"+
- "woogie");
- assertEvalEquals("1bar", "#parse( 'test' )");
- assertNull(context.get("template"));
- }
-
- public void testNestedParseScope()
- {
- HashMap grab = new HashMap();
- context.put("grab", grab);
-
- addTemplate("inner", "Inner depth: $template.depth"+
- "#set( $template.foo = '?' )"+
- "$!grab.put('inner',$template)"+
- "#break($template)$template.foo");
- addTemplate("outer", "#set( $template.foo = '!' )"+
- "Outer depth: $template.depth "+
- "#parse('inner')"+
- "$!grab.put('outer', $template)"+
- "$template.foo");
- assertEvalEquals("Outer depth: 1 Inner depth: 2!", "#parse('outer')");
- // make extra sure that the outer control was restored after the stop
- assertFalse(grab.get("inner") == grab.get("outer"));
- // make sure the outer control was cleaned up
- assertNull(context.get("template"));
-
- addTemplate("3", "$template.topmost.foo#set( $template.topmost.foo = 'bar' )");
- addTemplate("2", "#parse( '3' )$!parse.foo");
- addTemplate("1", "#set( $template.foo = 'foo' )#parse('2')$template.foo");
- assertEvalEquals("foobar", "#parse('1')$!parse");
- // make sure the top control was cleaned up
- assertNull(context.get("template"));
- }
-
- public void testForeachScope()
- {
- String template = "#foreach( $i in [0..2] )"+
- "#if( $i > 1 )#break($foreach)#end"+
- "$foreach.index:$foreach.count:$foreach.hasNext,"+
- "#end";
- assertEvalEquals("0:1:true,1:2:true,", template);
- assertNull(context.get("foreach"));
- }
-
- public void testNestedForeachScope()
- {
- String template = "#foreach( $i in [1..5] )"+
- "#foreach( $j in [1..2] )"+
- "#if ( $i > $foreach.count + $foreach.index + $foreach.depth )#break($foreach.topmost)#end"+
- "#end"+
- "$i"+
- "#end";
- assertEvalEquals("123", template);
- assertNull(context.get("foreach"));
- }
-
- public void testMacroScope()
- {
- String template = "#macro( foo $i )"+
- "#if($i > 2 )#break($macro)#end"+
- "$i#end"+
- "#foo( 0 )#foo( 1 )#foo( 2 )";
- assertEvalEquals("012", template);
- assertNull(context.get("macro"));
- }
-
- public void testRecursiveMacroScope()
- {
- String template = "#macro( foo )$macro.depth"+
- "#if($macro.depth > 2 )#break($macro.topmost)#end"+
- "#foo()#end#foo()";
- assertEvalEquals("123", template);
- assertNull(context.get("macro"));
- }
-
- public void testNestedMacroScope()
- {
- String template = "#macro( a )$macro.depth#set($macro.c = 'a')$macro.c#end"+
- "#macro( b )#set($macro.c = 'b' )#a()$macro.c#end"+
- "#b()";
- assertEvalEquals("2ab", template);
- assertNull(context.get("macro"));
- }
-
- public void testBodyMacroScope()
- {
- String template = "#macro( foo $bar )$bodyContent$macro.bar#end"+
- "#@foo( 'bar' )#set( $macro.bar = 'foo'+$bar )"+
- "#set( $foo.d = $foo.depth )$foo.d #end";
- assertEvalEquals("1 foobar", template);
- assertNull(context.get("foo"));
- assertNull(context.get("macro"));
- }
-
- public void testRecursiveBodyMacroScope()
- {
- engine.setProperty(RuntimeConstants.VM_MAX_DEPTH, "5");
- String template = "#macro( foo )$bodyContent$macro.i#end"+
- "#@foo()#set( $macro.i = \"$!macro.i$foo.depth,\" )"+
- "$!bodyContent#end";
- assertEvalEquals("1,2,3,4,5,", template);
- assertNull(context.get("foo"));
- assertNull(context.get("macro"));
- }
-
- public void testDefineScope()
- {
- String template = "#define( $foo )#set( $define.bar = 'bar'+$define.depth )$define.bar#end$foo";
- assertEvalEquals("bar1", template);
- assertNull(context.get("define"));
- }
-
- public void testNestedDefineScope()
- {
- String template = "#define($a)$b c#end"+
- "#define($b)$define.depth#break($define.topmost)#end"+
- "$a";
- assertEvalEquals("2", template);
- assertNull(context.get("define"));
- }
-
- public void testRecursiveDefineScope()
- {
- engine.setProperty(RuntimeConstants.DEFINE_DIRECTIVE_MAXDEPTH, "10");
- String template = "#define($a)$define.depth"+
- "#if($define.depth == 5)#break($define)#end,$a#end$a";
- assertEvalEquals("1,2,3,4,5", template);
- assertNull(context.get("define"));
- }
-
- public void testRootEvaluateScope()
- {
- assertEvalEquals("1", "$evaluate.depth");
- assertEvalEquals("foo", "foo#break($evaluate)bar");
- assertNull(context.get("evaluate"));
- }
-
- public void testEvaluateScope()
- {
- context.put("h", "#");
- context.put("d", "$");
- String template = "${h}set( ${d}evaluate.foo = 'bar' )"+
- "${d}evaluate.foo ${d}evaluate.depth";
- addTemplate("eval", "#evaluate(\""+template+"\")");
- assertTmplEquals("bar 1", "eval");
- assertNull(context.get("evaluate"));
- assertNull(context.get("template"));
- }
-
- public void testNestedEvaluateScope()
- {
- context.put("h", "#");
- context.put("d", "$");
- addTemplate("e", "#evaluate(\"${h}evaluate( '${d}evaluate.depth${h}stop(${d}evaluate) blah' )\")");
- assertTmplEquals("2", "e");
- assertNull(context.get("evaluate"));
- assertNull(context.get("template"));
- }
-
- public void testTurningOffTemplateScope()
- {
- engine.setProperty("template."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
- // root
- addTemplate("test", "$template.depth");
- assertTmplEquals("$template.depth", "test");
- // #parse
- assertEvalEquals("$template.depth", "#parse('test')");
- }
-
- public void testTurningOffEvaluateScope()
- {
- engine.setProperty("evaluate."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
- // root
- assertSchmoo("$evaluate.depth");
- // #evaluate
- assertEvalEquals("$evaluate.depth", "#evaluate( '$evaluate.depth' )");
- }
-
- public void testTurningOffMacroScope()
- {
- engine.setProperty("macro."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
- engine.setProperty("foo."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
- // macro definition
- assertEvalEquals("$macro", "#macro(a)$macro#end#a()");
- // macro body
- assertEvalEquals("$macro $foo", "#macro(foo)$bodyContent#end#@foo()$macro $foo#end");
- }
-
- public void testTurningOffDefineScope()
- {
- engine.setProperty("define."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
- assertEvalEquals("$define", "#define($a)$define#end$a");
- }
-
- public void testTurningOffForeachScope()
- {
- engine.setProperty("foreach."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
- assertEvalEquals("$foreach$foreach", "#foreach($i in [0..1])$foreach#end");
- }
-
- public void testTemplateReplaced()
- {
- context.put("template", "foo");
- addTemplate("test", "$template.replaced");
- assertTmplEquals("foo", "test");
- assertEvalEquals("foo", "#parse('test')");
- assertContextValue("template", "foo");
- }
-
- public void testEvaluateReplaced()
- {
- context.put("evaluate","foo");
- assertEvalEquals("foo", "$evaluate.replaced");
- assertEvalEquals("foo", "#evaluate('$evaluate.replaced')");
- assertContextValue("evaluate", "foo");
- }
-
- public void testMacroReplaced()
- {
- context.put("macro", "foo");
- assertEvalEquals("foo foo foo", "$macro #macro(a)$macro.replaced#end#a() $macro");
- assertContextValue("macro", "foo");
- }
-
- public void testForeachReplaced()
- {
- context.put("foreach", "foo");
- assertEvalEquals("foofoofoo", "$foreach#foreach($i in [1..1])$foreach.replaced#end$foreach");
- assertEquals("foo", context.get("foreach"));
- context.put("foreach", "a");
- assertEvalEquals("a", "#foreach($i in [1..1])#foreach($j in [1..1])$foreach.replaced#end#end");
- assertContextValue("foreach", "a");
- }
-
- public void testDefineReplaced()
- {
- context.put("define", "a");
- assertEvalEquals("a", "#define($a)$define.replaced#end$a");
- assertContextValue("define", "a");
- }
-
- public void testBodyContentReplaced()
- {
- context.put("vm", "a");
- assertEvalEquals("a", "#macro(vm)$bodyContent#end#@vm()$vm.replaced#end");
- assertContextValue("vm", "a");
- }
-
-}
+package org.apache.velocity.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.util.HashMap;
+
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * This class tests the directive scope controls
+ */
+public class ScopeTestCase extends BaseTestCase
+{
+ public ScopeTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUpEngine(VelocityEngine engine)
+ {
+ engine.setProperty("a.provide.scope.control", "true");
+ engine.setProperty("define.provide.scope.control", "true");
+ engine.setProperty("evaluate.provide.scope.control", "true");
+ engine.setProperty("foo.provide.scope.control", "true");
+ engine.setProperty("macro.provide.scope.control", "true");
+ engine.setProperty("template.provide.scope.control", "true");
+ engine.setProperty("vm.provide.scope.control", "true");
+ }
+
+ public void testScopeGetLeakIntoInner()
+ {
+ addTemplate("foo", "#foreach($i in [1..1])#set($foreach.a=$i)"+
+ "#foreach($j in [2..2])$foreach.a#set($foreach.a=$j)"+
+ "#foreach($k in [3..3])$foreach.a#end#end$foreach.a#end");
+ assertTmplEquals("121", "foo");
+ }
+
+ public void testScopeGetLeakDoesntHideNullset()
+ {
+ addTemplate("a", "#macro(a)#set($macro.a='a')#b()$macro.a#end"+
+ "#macro(b)$macro.a#set($macro.a=$null)$!macro.a#end"+
+ "#a()");
+ assertTmplEquals("aa", "a");
+ }
+
+ public void testRootTemplateMergeScope()
+ {
+ addTemplate("foo", "foo#break($template)bar");
+ assertTmplEquals("foo", "foo");
+ assertNull(context.get("template"));
+ }
+
+ public void testParseScope()
+ {
+ addTemplate("test", "$template.info.depth"+
+ "$!parse.parent.info.depth"+
+ "#set( $template.foo = 'bar' )"+
+ "$template.foo"+
+ "#break($template)"+
+ "woogie");
+ assertEvalEquals("1bar", "#parse( 'test' )");
+ assertNull(context.get("template"));
+ }
+
+ public void testNestedParseScope()
+ {
+ HashMap grab = new HashMap();
+ context.put("grab", grab);
+
+ addTemplate("inner", "Inner depth: $template.info.depth"+
+ "#set( $template.foo = '?' )"+
+ "$!grab.put('inner',$template)"+
+ "#break($template)$template.foo");
+ addTemplate("outer", "#set( $template.foo = '!' )"+
+ "Outer depth: $template.info.depth "+
+ "#parse('inner')"+
+ "$!grab.put('outer', $template)"+
+ "$template.foo");
+ assertEvalEquals("Outer depth: 1 Inner depth: 2!", "#parse('outer')");
+ // make extra sure that the outer control was restored after the stop
+ assertFalse(grab.get("inner") == grab.get("outer"));
+ // make sure the outer control was cleaned up
+ assertNull(context.get("template"));
+
+ addTemplate("3", "$template.topmost.foo#set( $template.topmost.foo = 'bar' )");
+ addTemplate("2", "#parse( '3' )$!parse.foo");
+ addTemplate("1", "#set( $template.foo = 'foo' )#parse('2')$template.foo");
+ assertEvalEquals("foobar", "#parse('1')$!parse");
+ // make sure the top control was cleaned up
+ assertNull(context.get("template"));
+ }
+
+ public void testForeachScope()
+ {
+ String template = "#foreach( $i in [0..2] )"+
+ "#if( $i > 1 )#break($foreach)#end"+
+ "$foreach.index:$foreach.count:$foreach.hasNext,"+
+ "#end";
+ assertEvalEquals("0:1:true,1:2:true,", template);
+ assertNull(context.get("foreach"));
+ }
+
+ public void testNestedForeachScope()
+ {
+ String template = "#foreach( $i in [1..5] )"+
+ "#foreach( $j in [1..2] )"+
+ "#if ( $i > $foreach.count + $foreach.index + $foreach.info.depth )#break($foreach.topmost)#end"+
+ "#end"+
+ "$i"+
+ "#end";
+ assertEvalEquals("123", template);
+ assertNull(context.get("foreach"));
+ }
+
+ public void testMacroScope()
+ {
+ String template = "#macro( foo $i )"+
+ "#if($i > 2 )#break($macro)#end"+
+ "$i#end"+
+ "#foo( 0 )#foo( 1 )#foo( 2 )";
+ assertEvalEquals("012", template);
+ assertNull(context.get("macro"));
+ }
+
+ public void testRecursiveMacroScope()
+ {
+ String template = "#macro( foo )$macro.info.depth"+
+ "#if($macro.info.depth > 2 )#break($macro.topmost)#end"+
+ "#foo()#end#foo()";
+ assertEvalEquals("123", template);
+ assertNull(context.get("macro"));
+ }
+
+ public void testNestedMacroScope()
+ {
+ String template = "#macro( a )$macro.info.depth#set($macro.c = 'a')$macro.c#end"+
+ "#macro( b )#set($macro.c = 'b' )#a()$macro.c#end"+
+ "#b()";
+ assertEvalEquals("2ab", template);
+ assertNull(context.get("macro"));
+ }
+
+ public void testBodyMacroScope()
+ {
+ String template = "#macro( foo $bar )$bodyContent$macro.bar#end"+
+ "#@foo( 'bar' )#set( $macro.bar = 'foo'+$bar )"+
+ "#set( $foo.d = $foo.info.depth )$foo.d #end";
+ assertEvalEquals("1 foobar", template);
+ assertNull(context.get("foo"));
+ assertNull(context.get("macro"));
+ }
+
+ public void testRecursiveBodyMacroScope()
+ {
+ engine.setProperty(RuntimeConstants.VM_MAX_DEPTH, "5");
+ String template = "#macro( foo )$bodyContent$macro.i#end"+
+ "#@foo()#set( $macro.i = \"$!macro.i$foo.info.depth,\" )"+
+ "$!bodyContent#end";
+ assertEvalEquals("1,2,3,4,5,", template);
+ assertNull(context.get("foo"));
+ assertNull(context.get("macro"));
+ }
+
+ public void testDefineScope()
+ {
+ String template = "#define( $foo )#set( $define.bar = 'bar'+$define.info.depth )$define.bar#end$foo";
+ assertEvalEquals("bar1", template);
+ assertNull(context.get("define"));
+ }
+
+ public void testNestedDefineScope()
+ {
+ String template = "#define($a)$b c#end"+
+ "#define($b)$define.info.depth#break($define.topmost)#end"+
+ "$a";
+ assertEvalEquals("2", template);
+ assertNull(context.get("define"));
+ }
+
+ public void testRecursiveDefineScope()
+ {
+ engine.setProperty(RuntimeConstants.DEFINE_DIRECTIVE_MAXDEPTH, "10");
+ String template = "#define($a)$define.info.depth"+
+ "#if($define.info.depth == 5)#break($define)#end,$a#end$a";
+ assertEvalEquals("1,2,3,4,5", template);
+ assertNull(context.get("define"));
+ }
+
+ public void testRootEvaluateScope()
+ {
+ assertEvalEquals("1", "$evaluate.info.depth");
+ assertEvalEquals("foo", "foo#break($evaluate)bar");
+ assertNull(context.get("evaluate"));
+ }
+
+ public void testEvaluateScope()
+ {
+ context.put("h", "#");
+ context.put("d", "$");
+ String template = "${h}set( ${d}evaluate.foo = 'bar' )"+
+ "${d}evaluate.foo ${d}evaluate.info.depth";
+ addTemplate("eval", "#evaluate(\""+template+"\")");
+ assertTmplEquals("bar 1", "eval");
+ assertNull(context.get("evaluate"));
+ assertNull(context.get("template"));
+ }
+
+ public void testNestedEvaluateScope()
+ {
+ context.put("h", "#");
+ context.put("d", "$");
+ addTemplate("e", "#evaluate(\"${h}evaluate( '${d}evaluate.info.depth${h}stop(${d}evaluate) blah' )\")");
+ assertTmplEquals("2", "e");
+ assertNull(context.get("evaluate"));
+ assertNull(context.get("template"));
+ }
+
+ public void testTurningOffTemplateScope()
+ {
+ engine.setProperty("template."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
+ // root
+ addTemplate("test", "$template.info.depth");
+ assertTmplEquals("$template.info.depth", "test");
+ // #parse
+ assertEvalEquals("$template.info.depth", "#parse('test')");
+ }
+
+ public void testTurningOffEvaluateScope()
+ {
+ engine.setProperty("evaluate."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
+ // root
+ assertSchmoo("$evaluate.info.depth");
+ // #evaluate
+ assertEvalEquals("$evaluate.info.depth", "#evaluate( '$evaluate.info.depth' )");
+ }
+
+ public void testTurningOffMacroScope()
+ {
+ engine.setProperty("macro."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
+ engine.setProperty("foo."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
+ // macro definition
+ assertEvalEquals("$macro", "#macro(a)$macro#end#a()");
+ // macro body
+ assertEvalEquals("$macro $foo", "#macro(foo)$bodyContent#end#@foo()$macro $foo#end");
+ }
+
+ public void testTurningOffDefineScope()
+ {
+ engine.setProperty("define."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
+ assertEvalEquals("$define", "#define($a)$define#end$a");
+ }
+
+ public void testTurningOffForeachScope()
+ {
+ engine.setProperty("foreach."+RuntimeConstants.PROVIDE_SCOPE_CONTROL, "false");
+ assertEvalEquals("$foreach$foreach", "#foreach($i in [0..1])$foreach#end");
+ }
+
+ public void testTemplateReplaced()
+ {
+ context.put("template", "foo");
+ addTemplate("test", "$template.replaced");
+ assertTmplEquals("foo", "test");
+ assertEvalEquals("foo", "#parse('test')");
+ assertContextValue("template", "foo");
+ }
+
+ public void testEvaluateReplaced()
+ {
+ context.put("evaluate","foo");
+ assertEvalEquals("foo", "$evaluate.replaced");
+ assertEvalEquals("foo", "#evaluate('$evaluate.replaced')");
+ assertContextValue("evaluate", "foo");
+ }
+
+ public void testMacroReplaced()
+ {
+ context.put("macro", "foo");
+ assertEvalEquals("foo foo foo", "$macro #macro(a)$macro.replaced#end#a() $macro");
+ assertContextValue("macro", "foo");
+ }
+
+ public void testForeachReplaced()
+ {
+ context.put("foreach", "foo");
+ assertEvalEquals("foofoofoo", "$foreach#foreach($i in [1..1])$foreach.replaced#end$foreach");
+ assertEquals("foo", context.get("foreach"));
+ context.put("foreach", "a");
+ assertEvalEquals("a", "#foreach($i in [1..1])#foreach($j in [1..1])$foreach.replaced#end#end");
+ assertContextValue("foreach", "a");
+ }
+
+ public void testDefineReplaced()
+ {
+ context.put("define", "a");
+ assertEvalEquals("a", "#define($a)$define.replaced#end$a");
+ assertContextValue("define", "a");
+ }
+
+ public void testBodyContentReplaced()
+ {
+ context.put("vm", "a");
+ assertEvalEquals("a", "#macro(vm)$bodyContent#end#@vm()$vm.replaced#end");
+ assertContextValue("vm", "a");
+ }
+
+ public void testInfoDepth()
+ {
+ String template = "#foreach($i in [1..1])"+
+ "#foreach($j in [0..0])"+
+ "$foreach.info.depth"+
+ "#end"+
+ "#end";
+ assertEvalEquals("2", template);
+ }
+
+ public void testInfoName()
+ {
+ String template = "#foreach($i in [1..1])"+
+ "$foreach.info.name #evaluate('$evaluate.info.name')"+
+ "#end";
+ assertEvalEquals("foreach evaluate", template);
+ }
+
+ public void testInfoType()
+ {
+ addTemplate("info", "#foreach($i in [1..1])"+
+ "$foreach.info.type"+
+ "#end "+
+ "#evaluate('$evaluate.info.type') "+
+ "$template.info.type");
+ assertTmplEquals("block line utf-8", "info");
+ }
+
+ public void testInfoLineAndColumn()
+ {
+ String template = " #evaluate('$evaluate.info.line, $evaluate.info.column')";
+ assertEvalEquals(" 1, 2", template);
+ assertEvalEquals("\n\n 3, 4", "\n\n "+template);
+ }
+
+ public void testInfoTemplate()
+ {
+ addTemplate("test", "#evaluate('$evaluate.info.template')");
+ assertTmplEquals("test", "test");
+ assertEvalEquals("test", "#parse('test')");
+ }
+
+}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/WrappedExceptionTestCase.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/WrappedExceptionTestCase.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/WrappedExceptionTestCase.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/WrappedExceptionTestCase.java Fri Sep 17 19:13:02 2010
@@ -27,9 +27,6 @@ import org.apache.velocity.app.VelocityE
import org.apache.velocity.context.Context;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.test.provider.TestProvider;
-import org.apache.velocity.util.ExceptionUtils;
-
-
/**
* Test thrown exceptions include a proper cause (under JDK 1.4+).
@@ -81,11 +78,5 @@ public class WrappedExceptionTestCase ex
}
}
- public void testExceptionUtils()
- {
- Error e = new Error("Inside");
- RuntimeException re = ExceptionUtils.createRuntimeException("Outside", e);
- assertEquals("cause was set", e,re.getCause());
- }
}
Modified: velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java?rev=998264&r1=998263&r2=998264&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java (original)
+++ velocity/sandbox/maven-reorg/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java Fri Sep 17 19:13:02 2010
@@ -46,9 +46,9 @@ public class Handler1
/**
* throw the exception
*/
- public Object methodException(Class claz, String method, Exception e) throws Exception
+ public Object methodException(Class claz, String method, Exception e)
{
- throw e;
+ throw new RuntimeException(e);
}
/*