jvanzyl 01/03/05 02:33:34
Modified: src/java/org/apache/velocity/test ContextSafetyTestCase.java
TemplateTestCase.java
Log:
- fixing up some of the test classes so that the velocity runtime
isn't initialized twice.
most of the the tests that require the runtime are run via
the VelocityTestSuite which already initializes the runtime.
tests run from within VelocityTestSuite that extend RuntimeTestCase
cause the velocity runtime to be initialized twice which is
a problem. basically the default properties were getting loaded
twice which actually didn't cause a problem before because properties
were overwritten whereas now multple same value keys are handled.
i will fix the problem where the default properties get loaded
more then once. it shouldn't happen, even inadvertently.
Revision Changes Path
1.4 +8 -2
jakarta-velocity/src/java/org/apache/velocity/test/ContextSafetyTestCase.java
Index: ContextSafetyTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/ContextSafetyTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContextSafetyTestCase.java 2001/01/03 05:28:51 1.3
+++ ContextSafetyTestCase.java 2001/03/05 10:33:31 1.4
@@ -73,10 +73,16 @@
* Tests if we are context safe : can we switch objects in the context
* and re-merge the template safely.
*
+ * NOTE:
+ * This class should not extend RuntimeTestCase because this test
+ * is run from the VelocityTestSuite which in effect a runtime
+ * test suite and the test suite initializes the Runtime. Extending
+ * RuntimeTestCase causes the Runtime to be initialized twice.
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ContextSafetyTestCase.java,v 1.3 2001/01/03 05:28:51 geirm Exp $
+ * @version $Id: ContextSafetyTestCase.java,v 1.4 2001/03/05 10:33:31 jvanzyl Exp $
*/
-public class ContextSafetyTestCase extends RuntimeTestCase
+public class ContextSafetyTestCase extends BaseTestCase
{
/**
* VTL file extension.
1.22 +19 -2
jakarta-velocity/src/java/org/apache/velocity/test/TemplateTestCase.java
Index: TemplateTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/TemplateTestCase.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TemplateTestCase.java 2001/02/15 12:30:23 1.21
+++ TemplateTestCase.java 2001/03/05 10:33:32 1.22
@@ -74,12 +74,29 @@
/**
* Easily add test cases which evaluate templates and check their output.
*
+ * NOTE:
+ * This class DOES NOT extend RuntimeTestCase because the VelocityTestSuite
+ * already initializes the Velocity runtime and adds the template
+ * test cases. Having this class extend RuntimeTestCase causes the
+ * Runtime to be initialized twice which is not good. I only discovered
+ * this after a couple hours of wondering why all the properties
+ * being setup were ending up as Vectors. At first I thought it
+ * was a problem with the Configuration class, but the Runtime
+ * was being initialized twice: so the first time the property
+ * is seen it's stored as a String, the second time it's seen
+ * the Configuration class makes a Vector with both Strings.
+ * As a result all the getBoolean(property) calls were failing because
+ * the Configurations class was trying to create a Boolean from
+ * a Vector which doesn't really work that well. I have learned
+ * my lesson and now have to add some code to make sure the
+ * Runtime isn't initialized more then once :-)
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: TemplateTestCase.java,v 1.21 2001/02/15 12:30:23 geirm Exp $
+ * @version $Id: TemplateTestCase.java,v 1.22 2001/03/05 10:33:32 jvanzyl Exp $
*/
-public class TemplateTestCase extends RuntimeTestCase
+public class TemplateTestCase extends BaseTestCase
{
/**
* VTL file extension.