jvanzyl 01/03/14 14:05:36
Modified: src/java/org/apache/velocity/test ClasspathResourceTest.java
ContextSafetyTestCase.java
InlineScopeVMTestCase.java
MultipleFileResourcePathTest.java
TemplateTestSuite.java VelocityAppTestCase.java
src/java/org/apache/velocity/test/misc Test.java
Log:
- conversion of the tests to use the velocity app class and made
all the tests consistent in using the Velocity.setProperty() method.
the tests don't need to create a properties object the properties
can be set directly.
Revision Changes Path
1.2 +23 -11
jakarta-velocity/src/java/org/apache/velocity/test/ClasspathResourceTest.java
Index: ClasspathResourceTest.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/ClasspathResourceTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClasspathResourceTest.java 2001/03/05 23:34:16 1.1
+++ ClasspathResourceTest.java 2001/03/14 22:05:17 1.2
@@ -61,12 +61,11 @@
import java.util.Properties;
-import org.apache.velocity.VelocityContext;
-
import org.apache.velocity.Template;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.VelocityContext;
import org.apache.velocity.test.provider.TestProvider;
import org.apache.velocity.runtime.Runtime;
-import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.util.StringUtils;
import org.apache.velocity.runtime.VelocimacroFactory;
@@ -77,7 +76,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
- * @version $Id: ClasspathResourceTest.java,v 1.1 2001/03/05 23:34:16 daveb Exp $
+ * @version $Id: ClasspathResourceTest.java,v 1.2 2001/03/14 22:05:17 jvanzyl Exp $
*/
public class ClasspathResourceTest extends TestCase
{
@@ -97,11 +96,6 @@
private static final String RESULT_FILE_EXT = "res";
/**
- * Overload velocity template
- */
- private final static String TEST_PROPERTY_FILE =
"../test/cpload/velocity.properties";
-
- /**
* Results relative to the build directory.
*/
private static final String RESULT_DIR = "../test/cpload/result";
@@ -114,13 +108,31 @@
/**
* Default constructor.
*/
- ClasspathResourceTest()
+ public ClasspathResourceTest()
{
super("ClasspathResourceTest");
try
{
- Runtime.init( TEST_PROPERTY_FILE );
+ Velocity.setProperty(Velocity.RESOURCE_LOADER, "classpath");
+
+ /*
+ * I don't think I should have to do this, these should
+ * be in the default config file.
+ */
+
+ Velocity.setProperty(
+ "classpath." + Velocity.RESOURCE_LOADER + ".class",
+
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+
+ Velocity.setProperty(
+ "classpath." + Velocity.RESOURCE_LOADER + ".cache", "false");
+
+ Velocity.setProperty(
+ "classpath." + Velocity.RESOURCE_LOADER +
".modificationCheckInterval",
+ "2");
+
+ Velocity.init();
}
catch (Exception e)
{
1.7 +8 -6
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContextSafetyTestCase.java 2001/03/12 00:31:13 1.6
+++ ContextSafetyTestCase.java 2001/03/14 22:05:18 1.7
@@ -64,8 +64,9 @@
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
-import org.apache.velocity.test.provider.TestProvider;
+import org.apache.velocity.app.Velocity;
import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.test.provider.TestProvider;
import org.apache.velocity.util.StringUtils;
import junit.framework.TestCase;
@@ -81,19 +82,20 @@
* RuntimeTestCase causes the Runtime to be initialized twice.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ContextSafetyTestCase.java,v 1.6 2001/03/12 00:31:13 jon Exp $
+ * @version $Id: ContextSafetyTestCase.java,v 1.7 2001/03/14 22:05:18 jvanzyl Exp $
*/
public class ContextSafetyTestCase extends TestCase implements TemplateTestBase
{
public ContextSafetyTestCase()
{
super("ContextSafetyTestCase");
+
try
{
- Runtime.setDefaultProperties();
- Runtime.setSourceProperty(
- Runtime.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
- Runtime.init();
+ Velocity.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+
+ Velocity.init();
}
catch (Exception e)
{
1.9 +10 -12
jakarta-velocity/src/java/org/apache/velocity/test/InlineScopeVMTestCase.java
Index: InlineScopeVMTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/InlineScopeVMTestCase.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- InlineScopeVMTestCase.java 2001/03/13 00:10:17 1.8
+++ InlineScopeVMTestCase.java 2001/03/14 22:05:19 1.9
@@ -64,9 +64,9 @@
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
-import org.apache.velocity.test.provider.TestProvider;
+import org.apache.velocity.app.Velocity;
import org.apache.velocity.runtime.Runtime;
-import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.provider.TestProvider;
import org.apache.velocity.util.StringUtils;
import org.apache.velocity.runtime.VelocimacroFactory;
@@ -77,7 +77,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: InlineScopeVMTestCase.java,v 1.8 2001/03/13 00:10:17 dlr Exp $
+ * @version $Id: InlineScopeVMTestCase.java,v 1.9 2001/03/14 22:05:19 jvanzyl Exp $
*/
public class InlineScopeVMTestCase extends TestCase implements TemplateTestBase
{
@@ -96,19 +96,17 @@
* do our properties locally, and just override the ones we want
* changed
*/
-
- Properties p = new Properties();
- p.setProperty(
- RuntimeConstants.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
+ Velocity.setProperty(
+ Velocity.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
- p.setProperty(
- RuntimeConstants.VM_PERM_INLINE_LOCAL, "true");
+ Velocity.setProperty(
+ Velocity.VM_PERM_INLINE_LOCAL, "true");
- p.setProperty(
- "resource.loader.1.resource.path", FILE_RESOURCE_LOADER_PATH);
+ Velocity.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
- Runtime.init(p);
+ Velocity.init();
}
catch (Exception e)
{
1.3 +8 -10
jakarta-velocity/src/java/org/apache/velocity/test/MultipleFileResourcePathTest.java
Index: MultipleFileResourcePathTest.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/MultipleFileResourcePathTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MultipleFileResourcePathTest.java 2001/03/05 11:47:38 1.2
+++ MultipleFileResourcePathTest.java 2001/03/14 22:05:20 1.3
@@ -64,9 +64,9 @@
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
-import org.apache.velocity.test.provider.TestProvider;
+import org.apache.velocity.app.Velocity;
import org.apache.velocity.runtime.Runtime;
-import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.provider.TestProvider;
import org.apache.velocity.util.StringUtils;
import org.apache.velocity.runtime.VelocimacroFactory;
@@ -76,7 +76,7 @@
* Multiple paths in the file resource loader.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: MultipleFileResourcePathTest.java,v 1.2 2001/03/05 11:47:38
jvanzyl Exp $
+ * @version $Id: MultipleFileResourcePathTest.java,v 1.3 2001/03/14 22:05:20
jvanzyl Exp $
*/
public class MultipleFileResourcePathTest extends TestCase
{
@@ -126,15 +126,13 @@
try
{
- Runtime.setDefaultProperties();
-
- Runtime.setSourceProperty(
- Runtime.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH1);
+ Velocity.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH1);
- Runtime.setSourceProperty(
- Runtime.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH2);
+ Velocity.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH2);
- Runtime.init();
+ Velocity.init();
}
catch (Exception e)
{
1.5 +8 -10
jakarta-velocity/src/java/org/apache/velocity/test/TemplateTestSuite.java
Index: TemplateTestSuite.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/TemplateTestSuite.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TemplateTestSuite.java 2001/03/12 03:33:22 1.4
+++ TemplateTestSuite.java 2001/03/14 22:05:22 1.5
@@ -61,7 +61,7 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.app.Velocity;
import junit.framework.TestSuite;
@@ -72,7 +72,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
- * @version $Id: TemplateTestSuite.java,v 1.4 2001/03/12 03:33:22 jon Exp $
+ * @version $Id: TemplateTestSuite.java,v 1.5 2001/03/14 22:05:22 jvanzyl Exp $
*/
public class TemplateTestSuite extends TestSuite implements TemplateTestBase
{
@@ -85,16 +85,14 @@
{
try
{
- Runtime.setDefaultProperties();
- Runtime.setSourceProperty(
- Runtime.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ Velocity.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
- Properties p = new Properties();
- p.setProperty(Runtime.RUNTIME_LOG_ERROR_STACKTRACE, "true");
- p.setProperty(Runtime.RUNTIME_LOG_WARN_STACKTRACE, "true");
- p.setProperty(Runtime.RUNTIME_LOG_INFO_STACKTRACE, "true");
+ Velocity.setProperty(Velocity.RUNTIME_LOG_ERROR_STACKTRACE, "true");
+ Velocity.setProperty(Velocity.RUNTIME_LOG_WARN_STACKTRACE, "true");
+ Velocity.setProperty(Velocity.RUNTIME_LOG_INFO_STACKTRACE, "true");
- Runtime.init(p);
+ Velocity.init();
testProperties = new Properties();
testProperties.load(new FileInputStream(TEST_CASE_PROPERTIES));
1.2 +11 -10
jakarta-velocity/src/java/org/apache/velocity/test/VelocityAppTestCase.java
Index: VelocityAppTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/VelocityAppTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- VelocityAppTestCase.java 2001/03/12 01:25:50 1.1
+++ VelocityAppTestCase.java 2001/03/14 22:05:23 1.2
@@ -64,8 +64,8 @@
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
+import org.apache.velocity.app.Velocity;
import org.apache.velocity.test.provider.TestProvider;
-import org.apache.velocity.runtime.Runtime;
import org.apache.velocity.util.StringUtils;
import org.apache.velocity.app.Velocity;
@@ -77,7 +77,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
- * @version $Id: VelocityAppTestCase.java,v 1.1 2001/03/12 01:25:50 jon Exp $
+ * @version $Id: VelocityAppTestCase.java,v 1.2 2001/03/14 22:05:23 jvanzyl Exp $
*/
public class VelocityAppTestCase extends TestCase implements TemplateTestBase
{
@@ -88,19 +88,20 @@
public VelocityAppTestCase()
{
super("VelocityAppTestCase");
+
try
+ {
+ Velocity.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+
+ Velocity.init();
+ }
+ catch (Exception e)
{
- Runtime.setDefaultProperties();
- Runtime.setSourceProperty(
- Runtime.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
- Runtime.init();
- }
- catch (Exception e)
- {
System.err.println("Cannot setup VelocityAppTestCase!");
e.printStackTrace();
System.exit(1);
- }
+ }
}
public static junit.framework.Test suite()
1.20 +7 -29
jakarta-velocity/src/java/org/apache/velocity/test/misc/Test.java
Index: Test.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/misc/Test.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Test.java 2001/03/12 02:01:32 1.19
+++ Test.java 2001/03/14 22:05:33 1.20
@@ -86,7 +86,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Test.java,v 1.19 2001/03/12 02:01:32 jon Exp $
+ * @version $Id: Test.java,v 1.20 2001/03/14 22:05:33 jvanzyl Exp $
*/
public class Test
{
@@ -121,49 +121,27 @@
try
{
/*
- * this is another way to do properties when initializing Runtime.
- * make a Properties
- */
-
- Properties p = new Properties();
-
- /*
- * now, if you want to, load it from a file (or whatever)
- */
-
- try
- {
- FileInputStream fis = new FileInputStream(
- new File("velocity.properties" ));
-
- if( fis != null)
- p.load( fis );
- }
- catch (Exception ex)
- {
- /* no worries. no file... */
- }
-
- /*
* add some individual properties if you wish
*/
- p.setProperty(Runtime.RUNTIME_LOG_ERROR_STACKTRACE, "true");
- p.setProperty(Runtime.RUNTIME_LOG_WARN_STACKTRACE, "true");
- p.setProperty(Runtime.RUNTIME_LOG_INFO_STACKTRACE, "true");
+ Velocity.setProperty(Velocity.RUNTIME_LOG_ERROR_STACKTRACE, "true");
+ Velocity.setProperty(Velocity.RUNTIME_LOG_WARN_STACKTRACE, "true");
+ Velocity.setProperty(Velocity.RUNTIME_LOG_INFO_STACKTRACE, "true");
/*
* and now call init
*/
- Runtime.init(p);
+ Velocity.init();
/*
* now, do what we want to do. First, get the Template
*/
if (templateFile == null)
+ {
templateFile = "examples/example.vm";
+ }
Template template = null;