I usually try to do it. Sorry if I forgot for some of them.
But for this one, that's a fix for a problem I discovered while coding
(the testcase needed an "mvn clean" to work).
The testcase itself, added in commit 1753201 yesterday, contains a
reference to the issue.
Not every commit refers to an issue.
On 19/07/2016 22:37, Sergiu Dumitriu wrote:
It is recommended to include the jira issue id in the commit message, so
that jira can find the right commits for an issue, and a commit can quickly
identify the relevant discussion.
On Jul 19, 2016 16:27, <cbris...@apache.org> wrote:
Author: cbrisson
Date: Tue Jul 19 20:26:58 2016
New Revision: 1753422
URL: http://svn.apache.org/viewvc?rev=1753422&view=rev
Log:
[engine] fix MacroAutoReloadTestCase
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MacroAutoReloadTestCase.java
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MacroAutoReloadTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MacroAutoReloadTestCase.java?rev=1753422&r1=1753421&r2=1753422&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MacroAutoReloadTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MacroAutoReloadTestCase.java
Tue Jul 19 20:26:58 2016
@@ -22,17 +22,22 @@ package org.apache.velocity.test;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
import org.apache.velocity.test.misc.TestLogger;
+import java.io.File;
import java.io.FileWriter;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
/**
* This class tests the velocimacro.library.autoreload functionality, and
issue VELOCITY-
*/
public class MacroAutoReloadTestCase extends BaseTestCase
{
+ private final String RELOAD_TEMPLATE_PATH = TEST_COMPARE_DIR +
"/reload";
+
public MacroAutoReloadTestCase(String name)
{
super(name);
@@ -40,6 +45,9 @@ public class MacroAutoReloadTestCase ext
protected void setUp() throws Exception
{
+ // always copy macros library before modifying it, to ensure
successive tests will pass
+ Files.copy(FileSystems.getDefault().getPath(RELOAD_TEMPLATE_PATH
+ "/macros.vtl"), FileSystems.getDefault().getPath(RELOAD_TEMPLATE_PATH +
"/macros2.vtl"), StandardCopyOption.REPLACE_EXISTING);
+
engine = new VelocityEngine();
//by default, make the engine's log output go to the test-report
@@ -48,44 +56,47 @@ public class MacroAutoReloadTestCase ext
// use file resource loader
engine.setProperty(RuntimeConstants.RESOURCE_LOADER,
"file,string");
- engine.addProperty("file.resource.loader.path", TEST_COMPARE_DIR
+ "/reload");
- engine.addProperty("velocimacro.library", "macros.vtl");
+ engine.addProperty("file.resource.loader.path",
RELOAD_TEMPLATE_PATH);
+ engine.addProperty("velocimacro.library", "macros2.vtl");
engine.addProperty("velocimacro.library.autoreload", "true");
engine.addProperty("file.resource.loader.cache", "false");
engine.addProperty("string.resource.loader.class",
StringResourceLoader.class.getName());
engine.addProperty("string.resource.loader.repository.name",
"stringRepo");
engine.addProperty("string.resource.loader.repository.static",
"false");
-
- setUpEngine(engine);
-
context = new VelocityContext();
- setUpContext(context);
}
public void testChangedMacro() throws Exception
{
String template = "#foo('hip')";
- String result = "hop_hip";
- assertEvalEquals(result, template);
+ assertEvalEquals("hop_hip", template);
- FileWriter writer = new FileWriter(TEST_COMPARE_DIR +
"/reload/macros.vtl");
+ FileWriter writer = new FileWriter(RELOAD_TEMPLATE_PATH +
"/macros2.vtl");
writer.write("#macro(foo $txt)hip_$txt#{end}");
writer.close();
-
- result = "hip_hip";
- assertEvalEquals(result, template);
+ // last modified timestamps resolution is one second before Java
8,
+ // so force reloading by setting a file date in the future
+ File macros2 = new File(TEST_COMPARE_DIR + "/reload/macros2.vtl");
+ macros2.setLastModified(macros2.lastModified() + 1000);
+
+ assertEvalEquals("hip_hip", template);
}
public void testNewMacro() throws Exception
{
- FileWriter writer = new FileWriter(TEST_COMPARE_DIR +
"/reload/macros.vtl", true);
+ String template = "#foo('hip')";
+ assertEvalEquals("hop_hip", template);
+
+ FileWriter writer = new FileWriter(TEST_COMPARE_DIR +
"/reload/macros2.vtl", true);
writer.write("\n#macro(bar $txt)hep_$txt#{end}");
writer.close();
-
- String template = "#foo('hip') #bar('hip')";
- String result = "hip_hip hep_hip";
- assertEvalEquals(result, template);
+ // last modified timestamps resolution is one second before Java
8,
+ // so force reloading by setting a file date in the future
+ File macros2 = new File(TEST_COMPARE_DIR + "/reload/macros2.vtl");
+ macros2.setLastModified(macros2.lastModified() + 1000);
+
+ template = "#foo('hip') #bar('hip')";
+ assertEvalEquals("hop_hip hep_hip", template);
}
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org