PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/scalate-wikitext/src/test/scala/org/fusesource/scalate/wikitext/ConfluenceTest.scala

http://github.com/scalate/scalate
Scala | 67 lines | 40 code | 9 blank | 18 comment | 4 complexity | 415eaeea6fd65f015aa656eef03cd83a MD5 | raw file
 1/**
 2 * Copyright (C) 2009-2011 the original author or authors.
 3 * See the notice.md file distributed with this work for additional
 4 * information regarding copyright ownership.
 5 *
 6 * Licensed under the Apache License, Version 2.0 (the "License");
 7 * you may not use this file except in compliance with the License.
 8 * You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18package org.fusesource.scalate.wikitext
19
20import java.io.File
21
22class ConfluenceTest extends AbstractConfluenceTest {
23
24  test("parse confluence wiki") {
25    assertFilter(
26      """h1. Title
27Hello
28* one
29* two
30""",
31
32      """<h1 id="Title">Title</h1><p>Hello</p><ul><li><p>one</p></li><li><p>two</p></li></ul>""")
33  }
34
35  if (Pygmentize.isInstalled) {
36    test("pygmentize macro") {
37      val source = """
38START
39
40  {pygmentize:xml}
41  <ul>
42    <li>one</li>
43    <li>two</li>
44  </ul>
45  {pygmentize}
46
47END
48"""
49
50      // Since the output result changed from Pygmentize 2.x, there are tests for 1.x and 2.x
51      if (Pygmentize.majorVersion >= 2) {
52        assertFilter(
53          source,
54          """<p>START</p><div class="syntax"><div class="highlight"><pre><span></span><span class="nt">&lt;ul&gt;</span>&#x000A;  <span class="nt">&lt;li&gt;</span>one<span class="nt">&lt;/li&gt;</span>&#x000A;  <span class="nt">&lt;li&gt;</span>two<span class="nt">&lt;/li&gt;</span>&#x000A;<span class="nt">&lt;/ul&gt;</span>&#x000A;</pre></div>&#x000A;</div><p>END</p>""")
55      } else {
56        assertFilter(
57          source,
58          """<p>START</p><div class="syntax"><div class="highlight"><pre><span class="nt">&lt;ul&gt;</span>&#x000A;  <span class="nt">&lt;li&gt;</span>one<span class="nt">&lt;/li&gt;</span>&#x000A;  <span class="nt">&lt;li&gt;</span>two<span class="nt">&lt;/li&gt;</span>&#x000A;<span class="nt">&lt;/ul&gt;</span>&#x000A;</pre></div>&#x000A;</div><p>END</p>""")
59
60      }
61
62    }
63  } else {
64    warn("Pygmentize not installed so ignoring the tests")
65  }
66
67}