1 package org.apache.velocity.test;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.Test;
23 import junit.framework.TestSuite;
24
25 import org.apache.velocity.app.Velocity;
26 import org.apache.velocity.runtime.RuntimeConstants;
27 import org.apache.velocity.test.misc.TestLogChute;
28
29
30
31
32
33
34
35
36
37 public class MacroForwardDefineTestCase
38 extends BaseTestCase
39 {
40
41
42
43
44 private final static String FILE_RESOURCE_LOADER_PATH = TEST_COMPARE_DIR + "/macroforwarddefine";
45
46
47
48
49 private static final String RESULTS_DIR = TEST_RESULT_DIR + "/macroforwarddefine";
50
51
52
53
54 private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/macroforwarddefine/compare";
55
56
57
58
59 private TestLogChute logger = new TestLogChute();
60
61
62
63
64 public MacroForwardDefineTestCase(String name)
65 {
66 super(name);
67 }
68
69 public void setUp()
70 throws Exception
71 {
72 assureResultsDirectoryExists(RESULTS_DIR);
73
74
75 Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER,"file");
76 Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH );
77 Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID,"true");
78 Velocity.setProperty(RuntimeConstants.VM_LIBRARY, "macros.vm");
79
80
81 logger = new TestLogChute();
82 Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,logger);
83 Velocity.setProperty("runtime.log.logsystem.test.level", "error");
84
85 Velocity.init();
86 }
87
88 public static Test suite()
89 {
90 return new TestSuite(MacroForwardDefineTestCase.class);
91 }
92
93 public void testLogResult()
94 throws Exception
95 {
96 if ( !isMatch(logger.getLog(), COMPARE_DIR, "velocity.log", "cmp"))
97 {
98 fail("Output incorrect.");
99 }
100 }
101 }