diff options
author | Claude Brisson <cbrisson@apache.org> | 2019-05-31 19:48:57 +0000 |
---|---|---|
committer | Claude Brisson <cbrisson@apache.org> | 2019-05-31 19:48:57 +0000 |
commit | 10cee0a411231df18449e6f165596fa60752ef8c (patch) | |
tree | 3f287d6569a7a5b52d4a9018472aa88d85e3c668 /velocity-engine-core/src/test/java/org/apache/velocity | |
parent | 941b7c2f90405de725e96c7ccb49eef5c27885ec (diff) | |
download | apache-velocity-engine-10cee0a411231df18449e6f165596fa60752ef8c.tar.gz |
[engine][VELOCITY-917] Preliminary work for VTL chars config: parametrize code using target chars
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/branches/parser_experiments@1860461 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/test/java/org/apache/velocity')
-rw-r--r-- | velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java b/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java index 44891fec..fc042544 100644 --- a/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java +++ b/velocity-engine-core/src/test/java/org/apache/velocity/test/TextblockTestCase.java @@ -19,8 +19,12 @@ package org.apache.velocity.test; * under the License. */ +import org.apache.velocity.runtime.RuntimeInstance; +import org.apache.velocity.runtime.parser.Parser; import org.apache.velocity.runtime.parser.node.ASTTextblock; +import java.lang.reflect.Field; + /** * This class tests the Textblock directive. */ @@ -28,12 +32,12 @@ public class TextblockTestCase extends BaseTestCase { // these are all here so that the test case adapts instantly // to changes in the textblock start/end sequences - private static final String START = ASTTextblock.START; - private static final String END = ASTTextblock.END; - private static final String PARTIAL_START = START.substring(0, START.length() - 1); - private static final String PARTIAL_END = END.substring(1, END.length()); - private static final String END_OF_START = START.substring(START.length() - 1, START.length()); - private static final String START_OF_END = END.substring(0, 1); + private String START = null; + private String END = null; + private String PARTIAL_START = null; + private String PARTIAL_END = null; + private String END_OF_START = null; + private String START_OF_END = null; public TextblockTestCase(String name) { @@ -41,6 +45,25 @@ public class TextblockTestCase extends BaseTestCase //DEBUG = true; } + @Override + protected void setUp() throws Exception + { + super.setUp(); + + // get a valid parser instance to initialize string constants + Field riField = engine.getClass().getDeclaredField("ri"); + riField.setAccessible(true); + RuntimeInstance ri = (RuntimeInstance)riField.get(engine); + Parser parser = ri.createNewParser(); + ASTTextblock astTextblock = new ASTTextblock(parser, 0); + START = astTextblock.START; + END = astTextblock.END; + PARTIAL_START = START.substring(0, START.length() - 1); + PARTIAL_END = END.substring(1); + END_OF_START = START.substring(START.length() - 1); + START_OF_END = END.substring(0, 1); + } + public String textblock(String s) { return START + s + END; |