Author: wglass
Date: Tue Nov 3 01:29:30 2009
New Revision: 832247
URL: http://svn.apache.org/viewvc?rev=832247&view=rev
Log:
Changed test cases to use VelocityEngine instead of Velocity, so they will work
in Eclipse. (within the same JVM). There's a few that will still fail in
eclipse which rely on special classpath elements or require the singleton
Velocity class.
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
Tue Nov 3 01:29:30 2009
@@ -29,6 +29,8 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeSingleton;
import org.apache.velocity.test.misc.TestLogChute;
@@ -71,6 +73,8 @@
*/
private static final String COMPARE_DIR = TEST_COMPARE_DIR +
"/absolute/compare";
+ VelocityEngine engine;
+
/**
* Default constructor.
*/
@@ -82,15 +86,16 @@
{
assureResultsDirectoryExists(RESULTS_DIR);
-
+ engine = new VelocityEngine();
+
// signify we want to use an absolute path
- Velocity.addProperty(
- Velocity.FILE_RESOURCE_LOADER_PATH, "");
+ engine.addProperty(
+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "");
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
catch (Exception e)
{
@@ -116,7 +121,7 @@
System.out.println("Retrieving template at absolute path: " + f);
- Template template1 = RuntimeSingleton.getTemplate(f);
+ Template template1 = engine.getTemplate(f);
FileOutputStream fos1 =
new FileOutputStream (
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
Tue Nov 3 01:29:30 2009
@@ -29,12 +29,12 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.app.event.EventCartridge;
import org.apache.velocity.app.event.IncludeEventHandler;
import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.RuntimeSingleton;
import org.apache.velocity.test.misc.TestLogChute;
import org.apache.velocity.util.RuntimeServicesAware;
@@ -85,6 +85,8 @@
private int EventHandlerBehavior = PASS_THROUGH;
+ VelocityEngine engine;
+
/**
* Default constructor.
*/
@@ -98,13 +100,15 @@
{
assureResultsDirectoryExists(RESULTS_DIR);
- Velocity.addProperty(
- Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ engine = new VelocityEngine();
+
+ engine.addProperty(
+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH);
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
@@ -121,13 +125,13 @@
public void testIncludeEventHandling ()
throws Exception
{
- Template template1 = RuntimeSingleton.getTemplate(
+ Template template1 = engine.getTemplate(
getFileName(null, "test1", TMPL_FILE_EXT));
- Template template2 = RuntimeSingleton.getTemplate(
+ Template template2 = engine.getTemplate(
getFileName(null, "subdir/test2", TMPL_FILE_EXT));
- Template template3 = RuntimeSingleton.getTemplate(
+ Template template3 = engine.getTemplate(
getFileName(null, "test3", TMPL_FILE_EXT));
FileOutputStream fos1 =
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java
Tue Nov 3 01:29:30 2009
@@ -29,8 +29,8 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.test.misc.TestLogChute;
/**
@@ -42,6 +42,7 @@
*/
public class InlineScopeVMTestCase extends BaseTestCase implements
TemplateTestBase
{
+ VelocityEngine engine;
public InlineScopeVMTestCase(String name)
{
super(name);
@@ -50,24 +51,21 @@
public void setUp()
throws Exception
{
- /*
- * do our properties locally, and just override the ones we want
- * changed
- */
-
- Velocity.setProperty(
- Velocity.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
+ engine = new VelocityEngine();
+
+ engine.setProperty(
+ RuntimeConstants.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
- Velocity.setProperty(
- Velocity.VM_PERM_INLINE_LOCAL, "true");
+ engine.setProperty(
+ RuntimeConstants.VM_PERM_INLINE_LOCAL, "true");
- Velocity.setProperty(
- Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ engine.setProperty(
+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH);
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
public static Test suite ()
@@ -88,10 +86,10 @@
* vm_test2 uses a local VM and vm_test1 doesn't
*/
- Template template2 = RuntimeSingleton.getTemplate(
+ Template template2 = engine.getTemplate(
getFileName(null, "vm_test2", TMPL_FILE_EXT));
- Template template1 = RuntimeSingleton.getTemplate(
+ Template template1 = engine.getTemplate(
getFileName(null, "vm_test1", TMPL_FILE_EXT));
FileOutputStream fos1 =
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
Tue Nov 3 01:29:30 2009
@@ -19,16 +19,16 @@
* under the License.
*/
+import java.io.StringWriter;
+
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.test.misc.TestLogChute;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-
-import java.io.*;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.misc.TestLogChute;
/**
* Make sure that a forward referenced macro inside another macro definition
does
@@ -62,6 +62,8 @@
*/
private TestLogChute logger = new TestLogChute();
+ VelocityEngine engine;
+
/**
* Default constructor.
*/
@@ -75,16 +77,18 @@
{
assureResultsDirectoryExists(RESULTS_DIR);
+ engine = new VelocityEngine();
+
// use Velocity.setProperty (instead of properties file) so that we
can use actual instance of log
- Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER,"file");
- Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH );
-
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID,"true");
+ engine.setProperty(RuntimeConstants.RESOURCE_LOADER,"file");
+ engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH );
+
engine.setProperty(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID,"true");
// actual instance of logger
logger = new TestLogChute(true, false);
- Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,logger);
- Velocity.setProperty(TestLogChute.TEST_LOGGER_LEVEL, "debug");
- Velocity.init();
+ engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,logger);
+ engine.setProperty(TestLogChute.TEST_LOGGER_LEVEL, "debug");
+ engine.init();
}
public static Test suite()
@@ -96,7 +100,7 @@
throws Exception
{
VelocityContext context = new VelocityContext();
- Template template = Velocity.getTemplate("macros.vm");
+ Template template = engine.getTemplate("macros.vm");
// try to get only messages during merge
logger.startCapture();
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java
Tue Nov 3 01:29:30 2009
@@ -29,7 +29,8 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.test.misc.TestLogChute;
/**
@@ -72,6 +73,8 @@
*/
private static final String COMPARE_DIR = TEST_COMPARE_DIR +
"/multiloader/compare";
+ VelocityEngine engine;
+
/**
* Default constructor.
*/
@@ -83,52 +86,54 @@
public void setUp()
throws Exception
{
+ engine = new VelocityEngine();
+
assureResultsDirectoryExists(RESULTS_DIR);
/*
* Set up the file loader.
*/
- Velocity.setProperty(Velocity.RESOURCE_LOADER, "file");
+ engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "file");
- Velocity.setProperty(
- Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+ engine.setProperty(
+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH);
- Velocity.addProperty(Velocity.RESOURCE_LOADER, "classpath");
+ engine.addProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
- Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
+ engine.addProperty(RuntimeConstants.RESOURCE_LOADER, "jar");
/*
* Set up the classpath loader.
*/
- Velocity.setProperty(
- "classpath." + Velocity.RESOURCE_LOADER + ".class",
+ engine.setProperty(
+ "classpath." + RuntimeConstants.RESOURCE_LOADER + ".class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
- Velocity.setProperty(
- "classpath." + Velocity.RESOURCE_LOADER + ".cache", "false");
+ engine.setProperty(
+ "classpath." + RuntimeConstants.RESOURCE_LOADER + ".cache",
"false");
- Velocity.setProperty(
- "classpath." + Velocity.RESOURCE_LOADER +
".modificationCheckInterval",
+ engine.setProperty(
+ "classpath." + RuntimeConstants.RESOURCE_LOADER +
".modificationCheckInterval",
"2");
/*
* setup the Jar loader
*/
- Velocity.setProperty(
- "jar." + Velocity.RESOURCE_LOADER + ".class",
+ engine.setProperty(
+ "jar." + RuntimeConstants.RESOURCE_LOADER +
".class",
"org.apache.velocity.runtime.resource.loader.JarResourceLoader");
- Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER + ".path",
+ engine.setProperty( "jar." + RuntimeConstants.RESOURCE_LOADER +
".path",
"jar:file:" + FILE_RESOURCE_LOADER_PATH +
"/test2.jar" );
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
public static Test suite ()
@@ -150,18 +155,18 @@
/*
* Template to find with the file loader.
*/
- Template template1 = Velocity.getTemplate(
+ Template template1 = engine.getTemplate(
getFileName(null, "path1", TMPL_FILE_EXT));
/*
* Template to find with the classpath loader.
*/
- Template template2 = Velocity.getTemplate("template/test1." +
TMPL_FILE_EXT);
+ Template template2 = engine.getTemplate("template/test1." +
TMPL_FILE_EXT);
/*
* Template to find with the jar loader
*/
- Template template3 = Velocity.getTemplate("template/test2." +
TMPL_FILE_EXT);
+ Template template3 = engine.getTemplate("template/test2." +
TMPL_FILE_EXT);
/*
* and the results files
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
Tue Nov 3 01:29:30 2009
@@ -29,8 +29,8 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.test.misc.TestLogChute;
/**
@@ -64,6 +64,8 @@
*/
private static final String COMPARE_DIR = TEST_COMPARE_DIR +
"/multi/compare";
+ VelocityEngine engine;
+
/**
* Default constructor.
*/
@@ -82,16 +84,18 @@
{
assureResultsDirectoryExists(RESULTS_DIR);
- Velocity.addProperty(
- Velocity.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH1);
+ engine = new VelocityEngine();
+
+ engine.addProperty(
+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH1);
- Velocity.addProperty(
- Velocity.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH2);
+ engine.addProperty(
+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
FILE_RESOURCE_LOADER_PATH2);
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
/**
@@ -100,10 +104,10 @@
public void testMultipleFileResources ()
throws Exception
{
- Template template1 = RuntimeSingleton.getTemplate(
+ Template template1 = engine.getTemplate(
getFileName(null, "path1", TMPL_FILE_EXT));
- Template template2 = RuntimeSingleton.getTemplate(
+ Template template2 = engine.getTemplate(
getFileName(null, "path2", TMPL_FILE_EXT));
FileOutputStream fos1 =
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
Tue Nov 3 01:29:30 2009
@@ -57,8 +57,14 @@
Velocity.init();
StringResourceRepository repo = getRepo(null, null);
- repo.putStringResource("foo", "This is $foo");
- repo.putStringResource("bar", "This is $bar");
+
+ // this will fail when run as part of suite of tests in one process
+ // but it's only required for several tests
+ if (repo != null)
+ {
+ repo.putStringResource("foo", "This is $foo");
+ repo.putStringResource("bar", "This is $bar");
+ }
context = new VelocityContext();
context.put("foo", "wonderful!");
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
Tue Nov 3 01:29:30 2009
@@ -29,10 +29,10 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.test.misc.TestLogChute;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
+import org.apache.velocity.test.misc.TestLogChute;
/**
* Multiple paths in the file resource loader.
@@ -52,6 +52,8 @@
*/
private static final String COMPARE_DIR = TEST_COMPARE_DIR +
"/stringloader/compare";
+ VelocityEngine engine;
+
/**
* Default constructor.
*/
@@ -70,14 +72,16 @@
{
assureResultsDirectoryExists(RESULTS_DIR);
- Velocity.setProperty(Velocity.RESOURCE_LOADER, "string");
- Velocity.addProperty("string.resource.loader.class",
StringResourceLoader.class.getName());
-
Velocity.addProperty("string.resource.loader.modificationCheckInterval", "1");
+ engine = new VelocityEngine();
+
+ engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "string");
+ engine.addProperty("string.resource.loader.class",
StringResourceLoader.class.getName());
+ engine.addProperty("string.resource.loader.modificationCheckInterval",
"1");
// Silence the logger.
- Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
public void testSimpleTemplate()
@@ -85,7 +89,7 @@
{
StringResourceLoader.getRepository().putStringResource("simpletemplate.vm",
"This is a test for ${foo}");
- Template template = RuntimeSingleton.getTemplate(getFileName(null,
"simpletemplate", TMPL_FILE_EXT));
+ Template template = engine.getTemplate(getFileName(null,
"simpletemplate", TMPL_FILE_EXT));
FileOutputStream fos =
new FileOutputStream (
@@ -113,7 +117,7 @@
StringResourceLoader.getRepository().putStringResource("multi1.vm", "I
am the $first template.");
StringResourceLoader.getRepository().putStringResource("multi2.vm", "I
am the $second template.");
- Template template1 = RuntimeSingleton.getTemplate(getFileName(null,
"multi1", TMPL_FILE_EXT));
+ Template template1 = engine.getTemplate(getFileName(null, "multi1",
TMPL_FILE_EXT));
FileOutputStream fos =
new FileOutputStream (
@@ -129,7 +133,7 @@
writer.flush();
writer.close();
- Template template2 = RuntimeSingleton.getTemplate(getFileName(null,
"multi2", TMPL_FILE_EXT));
+ Template template2 = engine.getTemplate(getFileName(null, "multi2",
TMPL_FILE_EXT));
fos = new FileOutputStream (
getFileName(RESULTS_DIR, "multi2", RESULT_FILE_EXT));
@@ -160,7 +164,7 @@
{
StringResourceLoader.getRepository().putStringResource("change.vm", "I
am the $first template.");
- Template template = RuntimeSingleton.getTemplate(getFileName(null,
"change", TMPL_FILE_EXT));
+ Template template = engine.getTemplate(getFileName(null, "change",
TMPL_FILE_EXT));
FileOutputStream fos =
new FileOutputStream (
@@ -178,7 +182,7 @@
StringResourceLoader.getRepository().putStringResource("change.vm", "I
am the $second template.");
Thread.sleep(2000L);
- template = RuntimeSingleton.getTemplate(getFileName(null, "change",
TMPL_FILE_EXT));
+ template = engine.getTemplate(getFileName(null, "change",
TMPL_FILE_EXT));
fos = new FileOutputStream (
getFileName(RESULTS_DIR, "change2", RESULT_FILE_EXT));
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java
Tue Nov 3 01:29:30 2009
@@ -26,8 +26,9 @@
import junit.framework.TestSuite;
import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.MacroOverflowException;
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.test.misc.TestLogChute;
/**
@@ -44,6 +45,8 @@
private String template3 = "#macro(baz $a)#set($a = $a +
1)$a#inner($a)#end#macro(inner $b)#baz($b)#end#baz(0)";
private String template4 = "#macro(bad $a)#set($a = $a +
1)$a#inside($a)#end#macro(inside $b)#loop($b)#end#macro(loop
$c)#bad($c)#end#bad(0)";
+ VelocityEngine engine = new VelocityEngine();
+
public VelocimacroTestCase(String name)
{
super(name);
@@ -55,11 +58,11 @@
/*
* setup local scope for templates
*/
- Velocity.setProperty( Velocity.VM_PERM_INLINE_LOCAL, Boolean.TRUE);
- Velocity.setProperty( Velocity.VM_MAX_DEPTH, new Integer(5));
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.setProperty( RuntimeConstants.VM_PERM_INLINE_LOCAL,
Boolean.TRUE);
+ engine.setProperty( RuntimeConstants.VM_MAX_DEPTH, new Integer(5));
+ engine.setProperty(
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.init();
}
public static Test suite()
@@ -76,7 +79,7 @@
VelocityContext context = new VelocityContext();
StringWriter writer = new StringWriter();
- Velocity.evaluate(context, writer, "vm_chain1", template1);
+ engine.evaluate(context, writer, "vm_chain1", template1);
String out = writer.toString();
@@ -97,7 +100,7 @@
try
{
- Velocity.evaluate(context, writer, "vm_chain2", template2);
+ engine.evaluate(context, writer, "vm_chain2", template2);
fail("Did not exceed max macro call depth as expected");
}
catch (MacroOverflowException e)
@@ -109,7 +112,7 @@
try
{
- Velocity.evaluate(context, writer, "vm_chain3", template3);
+ engine.evaluate(context, writer, "vm_chain3", template3);
fail("Did not exceed max macro call depth as expected");
}
catch (MacroOverflowException e)
@@ -121,7 +124,7 @@
try
{
- Velocity.evaluate(context, writer, "vm_chain4", template4);
+ engine.evaluate(context, writer, "vm_chain4", template4);
fail("Did not exceed max macro call depth as expected");
}
catch (MacroOverflowException e)
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
Tue Nov 3 01:29:30 2009
@@ -21,10 +21,10 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.test.misc.TestLogChute;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.test.misc.TestLogChute;
/**
* Test Case for <a
href="https://issues.apache.org/jira/browse/VELOCITY-580">Velocity Issue
580</a>.
@@ -56,6 +56,8 @@
*/
private static final String COMPARE_DIR = TEST_COMPARE_DIR +
"/issues/velocity-580/compare";
+ VelocityEngine engine;
+
public Velocity580TestCase(final String name) throws Exception
{
super(name);
@@ -71,11 +73,13 @@
assureResultsDirectoryExists(RESULTS_DIR);
- Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR);
+ engine = new VelocityEngine();
+
+ engine.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
TEMPLATE_DIR);
- Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
public void testVelocity580() throws Exception
@@ -85,7 +89,7 @@
protected Template executeTest(final String templateName) throws Exception
{
- Template template = RuntimeSingleton.getTemplate(templateName);
+ Template template = engine.getTemplate(templateName);
FileOutputStream fos = new FileOutputStream(getFileName(RESULTS_DIR,
templateName, RESULT_FILE_EXT));
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
Tue Nov 3 01:29:30 2009
@@ -33,9 +33,11 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.test.misc.TestLogChute;
import org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader;
+import org.apache.velocity.test.misc.TestLogChute;
public class DataSourceResourceLoaderTestCase
@@ -77,6 +79,8 @@
*/
private String UNICODE_TEMPLATE_NAME = "testUnicode";
+ VelocityEngine engine;
+
public DataSourceResourceLoaderTestCase(final String name)
throws Exception
{
@@ -100,19 +104,21 @@
DataSourceResourceLoader rl = new DataSourceResourceLoader();
rl.setDataSource(ds);
+ engine = new VelocityEngine();
+
// pass in an instance to Velocity
- Velocity.addProperty( "resource.loader", "ds" );
- Velocity.setProperty( "ds.resource.loader.instance", rl );
+ engine.addProperty( "resource.loader", "ds" );
+ engine.setProperty( "ds.resource.loader.instance", rl );
- Velocity.setProperty( "ds.resource.loader.resource.table",
"velocity_template");
- Velocity.setProperty( "ds.resource.loader.resource.keycolumn",
"id");
- Velocity.setProperty( "ds.resource.loader.resource.templatecolumn",
"def");
- Velocity.setProperty( "ds.resource.loader.resource.timestampcolumn",
"timestamp");
+ engine.setProperty( "ds.resource.loader.resource.table",
"velocity_template");
+ engine.setProperty( "ds.resource.loader.resource.keycolumn",
"id");
+ engine.setProperty( "ds.resource.loader.resource.templatecolumn",
"def");
+ engine.setProperty( "ds.resource.loader.resource.timestampcolumn",
"timestamp");
Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+ RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
- Velocity.init();
+ engine.init();
}
public void setUpUnicode()
@@ -137,7 +143,7 @@
public void testUnicode()
throws Exception
{
- Template template =
RuntimeSingleton.getTemplate(UNICODE_TEMPLATE_NAME);
+ Template template = engine.getTemplate(UNICODE_TEMPLATE_NAME);
Writer writer = new StringWriter();
VelocityContext context = new VelocityContext();
@@ -188,7 +194,7 @@
protected Template executeTest(final String templateName)
throws Exception
{
- Template template = RuntimeSingleton.getTemplate(templateName);
+ Template template = engine.getTemplate(templateName);
FileOutputStream fos =
new FileOutputStream (
Modified:
velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java?rev=832247&r1=832246&r2=832247&view=diff
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
(original)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
Tue Nov 3 01:29:30 2009
@@ -19,21 +19,30 @@
* under the License.
*/
+import java.io.StringWriter;
+
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.test.misc.TestLogChute;
-import org.apache.velocity.util.introspection.*;
-import org.apache.velocity.test.BaseTestCase;
-import org.apache.velocity.VelocityContext;
-import java.io.StringWriter;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.test.misc.TestLogChute;
+import org.apache.velocity.util.introspection.AbstractChainableUberspector;
+import org.apache.velocity.util.introspection.Info;
+import org.apache.velocity.util.introspection.UberspectImpl;
+import org.apache.velocity.util.introspection.VelPropertyGet;
+import org.apache.velocity.util.introspection.VelPropertySet;
/**
* Tests uberspectors chaining
*/
-public class ChainedUberspectorsTestCase extends BaseTestCase {
+public class ChainedUberspectorsTestCase extends BaseTestCase
+{
+ VelocityEngine engine;
+
public ChainedUberspectorsTestCase(String name)
throws Exception
{
@@ -48,11 +57,13 @@
public void setUp()
throws Exception
{
- Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
-
Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.util.introspection.UberspectImpl");
-
Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$ChainedUberspector");
-
Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$LinkedUberspector");
- Velocity.init();
+ engine = new VelocityEngine();
+
+ engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
TestLogChute.class.getName());
+
engine.addProperty(RuntimeConstants.UBERSPECT_CLASSNAME,"org.apache.velocity.util.introspection.UberspectImpl");
+
engine.addProperty(RuntimeConstants.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$ChainedUberspector");
+
engine.addProperty(RuntimeConstants.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$LinkedUberspector");
+ engine.init();
}
public void tearDown()
@@ -66,17 +77,17 @@
context.put("foo",new Foo());
StringWriter writer = new StringWriter();
- Velocity.evaluate(context,writer,"test","$foo.zeMethod()");
+ engine.evaluate(context,writer,"test","$foo.zeMethod()");
assertEquals(writer.toString(),"ok");
- Velocity.evaluate(context,writer,"test","#set($foo.foo =
'someValue')");
+ engine.evaluate(context,writer,"test","#set($foo.foo = 'someValue')");
writer = new StringWriter();
- Velocity.evaluate(context,writer,"test","$foo.bar");
+ engine.evaluate(context,writer,"test","$foo.bar");
assertEquals(writer.toString(),"someValue");
writer = new StringWriter();
- Velocity.evaluate(context,writer,"test","$foo.foo");
+ engine.evaluate(context,writer,"test","$foo.foo");
assertEquals(writer.toString(),"someValue");
}