Author: nbubna
Date: Thu Sep 18 13:56:29 2008
New Revision: 696799
URL: http://svn.apache.org/viewvc?rev=696799&view=rev
Log:
add some more useful assertions
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java?rev=696799&r1=696798&r2=696799&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/BaseEvalTestCase.java
Thu Sep 18 13:56:29 2008
@@ -85,6 +85,27 @@
assertEquals(expected, evaluate(template));
}
+ protected void assertEvalException(String evil)
+ {
+ assertEvalException(evil, null);
+ }
+
+ protected void assertEvalException(String evil, Class exceptionType)
+ {
+ try
+ {
+ evaluate(evil);
+ fail("Template '"+evil+"' should have thrown an exception.");
+ }
+ catch (Exception e)
+ {
+ if (exceptionType != null &&
!exceptionType.isAssignableFrom(e.getClass()))
+ {
+ fail("Was expecting template '"+evil+"' to throw
"+exceptionType+" not "+e);
+ }
+ }
+ }
+
protected String evaluate(String template)
{
StringWriter writer = new StringWriter();
@@ -107,10 +128,18 @@
}
catch (RuntimeException re)
{
+ if (DEBUG)
+ {
+ engine.getLog().info("RuntimeException!", re);
+ }
throw re;
}
catch (Exception e)
{
+ if (DEBUG)
+ {
+ engine.getLog().info("Exception!", e);
+ }
throw new RuntimeException(e);
}
}