1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 package org.w3c.tidy;
55
56 import java.io.StringWriter;
57
58 import junit.framework.TestCase;
59
60 import org.apache.commons.logging.Log;
61 import org.apache.commons.logging.LogFactory;
62
63
64 /**
65 * @author Fabrizio Giustina
66 * @version $Revision: 807 $ ($Author: fgiust $)
67 */
68 public class ConfigurationTest extends TestCase
69 {
70
71 /**
72 * logger.
73 */
74 private static Log log = LogFactory.getLog(ConfigurationTest.class);
75
76 /**
77 * Test for -help-config.
78 * @throws Exception any exception thrown during test
79 */
80 public void testPrintConfig() throws Exception
81 {
82 Tidy tidy = new Tidy();
83 Configuration configuration = tidy.getConfiguration();
84 StringWriter writer = new StringWriter();
85 configuration.printConfigOptions(writer, false);
86 String result = writer.toString();
87
88 assertTrue(result.length() > 200);
89 log.debug(result);
90 }
91
92 /**
93 * Test for -show-config.
94 * @throws Exception any exception thrown during test
95 */
96 public void testPrintActualConfig() throws Exception
97 {
98 Tidy tidy = new Tidy();
99 tidy.getConfiguration().tt.defineTag(Dict.TAGTYPE_INLINE, "something");
100 tidy.getConfiguration().tt.defineTag(Dict.TAGTYPE_INLINE, "second");
101 Configuration configuration = tidy.getConfiguration();
102 StringWriter writer = new StringWriter();
103 configuration.printConfigOptions(writer, true);
104 String result = writer.toString();
105
106 assertTrue(result.length() > 200);
107 log.debug(result);
108 }
109
110 /**
111 * Test for configuration getters and setters.
112 * @throws Exception any exception thrown during test
113 */
114 public void testGetSet() throws Exception
115 {
116 Tidy tidy = new Tidy();
117
118 tidy.setAltText("alt");
119 assertEquals("alt", tidy.getAltText());
120
121 tidy.setAsciiChars(false);
122 assertEquals(false, tidy.getAsciiChars());
123
124 tidy.setBreakBeforeBR(true);
125 assertEquals(true, tidy.getBreakBeforeBR());
126
127 tidy.setBurstSlides(true);
128 assertEquals(true, tidy.getBurstSlides());
129
130 tidy.setDropEmptyParas(false);
131 assertEquals(false, tidy.getDropEmptyParas());
132
133 tidy.setDropFontTags(true);
134 assertEquals(true, tidy.getDropFontTags());
135
136 tidy.setDropProprietaryAttributes(true);
137 assertEquals(true, tidy.getDropProprietaryAttributes());
138
139 tidy.setEmacs(true);
140 assertEquals(true, tidy.getEmacs());
141
142 tidy.setEncloseBlockText(true);
143 assertEquals(true, tidy.getEncloseBlockText());
144
145 tidy.setEncloseText(true);
146 assertEquals(true, tidy.getEncloseText());
147
148 tidy.setEscapeCdata(true);
149 assertEquals(true, tidy.getEscapeCdata());
150
151 tidy.setFixBackslash(true);
152 assertEquals(true, tidy.getFixBackslash());
153
154 tidy.setFixComments(true);
155 assertEquals(true, tidy.getFixComments());
156
157 tidy.setFixUri(true);
158 assertEquals(true, tidy.getFixUri());
159
160 tidy.setForceOutput(true);
161 assertEquals(true, tidy.getForceOutput());
162
163 tidy.setHideComments(true);
164 assertEquals(true, tidy.getHideComments());
165
166 tidy.setHideEndTags(true);
167 assertEquals(true, tidy.getHideEndTags());
168
169 tidy.setIndentAttributes(true);
170 assertEquals(true, tidy.getIndentAttributes());
171
172 tidy.setIndentCdata(true);
173 assertEquals(true, tidy.getIndentCdata());
174
175 tidy.setIndentContent(true);
176 assertEquals(true, tidy.getIndentContent());
177
178 tidy.setJoinClasses(true);
179 assertEquals(true, tidy.getJoinClasses());
180
181 tidy.setJoinStyles(true);
182 assertEquals(true, tidy.getJoinStyles());
183
184 tidy.setKeepFileTimes(true);
185 assertEquals(true, tidy.getKeepFileTimes());
186
187 tidy.setLiteralAttribs(true);
188 assertEquals(true, tidy.getLiteralAttribs());
189
190 tidy.setLogicalEmphasis(true);
191 assertEquals(true, tidy.getLogicalEmphasis());
192
193 tidy.setLowerLiterals(true);
194 assertEquals(true, tidy.getLowerLiterals());
195
196 tidy.setMakeBare(true);
197 assertEquals(true, tidy.getMakeBare());
198
199 tidy.setMakeClean(true);
200 assertEquals(true, tidy.getMakeClean());
201
202 tidy.setNumEntities(true);
203 assertEquals(true, tidy.getNumEntities());
204
205 tidy.setOnlyErrors(true);
206 assertEquals(true, tidy.getOnlyErrors());
207
208 tidy.setPrintBodyOnly(true);
209 assertEquals(true, tidy.getPrintBodyOnly());
210
211 tidy.setQuiet(true);
212 assertEquals(true, tidy.getQuiet());
213
214 tidy.setQuoteAmpersand(true);
215 assertEquals(true, tidy.getQuoteAmpersand());
216
217 tidy.setQuoteMarks(true);
218 assertEquals(true, tidy.getQuoteMarks());
219
220 tidy.setQuoteNbsp(true);
221 assertEquals(true, tidy.getQuoteNbsp());
222
223 tidy.setRawOut(true);
224 assertEquals(true, tidy.getRawOut());
225
226 tidy.setReplaceColor(true);
227 assertEquals(true, tidy.getReplaceColor());
228
229 tidy.setShowWarnings(true);
230 assertEquals(true, tidy.getShowWarnings());
231
232 tidy.setSmartIndent(true);
233 assertEquals(true, tidy.getSmartIndent());
234
235 tidy.setTidyMark(true);
236 assertEquals(true, tidy.getTidyMark());
237
238 tidy.setTrimEmptyElements(true);
239 assertEquals(true, tidy.getTrimEmptyElements());
240
241 tidy.setUpperCaseAttrs(true);
242 assertEquals(true, tidy.getUpperCaseAttrs());
243
244 tidy.setUpperCaseTags(true);
245 assertEquals(true, tidy.getUpperCaseTags());
246
247 tidy.setWord2000(true);
248 assertEquals(true, tidy.getWord2000());
249
250 tidy.setWrapAsp(true);
251 assertEquals(true, tidy.getWrapAsp());
252
253 tidy.setWrapAttVals(true);
254 assertEquals(true, tidy.getWrapAttVals());
255
256 tidy.setWrapJste(true);
257 assertEquals(true, tidy.getWrapJste());
258
259 tidy.setWrapPhp(true);
260 assertEquals(true, tidy.getWrapPhp());
261
262 tidy.setWrapScriptlets(true);
263 assertEquals(true, tidy.getWrapScriptlets());
264
265 tidy.setWrapSection(true);
266 assertEquals(true, tidy.getWrapSection());
267
268 tidy.setWraplen(5);
269 assertEquals(5, tidy.getWraplen());
270
271 tidy.setWriteback(true);
272 assertEquals(true, tidy.getWriteback());
273
274 tidy.setXHTML(true);
275 assertEquals(true, tidy.getXHTML());
276
277 tidy.setXmlOut(true);
278 assertEquals(true, tidy.getXmlOut());
279
280 tidy.setXmlPi(true);
281 assertEquals(true, tidy.getXmlPi());
282
283 tidy.setXmlPIs(true);
284 assertEquals(true, tidy.getXmlPIs());
285
286 tidy.setXmlSpace(true);
287 assertEquals(true, tidy.getXmlSpace());
288
289 tidy.setXmlTags(true);
290 assertEquals(true, tidy.getXmlTags());
291
292 tidy.setTabsize(5);
293 assertEquals(5, tidy.getTabsize());
294
295 tidy.setOutputEncoding("UTF8");
296 assertEquals("UTF8", tidy.getOutputEncoding());
297
298 tidy.setInputEncoding("UTF8");
299 assertEquals("UTF8", tidy.getInputEncoding());
300
301 tidy.setRepeatedAttributes(Configuration.KEEP_FIRST);
302 assertEquals(Configuration.KEEP_FIRST, tidy.getRepeatedAttributes());
303
304 tidy.setShowErrors(10);
305 assertEquals(10, tidy.getShowErrors());
306
307 tidy.setDocType("strict");
308 assertEquals("strict", tidy.getDocType());
309
310 tidy.setErrfile("errfile");
311 assertEquals("errfile", tidy.getErrfile());
312
313 tidy.setSpaces(5);
314 assertEquals(5, tidy.getSpaces());
315
316 tidy.setInputStreamName("inputname");
317 assertEquals("inputname", tidy.getInputStreamName());
318
319 }
320 }