/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. */
  18. package org.fusesource.scalate.wikitext
  19. import java.io.File
  20. class ConfluenceTest extends AbstractConfluenceTest {
  21. test("parse confluence wiki") {
  22. assertFilter(
  23. """h1. Title
  24. Hello
  25. * one
  26. * two
  27. """,
  28. """<h1 id="Title">Title</h1><p>Hello</p><ul><li><p>one</p></li><li><p>two</p></li></ul>""")
  29. }
  30. if (Pygmentize.isInstalled) {
  31. test("pygmentize macro") {
  32. val source = """
  33. START
  34. {pygmentize:xml}
  35. <ul>
  36. <li>one</li>
  37. <li>two</li>
  38. </ul>
  39. {pygmentize}
  40. END
  41. """
  42. // Since the output result changed from Pygmentize 2.x, there are tests for 1.x and 2.x
  43. if (Pygmentize.majorVersion >= 2) {
  44. assertFilter(
  45. source,
  46. """<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>""")
  47. } else {
  48. assertFilter(
  49. source,
  50. """<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>""")
  51. }
  52. }
  53. } else {
  54. warn("Pygmentize not installed so ignoring the tests")
  55. }
  56. }