You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by by...@apache.org on 2009/03/11 21:37:24 UTC
svn commit: r752606 - in
/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test:
BaseTestCase.java VMContextLocalscopeTestCase.java
Author: byron
Date: Wed Mar 11 20:37:23 2009
New Revision: 752606
URL: http://svn.apache.org/viewvc?rev=752606&view=rev
Log:
Add missing class members to test cases
Modified:
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/VMContextLocalscopeTestCase.java
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java?rev=752606&r1=752605&r2=752606&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java Wed Mar 11 20:37:23 2009
@@ -50,6 +50,7 @@
protected VelocityContext context;
protected boolean DEBUG = false;
protected TestLogChute log;
+ protected String stringRepoName = "string.repo";
public BaseTestCase(String name)
{
@@ -73,6 +74,13 @@
log.setEnabledLevel(TestLogChute.INFO_ID);
log.setSystemErrLevel(TestLogChute.WARN_ID);
engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, log);
+
+ // use string resource loader by default, instead of file
+ engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "file,string");
+ engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName());
+ engine.addProperty("string.resource.loader.repository.name", stringRepoName);
+ engine.addProperty("string.resource.loader.repository.static", "false");
+
setUpEngine(engine);
context = new VelocityContext();
@@ -152,7 +160,7 @@
public void testBase()
{
- if (DEBUG)
+ if (DEBUG && engine != null)
{
assertSchmoo("");
assertSchmoo("abc\n123");
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/VMContextLocalscopeTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/VMContextLocalscopeTestCase.java?rev=752606&r1=752605&r2=752606&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/VMContextLocalscopeTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/VMContextLocalscopeTestCase.java Wed Mar 11 20:37:23 2009
@@ -1,5 +1,5 @@
-package org.apache.velocity.test;
-
+package org.apache.velocity.test;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,57 +18,56 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.context.InternalContextAdapterImpl;
-import org.apache.velocity.context.ProxyVMContext;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.RuntimeInstance;
-
-/**
- * Tests scope of velocimacros with localscope setting.
- *
- * @author <a href="mailto:stephenh@chase3000.com">Stephen Habermann</a>
- * @version $Id$
- */
-public class VMContextLocalscopeTestCase extends BaseTestCase {
-
- public VMContextLocalscopeTestCase(String name)
- {
- super(name);
- }
-
- public void testViaEval()
- {
- engine.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, Boolean.TRUE);
- assertEvalEquals("$a", "#macro(a)#set($a = 'b')#end#a$a");
- context.put("b", "b");
- assertEvalEquals("b", "#macro(b)$b#set($b = 'c')#end#b");
- assertContextValue("b", "b");
- }
-
- public void testLocalscopePutDoesntLeakButGetDoes()
- {
- RuntimeInstance instance = new RuntimeInstance();
- instance.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, Boolean.TRUE);
- instance.init();
-
- VelocityContext base = new VelocityContext();
- base.put("outsideVar", "value1");
-
- ProxyVMContext vm = new ProxyVMContext(new InternalContextAdapterImpl(base), true);
-
- // New variable put doesn't leak
- assertNull(base.get("newLocalVar"));
- assertEquals("value2", vm.get("newLocalVar"));
-
- // But we can still get to "outsideVar"
- assertEquals("value1", vm.get("outsideVar"));
-
- // If we decide to try and set outsideVar it won't leak
- vm.put("outsideVar", "value3");
- assertEquals("value3", vm.get("outsideVar"));
- assertEquals("value1", base.get("outsideVar"));
- }
-
-}
+
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.context.InternalContextAdapterImpl;
+import org.apache.velocity.context.ProxyVMContext;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeInstance;
+
+/**
+ * Tests scope of velocimacros with localscope setting.
+ *
+ * @author <a href="mailto:stephenh@chase3000.com">Stephen Habermann</a>
+ * @version $Id$
+ */
+public class VMContextLocalscopeTestCase extends BaseTestCase {
+
+ public VMContextLocalscopeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testViaEval()
+ {
+ engine.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, Boolean.TRUE);
+ assertEvalEquals("$a", "#macro(a)#set($a = 'b')#end#a$a");
+ context.put("b", "b");
+ assertEvalEquals("b", "#macro(b)$b#set($b = 'c')#end#b");
+ assertContextValue("b", "b");
+ }
+
+ public void testLocalscopePutDoesntLeakButGetDoes()
+ {
+ engine.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, Boolean.TRUE);
+
+ VelocityContext base = new VelocityContext();
+ base.put("outsideVar", "value1");
+
+ ProxyVMContext vm = new ProxyVMContext(new InternalContextAdapterImpl(base), true);
+ vm.put("newLocalVar", "value2");
+
+ // New variable put doesn't leak
+ assertNull(base.get("newLocalVar"));
+ assertEquals("value2", vm.get("newLocalVar"));
+
+ // But we can still get to "outsideVar"
+ assertEquals("value1", vm.get("outsideVar"));
+
+ // If we decide to try and set outsideVar it won't leak
+ vm.put("outsideVar", "value3");
+ assertEquals("value3", vm.get("outsideVar"));
+ assertEquals("value1", base.get("outsideVar"));
+ }
+
+}