| 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.confluence.ConfluenceWikiParser; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
@version |
| 28 |
|
@since |
| 29 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (195) |
Complexity: 21 |
Complexity Density: 0.12 |
|
| 30 |
|
public class ConfluenceWikiParserTest extends AbstractWikiParserTest |
| 31 |
|
{ |
| 32 |
|
|
| 33 |
|
@param |
| 34 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
18 |
public ConfluenceWikiParserTest(String name)... |
| 36 |
|
{ |
| 37 |
18 |
super(name); |
| 38 |
|
} |
| 39 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
274 |
@Override... |
| 41 |
|
protected IWikiParser newWikiParser() |
| 42 |
|
{ |
| 43 |
274 |
return new ConfluenceWikiParser(); |
| 44 |
|
} |
| 45 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 46 |
1 |
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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 53 |
1 |
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 |
|
|
| 65 |
|
|
| 66 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 67 |
1 |
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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 76 |
1 |
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 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 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 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
@throws |
| 121 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 122 |
1 |
public void testEscape() throws WikiParserException... |
| 123 |
|
{ |
| 124 |
|
|
| 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 |
| 133 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 134 |
1 |
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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 163 |
1 |
test("abc - cde", "<p>abc - cde</p>"); |
| 164 |
|
|
| 165 |
|
|
| 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 |
|
|
| 171 |
1 |
test("abc + cde", "<p>abc + cde</p>"); |
| 172 |
|
|
| 173 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 193 |
1 |
test( |
| 194 |
|
"http://www.foo.bar", |
| 195 |
|
"<p>http://www.foo.bar</p>"); |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
|
| 199 |
|
@throws |
| 200 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 201 |
1 |
public void testHeaders() throws WikiParserException... |
| 202 |
|
{ |
| 203 |
|
|
| 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 |
|
|
| 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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 228 |
1 |
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 |
| 249 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 250 |
1 |
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 |
| 261 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
| 262 |
1 |
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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 368 |
1 |
public void testMacro() throws WikiParserException... |
| 369 |
|
{ |
| 370 |
1 |
testMacro( |
| 371 |
|
|
| 372 |
|
"section", |
| 373 |
|
"column", |
| 374 |
|
"csv", |
| 375 |
|
|
| 376 |
|
"table-plus", |
| 377 |
|
"composition-setup", |
| 378 |
|
|
| 379 |
|
"float", |
| 380 |
|
"cloak", |
| 381 |
|
"deck", |
| 382 |
|
"card", |
| 383 |
|
"color", |
| 384 |
|
"show-card", |
| 385 |
|
|
| 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 |
|
|
| 399 |
|
"tm", |
| 400 |
|
|
| 401 |
|
"sm", |
| 402 |
|
|
| 403 |
|
"reg-tm", |
| 404 |
|
|
| 405 |
|
"copyright", |
| 406 |
|
|
| 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 |
|
|
| 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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 473 |
1 |
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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 490 |
1 |
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 |
|
|
| 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 |
| 508 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 509 |
1 |
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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 521 |
1 |
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 |
| 539 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (45) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
| 540 |
1 |
public void testReferences() throws WikiParserException... |
| 541 |
|
{ |
| 542 |
|
|
| 543 |
1 |
test( |
| 544 |
|
"before http://www.foo.bar/com after", |
| 545 |
|
"<p>before http://www.foo.bar/com after</p>"); |
| 546 |
|
|
| 547 |
|
|
| 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 |
|
|
| 556 |
|
|
| 557 |
|
|
| 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 |
|
|
| 669 |
1 |
test( |
| 670 |
|
"before \\[toto] after", |
| 671 |
|
"<p>before <span class='wikimodel-escaped'>[</span>toto] after</p>"); |
| 672 |
|
} |
| 673 |
|
|
| 674 |
|
|
| 675 |
|
@throws |
| 676 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 677 |
1 |
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 |
|
|
| 732 |
1 |
test("abc || cde", "<p>abc || cde</p>"); |
| 733 |
|
|
| 734 |
|
|
| 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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 747 |
1 |
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 |
|
|
| 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 |
| 794 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 795 |
1 |
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 |
|
} |