1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.test; |
21 |
|
|
22 |
|
import org.xwiki.rendering.wikimodel.IWikiParser; |
23 |
|
import org.xwiki.rendering.wikimodel.WikiParserException; |
24 |
|
import org.xwiki.rendering.wikimodel.creole.CreoleWikiParser; |
25 |
|
|
26 |
|
|
27 |
|
@version |
28 |
|
@since |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (75) |
Complexity: 12 |
Complexity Density: 0.19 |
|
30 |
|
public class CreoleWikiParserTest extends AbstractWikiParserTest |
31 |
|
{ |
32 |
|
|
33 |
|
@param |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
35 |
10 |
public CreoleWikiParserTest(String name)... |
36 |
|
{ |
37 |
10 |
super(name); |
38 |
|
} |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
40 |
61 |
@Override... |
41 |
|
protected IWikiParser newWikiParser() |
42 |
|
{ |
43 |
61 |
return new CreoleWikiParser(); |
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
|
@throws |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
49 |
1 |
public void testFormats() throws WikiParserException... |
50 |
|
{ |
51 |
1 |
test("**bold**", "<p><strong>bold</strong></p>"); |
52 |
1 |
test("//italic//", "<p><em>italic</em></p>"); |
53 |
1 |
test("before{{{inside}}}after", "<p>before<tt class=\"wikimodel-verbatim\">inside</tt>after</p>"); |
54 |
|
|
55 |
|
|
56 |
1 |
test( |
57 |
|
"normal**bold//bold-italic**italic//normal", |
58 |
|
"<p>normal<strong>bold</strong><strong><em>bold-italic</em></strong><em>italic</em>normal</p>"); |
59 |
|
|
60 |
|
|
61 |
1 |
test("_nothing special_", "<p>_nothing special_</p>"); |
62 |
1 |
test( |
63 |
|
"http://www.foo.bar", |
64 |
|
"<p><a href='http://www.foo.bar' class='wikimodel-freestanding'>http://www.foo.bar</a></p>"); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
@throws |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
70 |
1 |
public void testHeaders() throws WikiParserException... |
71 |
|
{ |
72 |
1 |
test("=Header1=", "<h1>Header1</h1>"); |
73 |
1 |
test("==Header2==", "<h2>Header2</h2>"); |
74 |
1 |
test("===Header3===", "<h3>Header3</h3>"); |
75 |
1 |
test("====Header4====", "<h4>Header4</h4>"); |
76 |
1 |
test("=====Header5====", "<h5>Header5</h5>"); |
77 |
1 |
test("======Header6======", "<h6>Header6</h6>"); |
78 |
1 |
test("=======Header6=======", "<h6>Header6</h6>"); |
79 |
|
|
80 |
1 |
test("\n===Header===\n * list item"); |
81 |
1 |
test("before\n=== Header ===\nafter"); |
82 |
1 |
test("before\n=== Header \nafter"); |
83 |
1 |
test("This is not a header: ==="); |
84 |
1 |
test("== Header**bold** //italic// =="); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
@throws |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
90 |
1 |
public void testLineBreaks() throws WikiParserException... |
91 |
|
{ |
92 |
1 |
test("line\\\\break"); |
93 |
1 |
test("not\\a\\break"); |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
@throws |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
99 |
1 |
public void testLists() throws WikiParserException... |
100 |
|
{ |
101 |
1 |
test("\n**item one**", "<p><strong>item one</strong></p>"); |
102 |
1 |
test("**item one**\n\n**item two**", "" |
103 |
|
+ "<p><strong>item one</strong></p>\n" |
104 |
|
+ "<p><strong>item two</strong></p>"); |
105 |
|
|
106 |
1 |
test(" * item one", "<ul>\n <li>item one</li>\n</ul>"); |
107 |
1 |
test("* item one\n** item two", "" |
108 |
|
+ "<ul>\n" |
109 |
|
+ " <li>item one<ul>\n" |
110 |
|
+ " <li>item two</li>\n" |
111 |
|
+ "</ul>\n" |
112 |
|
+ "</li>\n" |
113 |
|
+ "</ul>"); |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
1 |
test("** item one", "" |
163 |
|
+ "<ul>\n" |
164 |
|
+ " <li><ul>\n" |
165 |
|
+ " <li>item one</li>\n" |
166 |
|
+ "</ul>\n" |
167 |
|
+ "</li>\n" |
168 |
|
+ "</ul>"); |
169 |
1 |
test("*** item one", "" |
170 |
|
+ "<ul>\n" |
171 |
|
+ " <li><ul>\n" |
172 |
|
+ " <li><ul>\n" |
173 |
|
+ " <li>item one</li>\n" |
174 |
|
+ "</ul>\n" |
175 |
|
+ "</li>\n" |
176 |
|
+ "</ul>\n" |
177 |
|
+ "</li>\n" |
178 |
|
+ "</ul>"); |
179 |
1 |
test("*## item one", "" |
180 |
|
+ "<ul>\n" |
181 |
|
+ " <li><ol>\n" |
182 |
|
+ " <li><ol>\n" |
183 |
|
+ " <li>item one</li>\n" |
184 |
|
+ "</ol>\n" |
185 |
|
+ "</li>\n" |
186 |
|
+ "</ol>\n" |
187 |
|
+ "</li>\n" |
188 |
|
+ "</ul>"); |
189 |
1 |
test("*##item one", "" |
190 |
|
+ "<ul>\n" |
191 |
|
+ " <li><ol>\n" |
192 |
|
+ " <li><ol>\n" |
193 |
|
+ " <li>item one</li>\n" |
194 |
|
+ "</ol>\n" |
195 |
|
+ "</li>\n" |
196 |
|
+ "</ol>\n" |
197 |
|
+ "</li>\n" |
198 |
|
+ "</ul>"); |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
1 |
test("**item one", "<p><strong>item one</strong></p>"); |
203 |
1 |
test( |
204 |
|
" **item one", |
205 |
|
"<blockquote>\n<strong>item one</strong>\n</blockquote>"); |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
@throws |
240 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
241 |
1 |
public void testParagraphs() throws WikiParserException... |
242 |
|
{ |
243 |
1 |
test("First paragraph.\n" |
244 |
|
+ "Second line of the same paragraph.\n" |
245 |
|
+ "\n" |
246 |
|
+ "The second paragraph"); |
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
|
@throws |
251 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
252 |
1 |
public void testProperties() throws WikiParserException... |
253 |
|
{ |
254 |
1 |
test("#toto hello world\n123"); |
255 |
1 |
test("#prop1 value1\n#prop2 value2"); |
256 |
|
} |
257 |
|
|
258 |
|
|
259 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
260 |
1 |
public void testQuot() throws WikiParserException... |
261 |
|
{ |
262 |
1 |
test("This is a paragraph\n\n and this is a quotations\n the second line"); |
263 |
|
} |
264 |
|
|
265 |
|
|
266 |
|
@throws |
267 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
268 |
1 |
public void testReferences() throws WikiParserException... |
269 |
|
{ |
270 |
1 |
test( |
271 |
|
"before http://www.foo.bar/com after", |
272 |
|
"<p>before <a href='http://www.foo.bar/com' class='wikimodel-freestanding'>http://www.foo.bar/com</a> after</p>"); |
273 |
1 |
test( |
274 |
|
"before this+is+a+reference:to_here after", |
275 |
|
"<p>before <a href='this+is+a+reference:to_here' class='wikimodel-freestanding'>this+is+a+reference:to_here</a> after</p>"); |
276 |
1 |
test( |
277 |
|
"before [[toto]] after", |
278 |
|
"<p>before <a href='toto' class='wikimodel-freestanding'>toto</a> after</p>"); |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
1 |
test("[[link]]", "<p><a href='link' class='wikimodel-freestanding'>link</a></p>"); |
284 |
1 |
test( |
285 |
|
"[[MyBigPage|Go to my page]]", |
286 |
|
"<p><a href='MyBigPage'>Go to my page</a></p>"); |
287 |
1 |
test( |
288 |
|
"[[http://www.wikicreole.org/]]", |
289 |
|
"<p><a href='http://www.wikicreole.org/' class='wikimodel-freestanding'>http://www.wikicreole.org/</a></p>"); |
290 |
1 |
test( |
291 |
|
"http://www.rawlink.org/, http://www.another.rawlink.org", |
292 |
|
"<p><a href='http://www.rawlink.org/' class='wikimodel-freestanding'>http://www.rawlink.org/</a>, <a href='http://www.another.rawlink.org' class='wikimodel-freestanding'>http://www.another.rawlink.org</a></p>"); |
293 |
1 |
test( |
294 |
|
"[[http://www.wikicreole.org/|Visit the WikiCreole website]]", |
295 |
|
"<p><a href='http://www.wikicreole.org/'>Visit the WikiCreole website</a></p>"); |
296 |
|
|
297 |
|
|
298 |
|
|
299 |
1 |
test("[[Weird Stuff|**Weird** // Stuff//]]"); |
300 |
1 |
test( |
301 |
|
"[[Ohana:WikiFamily]]", |
302 |
|
"<p><a href='Ohana:WikiFamily' class='wikimodel-freestanding'>Ohana:WikiFamily</a></p>"); |
303 |
|
|
304 |
|
|
305 |
1 |
test("before [toto] after", "<p>before [toto] after</p>"); |
306 |
|
|
307 |
1 |
test("before this+is+a+reference:to_here after"); |
308 |
1 |
test("before this+is+not+a+reference: to_here after"); |
309 |
1 |
test("before|foo:bar|after"); |
310 |
1 |
test("before main:wiki after"); |
311 |
1 |
test("before main:**wiki** after"); |
312 |
1 |
test("before http://www.google.com:8080 after"); |
313 |
1 |
test("before http://www.google.com?q=Hello+World!#fragmenté~~ after"); |
314 |
|
|
315 |
1 |
test("Bad reference: http://923.43.23.11:8080/toto "); |
316 |
1 |
test("Bad reference: http:|sdf after"); |
317 |
|
} |
318 |
|
|
319 |
|
|
320 |
|
@throws |
321 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
322 |
1 |
public void testTables() throws WikiParserException... |
323 |
|
{ |
324 |
1 |
test("|= Header 1.1 |= Header 1.2\n" |
325 |
|
+ "| Cell 2.1 | Cell 2.2\n" |
326 |
|
+ "| Cell 3.1 |= Head 3.2", "" |
327 |
|
+ "<table><tbody>\n" |
328 |
|
+ " <tr><th> Header 1.1 </th><th> Header 1.2</th></tr>\n" |
329 |
|
+ " <tr><td> Cell 2.1 </td><td> Cell 2.2</td></tr>\n" |
330 |
|
+ " <tr><td> Cell 3.1 </td><th> Head 3.2</th></tr>\n" |
331 |
|
+ "</tbody></table>"); |
332 |
1 |
test("abc || cde"); |
333 |
|
} |
334 |
|
|
335 |
|
|
336 |
|
@throws |
337 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
338 |
1 |
public void testVerbatimeBlocks() throws WikiParserException... |
339 |
|
{ |
340 |
1 |
test("abc \n{{{ 123\n CDE\n 345 }}} efg"); |
341 |
1 |
test("abc {{{ 123\n CDE\n 345 }}} efg"); |
342 |
1 |
test("abc\n{{{\n{{{\n 123 \n }}}\n}}} efg"); |
343 |
1 |
test("`verbatime`"); |
344 |
1 |
test("`just like this..."); |
345 |
|
} |
346 |
|
} |