From f557075071a8dd848b36220f2a904a2f84e73e11 Mon Sep 17 00:00:00 2001 From: Antonio Petrelli Date: Thu, 1 Jul 2010 19:00:14 +0000 Subject: VELOCITYSB-4 Renamed directories of modules. git-svn-id: https://svn.apache.org/repos/asf/velocity/sandbox/maven-reorg/engine/trunk@959747 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/velocity/test/VelocityAppTestCase.java | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java (limited to 'velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java') diff --git a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java new file mode 100644 index 00000000..f858f084 --- /dev/null +++ b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java @@ -0,0 +1,93 @@ +package org.apache.velocity.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.StringWriter; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.test.misc.TestLogChute; + +/** + * This class is intended to test the app.Velocity.java class. + * + * @author Geir Magnusson Jr. + * @author Jon S. Stevens + * @version $Id$ + */ +public class VelocityAppTestCase extends BaseTestCase implements TemplateTestBase +{ + private StringWriter compare1 = new StringWriter(); + private String input1 = "My name is $name -> $Floog"; + private String result1 = "My name is jason -> floogie woogie"; + + public VelocityAppTestCase(String name) + { + super(name); + } + + public void setUp() + throws Exception + { + Velocity.setProperty( + Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); + + Velocity.setProperty( + Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + + Velocity.init(); + } + + public static Test suite() + { + return new TestSuite(VelocityAppTestCase.class); + } + + /** + * Runs the test. + */ + public void testVelocityApp () + throws Exception + { + VelocityContext context = new VelocityContext(); + context.put("name", "jason"); + context.put("Floog", "floogie woogie"); + + Velocity.evaluate(context, compare1, "evaltest", input1); + +/* + * @todo FIXME: Not tested right now. + * + * StringWriter result2 = new StringWriter(); + * Velocity.mergeTemplate("mergethis.vm", context, result2); + * + * StringWriter result3 = new StringWriter(); + * Velocity.invokeVelocimacro("floog", "test", new String[2], + * context, result3); + */ + if (!result1.equals(compare1.toString())) + { + fail("Output incorrect."); + } + } +} -- cgit v1.2.3 From 32273e3c5dc553708106a3617b2c40914a0aba7b Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Mon, 31 Aug 2015 21:06:34 +0000 Subject: [engine] switch to slf4j logging facade git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1700350 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/velocity/test/VelocityAppTestCase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java') diff --git a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java index f858f084..a7c1808a 100644 --- a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java +++ b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java @@ -26,7 +26,7 @@ import junit.framework.TestSuite; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * This class is intended to test the app.Velocity.java class. @@ -53,7 +53,7 @@ public class VelocityAppTestCase extends BaseTestCase implements TemplateTestBas Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } -- cgit v1.2.3 From 92d42e6fadb5e554b5223c93169bb4850da31b4c Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sun, 17 Jul 2016 23:33:09 +0000 Subject: [engine] keep macros in defining templates (applied reviewed patch from VELOCITY-797, fixes VELOCITY-797 and VELOCITY-776); plus some code cleaning that was in the patch git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1753137 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/velocity/test/VelocityAppTestCase.java | 67 +++++++++------------- 1 file changed, 27 insertions(+), 40 deletions(-) (limited to 'velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java') diff --git a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java index a7c1808a..7c774dbf 100644 --- a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java +++ b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java @@ -19,14 +19,10 @@ package org.apache.velocity.test; * under the License. */ -import java.io.StringWriter; - -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogger; + +import java.io.StringWriter; /** * This class is intended to test the app.Velocity.java class. @@ -46,48 +42,39 @@ public class VelocityAppTestCase extends BaseTestCase implements TemplateTestBas super(name); } - public void setUp() + public void testVelocityApp() throws Exception { - Velocity.setProperty( - Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); + engine.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); + engine.init(); - Velocity.setProperty( - Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); - - Velocity.init(); - } - - public static Test suite() - { - return new TestSuite(VelocityAppTestCase.class); - } + // the usage of engine here is equivalent to using static calls to Velocity. class - /** - * Runs the test. - */ - public void testVelocityApp () - throws Exception - { VelocityContext context = new VelocityContext(); context.put("name", "jason"); context.put("Floog", "floogie woogie"); - Velocity.evaluate(context, compare1, "evaltest", input1); + String cmp = "Hello jason! Nice floogie woogie!"; -/* - * @todo FIXME: Not tested right now. - * - * StringWriter result2 = new StringWriter(); - * Velocity.mergeTemplate("mergethis.vm", context, result2); - * - * StringWriter result3 = new StringWriter(); - * Velocity.invokeVelocimacro("floog", "test", new String[2], - * context, result3); - */ - if (!result1.equals(compare1.toString())) - { - fail("Output incorrect."); - } + engine.evaluate(context, compare1, "evaltest", input1); + if (!result1.equals(compare1.toString())) + { + fail("Output 1 incorrect."); + } + + StringWriter result2 = new StringWriter(); + engine.mergeTemplate("mergethis.vm", "UTF-8", context, result2); + if (!result2.toString().equals(cmp)) + { + fail("Output 2 incorrect."); + } + + StringWriter result3 = new StringWriter(); + engine.invokeVelocimacro("floog", "test", new String[]{"name", "Floog"}, context, result3); + + if (!result3.toString().equals(cmp)) + { + fail("Output 3 incorrect."); + } } } -- cgit v1.2.3 From 2880a3c02ddc0b4aa8990c04d2580ea9db0d2acf Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Thu, 26 Jan 2017 01:57:00 +0000 Subject: [engine] fix trailing whitespaces git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1780307 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/org/apache/velocity/test/VelocityAppTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java') diff --git a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java index 7c774dbf..ecc9f8fc 100644 --- a/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java +++ b/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java @@ -16,7 +16,7 @@ package org.apache.velocity.test; * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import org.apache.velocity.VelocityContext; -- cgit v1.2.3