1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.wikimodel.test

File ConfluenceWikiParserTest.java

 

Code metrics

0
174
21
1
803
657
21
0.12
8.29
21
1

Classes

Class Line # Actions
ConfluenceWikiParserTest 30 174 0% 21 0
1.0100%
 

Contributing tests

This file is covered by 18 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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.confluence.ConfluenceWikiParser;
25   
26    /**
27    * @version $Id: 043c736cddcdc9dfebb44e8b529ccfa89df69c34 $
28    * @since 4.0M1
29    */
 
30    public class ConfluenceWikiParserTest extends AbstractWikiParserTest
31    {
32    /**
33    * @param name
34    */
 
35  18 toggle public ConfluenceWikiParserTest(String name)
36    {
37  18 super(name);
38    }
39   
 
40  274 toggle @Override
41    protected IWikiParser newWikiParser()
42    {
43  274 return new ConfluenceWikiParser();
44    }
45   
 
46  1 toggle public void testMacroInTextLine() throws WikiParserException
47    {
48  1 test(
49    "this is no format text: {noformat}text no format{noformat}",
50    "<p>this is no format text: <span class='wikimodel-macro' macroName='noformat'><![CDATA[text no format]]></span></p>");
51    }
52   
 
53  1 toggle public void testConfluenceHeadings() throws WikiParserException
54    {
55  1 test("h1. Biggest heading", "<h1>Biggest heading</h1>");
56  1 test("h2. Bigger heading", "<h2>Bigger heading</h2>");
57  1 test("h3. Big Heading", "<h3>Big Heading</h3>");
58  1 test("h4. Normal Heading", "<h4>Normal Heading</h4>");
59  1 test("h5. Small Heading", "<h5>Small Heading</h5>");
60  1 test("h6. Smallest Heading", "<h6>Smallest Heading</h6>");
61    }
62   
63    /**
64    * http://confluence.atlassian.com/renderer/notationhelp.action?section=
65    * breaks
66    */
 
67  1 toggle public void testConfluenceTextBreaks() throws WikiParserException
68    {
69  1 test("first\n\nsecond", "<p>first</p>\n<p>second</p>");
70  1 test("first\\\\second", "<p>first<br />second</p>");
71  1 test("first\n----second", "<p>first</p>\n<hr />\n<p>second</p>");
72  1 test("first --- second", "<p>first --- second</p>");
73  1 test("first -- second", "<p>first -- second</p>");
74    }
75   
 
76  1 toggle public void testConfluenceTextEffects() throws WikiParserException
77    {
78  1 test(
79    "Makes text *strong*.",
80    "<p>Makes text <strong>strong</strong>.</p>");
81  1 test("Makes text _emphasis_.", "<p>Makes text <em>emphasis</em>.</p>");
82  1 test(
83    "Makes text ??citation??.",
84    "<p>Makes text <cite>citation</cite>.</p>");
85  1 test(
86    "Makes text -strikethrough-.",
87    "<p>Makes text <strike>strikethrough</strike>.</p>");
88   
89    // Underlined was replaced by "tt": I consider the underline formatting
90    // harmful - this pure visual tag mocks up a very important logical tag
91    // - "a". So it is not a "bug", it is a "feature".
92    // (mkotelnikov)
93  1 test(
94    "Makes text +underlined+.",
95    "<p>Makes text <ins>underlined</ins>.</p>");
96  1 test(
97    "Makes text ^superscript^.",
98    "<p>Makes text <sup>superscript</sup>.</p>");
99  1 test(
100    "Makes text ~subscript~.",
101    "<p>Makes text <sub>subscript</sub>.</p>");
102  1 test(
103    "Makes text as {{code text}}.",
104    "<p>Makes text as <mono>code text</mono>.</p>");
105  1 test(
106    "bq. Some block quoted text.",
107    "<blockquote>\n Some block quoted text.\n</blockquote>");
108  1 test(
109    "{quote}Some block quoted text.\n{quote}",
110    "<blockquote>\nSome block quoted text.\n</blockquote>");
111   
112    // {color:red}
113    // look ma, red text!
114    // {color} Changes the color of a block of text.
115    //
116    // Example: look ma, red text!
117    }
118   
119    /**
120    * @throws WikiParserException
121    */
 
122  1 toggle public void testEscape() throws WikiParserException
123    {
124    // "a" and "b" symbols are just escaped
125  1 test("not\\a\\break", "<p>not"
126    + "<span class='wikimodel-escaped'>a</span>"
127    + "<span class='wikimodel-escaped'>b</span>"
128    + "reak</p>");
129    }
130   
131    /**
132    * @throws WikiParserException
133    */
 
134  1 toggle public void testFormats() throws WikiParserException
135    {
136  1 test("a-b", "<p>a-b</p>");
137  1 test("-a-", "<p><strike>a</strike></p>");
138   
139    // STRONG
140  1 test("*bold*", "<p><strong>bold</strong></p>");
141  1 test(
142    "*bold* *bold* *bold*",
143    "<p><strong>bold</strong> <strong>bold</strong> <strong>bold</strong></p>");
144    // EM
145  1 test("_italic_", "<p><em>italic</em></p>");
146  1 test(
147    "_italic_ _italic_ _italic_",
148    "<p><em>italic</em> <em>italic</em> <em>italic</em></p>");
149    // CITE
150  1 test("??citation??", "<p><cite>citation</cite></p>");
151  1 test(
152    "??citation?? ??citation?? ??citation??",
153    "<p><cite>citation</cite> <cite>citation</cite> <cite>citation</cite></p>");
154   
155    // STRIKE
156  1 test("-abc-", "<p><strike>abc</strike></p>");
157  1 test(" -abc-", "<p> <strike>abc</strike></p>");
158  1 test("abc -cde- efg", "<p>abc <strike>cde</strike> efg</p>");
159  1 test(
160    "abc -cde- -efg-",
161    "<p>abc <strike>cde</strike> <strike>efg</strike></p>");
162    // not a STRIKE
163  1 test("abc - cde", "<p>abc - cde</p>");
164   
165    // INS
166  1 test("+abc+", "<p><ins>abc</ins></p>");
167  1 test(" +abc+", "<p> <ins>abc</ins></p>");
168  1 test("abc +cde+ efg", "<p>abc <ins>cde</ins> efg</p>");
169  1 test("abc +cde+ +efg+", "<p>abc <ins>cde</ins> <ins>efg</ins></p>");
170    // not a TT
171  1 test("abc + cde", "<p>abc + cde</p>");
172   
173    // SUB
174  1 test("~abc~", "<p><sub>abc</sub></p>");
175  1 test(" ~abc~", "<p> <sub>abc</sub></p>");
176  1 test("abc ~cde~ efg", "<p>abc <sub>cde</sub> efg</p>");
177  1 test("abc ~cde~ ~efg~", "<p>abc <sub>cde</sub> <sub>efg</sub></p>");
178   
179    // SUP
180  1 test("^abc^", "<p><sup>abc</sup></p>");
181  1 test(" ^abc^", "<p> <sup>abc</sup></p>");
182  1 test("abc ^cde^ efg", "<p>abc <sup>cde</sup> efg</p>");
183  1 test("abc ^cde^ ^efg^", "<p>abc <sup>cde</sup> <sup>efg</sup></p>");
184   
185  1 test("before{{{inside}}}after", "<p>before<tt class=\"wikimodel-verbatim\">inside</tt>after</p>");
186   
187    // Mixed styles
188  1 test(
189    "normal*bold_bold-italic*italic_normal",
190    "<p>normal<strong>bold</strong><strong><em>bold-italic</em></strong><em>italic</em>normal</p>");
191   
192    // Not formatting
193  1 test(
194    "http://www.foo.bar",
195    "<p>http://www.foo.bar</p>");
196    }
197   
198    /**
199    * @throws WikiParserException
200    */
 
201  1 toggle public void testHeaders() throws WikiParserException
202    {
203    // Headers without spaces after the header symbol
204  1 test("h1.Header1", "<h1>Header1</h1>");
205  1 test("h2.Header2", "<h2>Header2</h2>");
206  1 test("h3.Header3", "<h3>Header3</h3>");
207  1 test("h4.Header4", "<h4>Header4</h4>");
208  1 test("h5.Header5", "<h5>Header5</h5>");
209  1 test("h6.Header6", "<h6>Header6</h6>");
210  1 test("h7.Not a header", "<p>h7.Not a header</p>");
211    // Headers: ignoring spaces just after the header sign
212  1 test("h1. Header1", "<h1>Header1</h1>");
213  1 test("h2. Header2", "<h2>Header2</h2>");
214  1 test("h3. Header3", "<h3>Header3</h3>");
215  1 test("h4. Header4", "<h4>Header4</h4>");
216  1 test("h5. Header5", "<h5>Header5</h5>");
217  1 test("h6. Header6", "<h6>Header6</h6>");
218  1 test("h7. Not a header", "<p>h7. Not a header</p>");
219   
220  1 test(
221    "\nh1.Header\n* list item",
222    "<h1>Header</h1>\n<ul>\n <li>list item</li>\n</ul>");
223  1 test(
224    "before\nh3. Header \nafter",
225    "<p>before</p>\n<h3>Header </h3>\n<p>after</p>");
226    }
227   
 
228  1 toggle public void testImages() throws WikiParserException
229    {
230  1 test(
231    "before !http://www.host.com/image.gif! after",
232    "<p>before <img src='http://www.host.com/image.gif'/> after</p>");
233  1 test(
234    "!spaceKey:pageTitle^image.gif!",
235    "<p><img src='spaceKey:pageTitle^image.gif'/></p>");
236  1 test(
237    "!/2007/05/23/My Blog Post^image.gif!",
238    "<p><img src='/2007/05/23/My Blog Post^image.gif'/></p>");
239  1 test(
240    "!image.gif|a=b!",
241    "<p><img src='image.gif' a='b' title='image.gif'/></p>");
242  1 test(
243    "!image.gif|a=b,c=d!",
244    "<p><img src='image.gif' a='b' c='d' title='image.gif'/></p>");
245    }
246   
247    /**
248    * @throws WikiParserException
249    */
 
250  1 toggle public void testLineBreaks() throws WikiParserException
251    {
252  1 test("line\\\\break", "<p>line<br />break</p>");
253  1 test("not\\a\\break", "<p>not"
254    + "<span class='wikimodel-escaped'>a</span>"
255    + "<span class='wikimodel-escaped'>b</span>"
256    + "reak</p>");
257    }
258   
259    /**
260    * @throws WikiParserException
261    */
 
262  1 toggle public void testLists() throws WikiParserException
263    {
264  1 test("# Item 1\n"
265    + "## Item 2\n"
266    + "##* Item 3\n"
267    + "## Item 4\n"
268    + "# Item 5\n", ""
269    + "<ol>\n"
270    + " <li>Item 1<ol>\n"
271    + " <li>Item 2<ul>\n"
272    + " <li>Item 3</li>\n"
273    + "</ul>\n"
274    + "</li>\n"
275    + " <li>Item 4</li>\n"
276    + "</ol>\n"
277    + "</li>\n"
278    + " <li>Item 5</li>\n"
279    + "</ol>");
280  1 test("* item one", "<ul>\n <li>item one</li>\n</ul>");
281  1 test("* item one\n** item two", ""
282    + "<ul>\n"
283    + " <li>item one<ul>\n"
284    + " <li>item two</li>\n"
285    + "</ul>\n"
286    + "</li>\n"
287    + "</ul>");
288  1 test("- item one\n-- item two", ""
289    + "<ul>\n"
290    + " <li>item one<ul>\n"
291    + " <li>item two</li>\n"
292    + "</ul>\n"
293    + "</li>\n"
294    + "</ul>");
295  1 test("** item one", ""
296    + "<ul>\n"
297    + " <li><ul>\n"
298    + " <li>item one</li>\n"
299    + "</ul>\n"
300    + "</li>\n"
301    + "</ul>");
302  1 test("*** item one", ""
303    + "<ul>\n"
304    + " <li><ul>\n"
305    + " <li><ul>\n"
306    + " <li>item one</li>\n"
307    + "</ul>\n"
308    + "</li>\n"
309    + "</ul>\n"
310    + "</li>\n"
311    + "</ul>");
312  1 test("*## item one", ""
313    + "<ul>\n"
314    + " <li><ol>\n"
315    + " <li><ol>\n"
316    + " <li>item one</li>\n"
317    + "</ol>\n"
318    + "</li>\n"
319    + "</ol>\n"
320    + "</li>\n"
321    + "</ul>");
322  1 test("*## item one", ""
323    + "<ul>\n"
324    + " <li><ol>\n"
325    + " <li><ol>\n"
326    + " <li>item one</li>\n"
327    + "</ol>\n"
328    + "</li>\n"
329    + "</ol>\n"
330    + "</li>\n"
331    + "</ul>");
332  1 test("# Item 1\n"
333    + "## Item 2\n"
334    + "##* Item 3\n"
335    + "## Item 4\n"
336    + "# Item 5\n"
337    + "* Item 1\n"
338    + "** Item 2\n"
339    + "*** Item 3\n"
340    + "** Item 4\n"
341    + "* Item 5\n"
342    + "* Item 6", ""
343    + "<ol>\n"
344    + " <li>Item 1<ol>\n"
345    + " <li>Item 2<ul>\n"
346    + " <li>Item 3</li>\n"
347    + "</ul>\n"
348    + "</li>\n"
349    + " <li>Item 4</li>\n"
350    + "</ol>\n"
351    + "</li>\n"
352    + " <li>Item 5</li>\n"
353    + "</ol>\n"
354    + "<ul>\n"
355    + " <li>Item 1<ul>\n"
356    + " <li>Item 2<ul>\n"
357    + " <li>Item 3</li>\n"
358    + "</ul>\n"
359    + "</li>\n"
360    + " <li>Item 4</li>\n"
361    + "</ul>\n"
362    + "</li>\n"
363    + " <li>Item 5</li>\n"
364    + " <li>Item 6</li>\n"
365    + "</ul>");
366    }
367   
 
368  1 toggle public void testMacro() throws WikiParserException
369    {
370  1 testMacro(
371    // "quote" // DONE - {quote} quoted block {quote}
372    "section",
373    "column",
374    "csv",
375    // TODO: {table-plus:width=100..} table {table-plus}
376    "table-plus",
377    "composition-setup",
378    // TODO: {float:xx} paragraph {float}
379    "float",
380    "cloak",
381    "deck",
382    "card",
383    "color",
384    "show-card",
385    // TODO: {chart: params} table {charĊ§}
386    "chart",
387    "slideshow",
388    "slide",
389    "note",
390    "warning",
391    "info",
392    "tip",
393    "cache",
394    "sql",
395    "panel",
396    "sub-section",
397    "clickable",
398    // TODO: {tm} inline text {tm}
399    "tm",
400    // TODO: {sm} inline text {sm}
401    "sm",
402    // TODO: {reg-tm} inline text {reg-tm}
403    "reg-tm",
404    // TODO: {copyright} inline text {copyright}
405    "copyright",
406    // TODO: {span} inline text {span}
407    "span",
408    "lozenge",
409    "style",
410    "div",
411    "bgcolor",
412    "center",
413    "strike",
414    "privacy-policy",
415    "roundrect",
416    "align",
417    "iframe",
418    "table",
419    "table-row",
420    "table-cell",
421    "th",
422    "tbody",
423    "thead",
424    "ul",
425    "li",
426    "rollover",
427    "fancy-bullets",
428    "contentformattingtest",
429    "toc-zone",
430    "excerpt",
431    "code",
432    "html");
433   
434  1 test(
435    ""
436    + "{section}\n"
437    + "{column:width=30%}\n"
438    + "Column one text goes here\n"
439    + "{column}\n"
440    + "{column:width=70%}\n"
441    + "Column two text goes here\n"
442    + "{column}\n"
443    + "{section}\n",
444    "<pre class='wikimodel-macro' macroName='section'><![CDATA[\n"
445    + "{column:width=30%}\n"
446    + "Column one text goes here\n"
447    + "{column}\n"
448    + "{column:width=70%}\n"
449    + "Column two text goes here\n"
450    + "{column}\n"
451    + "]]></pre>");
452   
453    // Macro parameters
454  1 test(
455    "{float}x{float}",
456    "<pre class='wikimodel-macro' macroName='float'><![CDATA[x]]></pre>");
457  1 test(
458    "{float:left}align to left{float}",
459    "<pre class='wikimodel-macro' macroName='float' value='left'><![CDATA[align to left]]></pre>");
460  1 test(
461    "{column:width=50%}\n" + "Text in this column.\n" + "{column}",
462    "<pre class='wikimodel-macro' macroName='column' width='50%'><![CDATA[\nText in this column.\n]]></pre>");
463  1 test(
464    "{csv:output=wiki|width=900|border=15|delimiter=whitespace}\n"
465    + "Month Max Min Average\n"
466    + "January 25.5 *6.3* 15.9\n{csv}",
467    "<pre class='wikimodel-macro' macroName='csv' output='wiki' width='900' border='15' delimiter='whitespace'>"
468    + "<![CDATA[\n"
469    + "Month Max Min Average\n"
470    + "January 25.5 *6.3* 15.9\n]]></pre>");
471    }
472   
 
473  1 toggle private void testMacro(String... names) throws WikiParserException
474    {
475  1 for (String name : names) {
476  53 test(
477    "{" + name + "}a{" + name + "}",
478    "<pre class='wikimodel-macro' macroName='"
479    + name
480    + "'><![CDATA[a]]></pre>");
481  53 test("before\n{" + name + "}a{" + name + "}\nafter", ""
482    + "<p>before</p>\n"
483    + "<pre class='wikimodel-macro' macroName='"
484    + name
485    + "'><![CDATA[a]]></pre>\n"
486    + "<p>after</p>");
487    }
488    }
489   
 
490  1 toggle public void testMacroEmpty() throws WikiParserException
491    {
492  1 test(
493    "{code}a{code}b",
494    ""
495    + "<pre class='wikimodel-macro' macroName='code'><![CDATA[a]]></pre>\n"
496    + "<p>b</p>");
497   
498    // Empty macros with parameters
499  1 test(
500    "{code:x=X|y=Y}a{code}b",
501    ""
502    + "<pre class='wikimodel-macro' macroName='code' x='X' y='Y'><![CDATA[a]]></pre>\n"
503    + "<p>b</p>");
504    }
505   
506    /**
507    * @throws WikiParserException
508    */
 
509  1 toggle public void testParagraphs() throws WikiParserException
510    {
511  1 test("First paragraph.\n"
512    + "Second line of the same paragraph.\n"
513    + "\n"
514    + "The second paragraph", "<p>First paragraph.\n"
515    + "Second line of the same paragraph.</p>\n"
516    + "<p>The second paragraph</p>");
517    }
518   
519    /**
520    */
 
521  1 toggle public void testQuot() throws WikiParserException
522    {
523  1 test(
524    "first\nbq.second\n\nthird",
525    "<p>first</p>\n<blockquote>\nsecond\n</blockquote>\n<p>third</p>");
526  1 test(
527    "bq. Some block quoted text.",
528    "<blockquote>\n Some block quoted text.\n</blockquote>");
529  1 test(
530    "first\n{quote}second\n{quote}\nthird",
531    "<p>first</p>\n<blockquote>\nsecond\n</blockquote>\n<p>third</p>");
532  1 test(
533    "{quote}Some block quoted text.\n{quote}",
534    "<blockquote>\nSome block quoted text.\n</blockquote>");
535    }
536   
537    /**
538    * @throws WikiParserException
539    */
 
540  1 toggle public void testReferences() throws WikiParserException
541    {
542    // The Confluence does not support this syntax as a reference.
543  1 test(
544    "before http://www.foo.bar/com after",
545    "<p>before http://www.foo.bar/com after</p>");
546   
547    // The Confluence does not support the uri format: "scheme:hier_path"
548  1 test(
549    "before this+is+a+reference:to_here after",
550    "<p>before this+is+a+reference:to_here after</p>");
551  1 test(
552    "before [toto] after",
553    "<p>before <a href='toto' class='wikimodel-freestanding'>toto</a> after</p>");
554   
555    // Tests from
556    // http://wikicreole.org/wiki/Creole1.0#section-Creole1.0-
557    // LinksInternalExternalAndInterwiki
558  1 test("[link]", "<p><a href='link' class='wikimodel-freestanding'>link</a></p>");
559  1 test(
560    "[Go to my page|MyBigPage]",
561    "<p><a href='MyBigPage'>Go to my page</a></p>");
562  1 test(
563    "[http://www.wikicreole.org/]",
564    "<p><a href='http://www.wikicreole.org/' class='wikimodel-freestanding'>http://www.wikicreole.org/</a></p>");
565  1 test(
566    "http://www.rawlink.org/, http://www.another.rawlink.org",
567    "<p>http://www.rawlink.org/, http://www.another.rawlink.org</p>");
568  1 test(
569    "[ Visit the WikiCreole website | http://www.wikicreole.org/ ]",
570    "<p><a href='http://www.wikicreole.org/'>Visit the WikiCreole website</a></p>");
571  1 test(
572    "[Ohana:WikiFamily]",
573    "<p><a href='Ohana:WikiFamily' class='wikimodel-freestanding'>Ohana:WikiFamily</a></p>");
574   
575  1 test("[#anchor]", "<p><a href='#anchor' class='wikimodel-freestanding'>#anchor</a></p>");
576  1 test(
577    "[^attachment.ext]",
578    "<p><a href='^attachment.ext' class='wikimodel-freestanding'>^attachment.ext</a></p>");
579  1 test("[pagetitle]", "<p><a href='pagetitle' class='wikimodel-freestanding'>pagetitle</a></p>");
580  1 test(
581    "[pagetitle#anchor]",
582    "<p><a href='pagetitle#anchor' class='wikimodel-freestanding'>pagetitle#anchor</a></p>");
583  1 test(
584    "[pagetitle^attachment.ext]",
585    "<p><a href='pagetitle^attachment.ext' class='wikimodel-freestanding'>pagetitle^attachment.ext</a></p>");
586  1 test(
587    "[spacekey:pagetitle]",
588    "<p><a href='spacekey:pagetitle' class='wikimodel-freestanding'>spacekey:pagetitle</a></p>");
589  1 test(
590    "[spacekey:pagetitle#anchor]",
591    "<p><a href='spacekey:pagetitle#anchor' class='wikimodel-freestanding'>spacekey:pagetitle#anchor</a></p>");
592  1 test(
593    "[spacekey:pagetitle^attachment.ext]",
594    "<p><a href='spacekey:pagetitle^attachment.ext' class='wikimodel-freestanding'>spacekey:pagetitle^attachment.ext</a></p>");
595  1 test(
596    "[link alias|#anchor|link tip]",
597    "<p><a href='#anchor' title='link tip'>link alias</a></p>");
598  1 test(
599    "[link alias|^attachment.ext|link tip]",
600    "<p><a href='^attachment.ext' title='link tip'>link alias</a></p>");
601  1 test(
602    "[link alias|pagetitle|link tip]",
603    "<p><a href='pagetitle' title='link tip'>link alias</a></p>");
604  1 test(
605    "[link alias|pagetitle#anchor|link tip]",
606    "<p><a href='pagetitle#anchor' title='link tip'>link alias</a></p>");
607  1 test(
608    "[link alias|pagetitle^attachment.ext|link tip]",
609    "<p><a href='pagetitle^attachment.ext' title='link tip'>link alias</a></p>");
610  1 test(
611    "[link alias|spacekey:pagetitle|link tip]",
612    "<p><a href='spacekey:pagetitle' title='link tip'>link alias</a></p>");
613  1 test(
614    "[link alias|spacekey:pagetitle#anchor|link tip]",
615    "<p><a href='spacekey:pagetitle#anchor' title='link tip'>link alias</a></p>");
616  1 test(
617    "[link alias|spacekey:pagetitle^attachment.ext|link tip]",
618    "<p><a href='spacekey:pagetitle^attachment.ext' title='link tip'>link alias</a></p>");
619  1 test(
620    "[/2004/01/12/My Blog Post]",
621    "<p><a href='/2004/01/12/My Blog Post' class='wikimodel-freestanding'>/2004/01/12/My Blog Post</a></p>");
622  1 test(
623    "[spacekey:/2004/01/12/My Blog Post]",
624    "<p><a href='spacekey:/2004/01/12/My Blog Post' class='wikimodel-freestanding'>spacekey:/2004/01/12/My Blog Post</a></p>");
625  1 test("[/2004/01/12]", "<p><a href='/2004/01/12' class='wikimodel-freestanding'>/2004/01/12</a></p>");
626  1 test(
627    "[spacekey:/2004/01/12]",
628    "<p><a href='spacekey:/2004/01/12' class='wikimodel-freestanding'>spacekey:/2004/01/12</a></p>");
629  1 test(
630    "[my link name|/2004/01/12]",
631    "<p><a href='/2004/01/12'>my link name</a></p>");
632  1 test(
633    "[my link name|spacekey:/2004/01/12]",
634    "<p><a href='spacekey:/2004/01/12'>my link name</a></p>");
635  1 test("[$12345]", "<p><a href='$12345' class='wikimodel-freestanding'>$12345</a></p>");
636  1 test(
637    "[my link name|$12345]",
638    "<p><a href='$12345'>my link name</a></p>");
639  1 test("[spacekey:]", "<p><a href='spacekey:' class='wikimodel-freestanding'>spacekey:</a></p>");
640  1 test(
641    "[custom link title|spacekey:]",
642    "<p><a href='spacekey:'>custom link title</a></p>");
643  1 test("[~username]", "<p><a href='~username' class='wikimodel-freestanding'>~username</a></p>");
644  1 test(
645    "[custom link title|~username]",
646    "<p><a href='~username'>custom link title</a></p>");
647  1 test(
648    "[phrase@shortcut]",
649    "<p><a href='phrase@shortcut' class='wikimodel-freestanding'>phrase@shortcut</a></p>");
650  1 test(
651    "[custom link text|phrase@shortcut]",
652    "<p><a href='phrase@shortcut'>custom link text</a></p>");
653  1 test(
654    "[http://confluence.atlassian.com]",
655    "<p><a href='http://confluence.atlassian.com' class='wikimodel-freestanding'>http://confluence.atlassian.com</a></p>");
656  1 test(
657    "[Atlassian|http://atlassian.com]",
658    "<p><a href='http://atlassian.com'>Atlassian</a></p>");
659  1 test(
660    "[mailto:legendaryservice@atlassian.com]",
661    "<p><a href='mailto:legendaryservice@atlassian.com' class='wikimodel-freestanding'>mailto:legendaryservice@atlassian.com</a></p>");
662  1 test(
663    "[file://c:/temp/foo.txt]",
664    "<p><a href='file://c:/temp/foo.txt' class='wikimodel-freestanding'>file://c:/temp/foo.txt</a></p>");
665  1 test(
666    "[file://z:/file/on/network/share.txt]",
667    "<p><a href='file://z:/file/on/network/share.txt' class='wikimodel-freestanding'>file://z:/file/on/network/share.txt</a></p>");
668    // Not a reference
669  1 test(
670    "before \\[toto] after",
671    "<p>before <span class='wikimodel-escaped'>[</span>toto] after</p>");
672    }
673   
674    /**
675    * @throws WikiParserException
676    */
 
677  1 toggle public void testTable() throws WikiParserException
678    {
679  1 test(
680    "||Header",
681    "<table><tbody>\n <tr><th>Header</th></tr>\n</tbody></table>");
682  1 test(
683    "|Cell",
684    "<table><tbody>\n <tr><td>Cell</td></tr>\n</tbody></table>");
685  1 test(
686    "||Header||\n",
687    "<table><tbody>\n <tr><th>Header</th></tr>\n</tbody></table>");
688  1 test(
689    "|Cell|\n",
690    "<table><tbody>\n <tr><td>Cell</td></tr>\n</tbody></table>");
691  1 test("||Header1||Header2", ""
692    + "<table><tbody>\n"
693    + " <tr><th>Header1</th><th>Header2</th></tr>\n"
694    + "</tbody></table>");
695  1 test("||Header1||Header2||", ""
696    + "<table><tbody>\n"
697    + " <tr><th>Header1</th><th>Header2</th></tr>\n"
698    + "</tbody></table>");
699   
700  1 test("|Cell1|Cell2", ""
701    + "<table><tbody>\n"
702    + " <tr><td>Cell1</td><td>Cell2</td></tr>\n"
703    + "</tbody></table>");
704  1 test("||Header1\n||Header2", ""
705    + "<table><tbody>\n"
706    + " <tr><th>Header1</th></tr>\n"
707    + " <tr><th>Header2</th></tr>\n"
708    + "</tbody></table>");
709  1 test("|Cell1\n|Cell2", ""
710    + "<table><tbody>\n"
711    + " <tr><td>Cell1</td></tr>\n"
712    + " <tr><td>Cell2</td></tr>\n"
713    + "</tbody></table>");
714  1 test("|| Header | Cell", ""
715    + "<table><tbody>\n"
716    + " <tr><th> Header </th><td> Cell</td></tr>\n"
717    + "</tbody></table>");
718   
719  1 test("|| Header 1.1 || Header 1.2\n"
720    + "| Cell 2.1 | Cell 2.2\n"
721    + "| Cell 3.1 || Head 3.2", ""
722    + "<table><tbody>\n"
723    + " <tr><th> Header 1.1 </th><th> Header 1.2</th></tr>\n"
724    + " <tr><td> Cell 2.1 </td><td> Cell 2.2</td></tr>\n"
725    + " <tr><td> Cell 3.1 </td><th> Head 3.2</th></tr>\n"
726    + "</tbody></table>");
727   
728  1 test("||heading 1||heading 2||heading 3||\n"
729    + "|col A1|col A2|col A3|\n"
730    + "|col B1|col B2|col B3| ");
731    // Not a table
732  1 test("abc || cde", "<p>abc || cde</p>");
733   
734    // Check that the table accept only single lines
735  1 test("before\n|cell1|cell2\nafter", ""
736    + "<p>before</p>\n"
737    + "<table><tbody>\n"
738    + " <tr><td>cell1</td><td>cell2\nafter"
739    + "</td></tr>\n"
740    + "</tbody></table>");
741  1 test("|* Item 1|* Item 2",
742    "<table><tbody>\n <tr><td><ul>\n <li>Item 1</li>\n</ul>\n</td><td><ul>\n <li>Item 2</li>\n</ul>\n</td></tr>\n</tbody></table>");
743  1 test("|* Item 1\n|* Item 2",
744    "<table><tbody>\n <tr><td><ul>\n <li>Item 1</li>\n</ul>\n</td></tr>\n <tr><td><ul>\n <li>Item 2</li>\n</ul>\n</td></tr>\n</tbody></table>");
745    }
746   
 
747  1 toggle public void testVerbatimBlock() throws WikiParserException
748    {
749  1 test("{{{xxx}}}", "<pre>xxx</pre>");
750  1 test(
751    "before\n{{{xxx}}}after",
752    "<p>before</p>\n<pre>xxx</pre>\n<p>after</p>");
753  1 test("{{{\n"
754    + "h1. xxx\n"
755    + "* item\n"
756    + "* item\n"
757    + "}}}", ""
758    + "<pre>\n"
759    + "h1. xxx\n"
760    + "* item\n"
761    + "* item\n"
762    + "</pre>");
763  1 test("before\n{{{\n"
764    + "h1. xxx\n"
765    + "* item\n"
766    + "* item\n"
767    + "}}}after", ""
768    + "<p>before</p>\n"
769    + "<pre>\n"
770    + "h1. xxx\n"
771    + "* item\n"
772    + "* item\n"
773    + "</pre>\n"
774    + "<p>after</p>");
775   
776    // Inline verbatim blocks
777  1 test(
778    "before{{{xxx}}}after",
779    "<p>before<tt class=\"wikimodel-verbatim\">xxx</tt>after</p>");
780  1 test("before{{{\n"
781    + "h1. xxx\n"
782    + "* item\n"
783    + "* item\n"
784    + "}}}after", ""
785    + "<p>before<tt class=\"wikimodel-verbatim\">\n"
786    + "h1. xxx\n"
787    + "* item\n"
788    + "* item\n"
789    + "</tt>after</p>");
790    }
791   
792    /**
793    * @throws WikiParserException
794    */
 
795  1 toggle public void testVerbatimeBlocks() throws WikiParserException
796    {
797  1 test("abc \n{{{ 123\n CDE\n 345 }}} efg");
798  1 test("abc {{{ 123\n CDE\n 345 }}} efg");
799  1 test("abc\n{{{\n{{{\n 123 \n }}}\n}}} efg");
800  1 test("`verbatime`");
801  1 test("`just like this...");
802    }
803    }