James Moger
2012-10-01 eb1405f736f2f98e14215774dd53eea9b9a77017
commit | author | age
a125cf 1 /*
JM 2  * Copyright 2011 gitblit.com.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.gitblit.tests;
17
7e8873 18 import static org.junit.Assert.assertEquals;
JM 19 import static org.junit.Assert.assertTrue;
20
a125cf 21 import java.text.ParseException;
JM 22
7e8873 23 import org.junit.Test;
a125cf 24
JM 25 import com.gitblit.utils.MarkdownUtils;
26
7e8873 27 public class MarkdownUtilsTest {
a125cf 28
7e8873 29     @Test
a125cf 30     public void testMarkdown() throws Exception {
cbf595 31         assertEquals("<h1> H1</h1>", MarkdownUtils.transformMarkdown("# H1"));
JM 32         assertEquals("<h2> H2</h2>", MarkdownUtils.transformMarkdown("## H2"));
831469 33         assertEquals("<p><strong>THIS</strong> is a test</p>",
JM 34                 MarkdownUtils.transformMarkdown("**THIS** is a test"));
35         assertEquals("<p>** THIS ** is a test</p>",
36                 MarkdownUtils.transformMarkdown("** THIS ** is a test"));
37         assertEquals("<p>**THIS ** is a test</p>",
38                 MarkdownUtils.transformMarkdown("**THIS ** is a test"));
39         assertEquals("<p>** THIS** is a test</p>",
40                 MarkdownUtils.transformMarkdown("** THIS** is a test"));
7e8873 41
JM 42         assertEquals("<table><tr><td>test</td></tr></table>",
43                 MarkdownUtils.transformMarkdown("<table><tr><td>test</td></tr></table>"));
d4c908 44         assertEquals("<table><tr><td>&lt;test&gt;</td></tr></table>",
JM 45                 MarkdownUtils.transformMarkdown("<table><tr><td>&lt;test&gt;</td></tr></table>"));
46
a125cf 47         try {
JM 48             MarkdownUtils.transformMarkdown((String) null);
49             assertTrue(false);
50         } catch (ParseException p) {
51             assertTrue(p != null);
52         }
53     }
54 }