1 package de.fu_berlin.ties.preprocess;
2
3 import junit.framework.TestCase;
4
5 import java.io.File;
6 import java.io.FileInputStream;
7 import java.io.InputStreamReader;
8 import java.io.Reader;
9 import java.io.StringWriter;
10 import java.io.Writer;
11
12 import de.fu_berlin.ties.ContextMap;
13 import de.fu_berlin.ties.TiesConfiguration;
14 import de.fu_berlin.ties.io.IOUtils;
15 import de.fu_berlin.ties.util.TaskRunner;
16
17
18 /***
19 * Generated by JUnitDoclet, a tool provided by
20 * ObjectFab GmbH under LGPL.
21 * Please see www.junitdoclet.org, www.gnu.org
22 * and www.objectfab.de for informations about
23 * the tool, the licence and the authors.
24 */
25
26
27 public class PreProcessorTest
28
29 extends TestCase
30
31 {
32
33 PreProcessor preprocessor = null;
34
35
36 public PreProcessorTest(String name) {
37
38 super(name);
39
40 }
41
42 public de.fu_berlin.ties.preprocess.PreProcessor createInstance() throws Exception {
43
44
45 return null;
46
47 }
48
49 protected void setUp() throws Exception {
50
51 super.setUp();
52 preprocessor = createInstance();
53
54 }
55
56 protected void tearDown() throws Exception {
57
58 preprocessor = null;
59 super.tearDown();
60
61 }
62
63 public void testCleanHTML() throws Exception {
64
65
66
67
68
69 final String baseDir = "test/samples";
70
71 final String[] baseNames = new String[] {
72 "digitalesRadio",
73 "kugelmensch",
74 "cmu.andrew.academic.bio-242",
75 };
76 final String[] inExtensions = new String[] {
77 "html",
78 "html",
79 "txt",
80 };
81 final String[] lang = new String[] {
82 "de",
83 "de",
84 "en",
85 };
86 Writer writer;
87 Reader outputReader = null;
88 String expectedOutput;
89 PreProcessor processor = null;
90 final ContextMap context = new ContextMap();
91
92 context.put(IOUtils.KEY_LOCAL_CHARSET, IOUtils.STANDARD_HTTP_CHARSET);
93
94 TaskRunner.registerInterest();
95
96 try {
97
98 if (File.separatorChar != '//') {
99 for (int i = 0; i < baseNames.length; i++) {
100 try {
101
102 TiesConfiguration.CONF.setProperty(
103 TiesConfiguration.CONFIG_LANG, lang[i]);
104 processor = new de.fu_berlin.ties.preprocess.PreProcessor(
105 "aug");
106 writer = new StringWriter();
107 processor.process(new File(baseDir, baseNames[i] + '.'
108 + inExtensions[i]), writer, context);
109 outputReader = new InputStreamReader(
110 new FileInputStream(new File(baseDir, baseNames[i]
111 + '.' + "aug")),
112 IOUtils.STANDARD_HTTP_CHARSET);
113 expectedOutput = IOUtils.readToString(outputReader);
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131 assertEquals(expectedOutput.trim(), writer.toString().trim());
132 } finally {
133 IOUtils.tryToClose(outputReader);
134 }
135 }
136 }
137 } finally {
138 TaskRunner.deregisterInterest();
139 }
140
141 }
142
143 public void testToString() throws Exception {
144
145
146 }
147
148
149
150 /***
151 * JUnitDoclet moves marker to this method, if there is not match
152 * for them in the regenerated code and if the marker is not empty.
153 * This way, no test gets lost when regenerating after renaming.
154 * Method testVault is supposed to be empty.
155 */
156 public void testVault() throws Exception {
157
158
159 }
160
161 public static void main(String[] args) {
162
163 junit.textui.TestRunner.run(PreProcessorTest.class);
164
165 }
166 }