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

File GWikiParserTest.java

 

Code metrics

0
51
11
1
190
120
11
0.22
4.64
11
1

Classes

Class Line # Actions
GWikiParserTest 30 51 0% 11 0
1.0100%
 

Contributing tests

This file is covered by 9 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.gwiki.GWikiParser;
25   
26    /**
27    * @version $Id: a2ee498438a38e52b5c3ca723f5c2005647c2dcb $
28    * @since 4.0M1
29    */
 
30    public class GWikiParserTest extends AbstractWikiParserTest
31    {
32    /**
33    * @param name
34    */
 
35  9 toggle public GWikiParserTest(String name)
36    {
37  9 super(name);
38    }
39   
 
40  49 toggle @Override
41    protected IWikiParser newWikiParser()
42    {
43  49 return new GWikiParser();
44    }
45   
46    /**
47    * @throws WikiParserException
48    */
 
49  1 toggle public void testFormats() throws WikiParserException
50    {
51  1 test("*bold*");
52  1 test("~~strike~~");
53  1 test("_italic_");
54  1 test("^superscript^");
55  1 test(",,subscript,,");
56   
57  1 test("normal*bold_bold-italic*italic_normal");
58   
59  1 test("*bold");
60  1 test("~~strike");
61  1 test("_italic");
62  1 test("^superscript");
63  1 test(",,subscript");
64   
65  1 test("bold*");
66  1 test("strike~~");
67  1 test("italic_");
68  1 test("superscript^");
69  1 test("subscript,,");
70    }
71   
72    /**
73    * @throws WikiParserException
74    */
 
75  1 toggle public void testHeaders() throws WikiParserException
76    {
77  1 test("===Header===");
78  1 test("\n===Header===\n * list item");
79  1 test("before\n=== Header ===\nafter");
80  1 test("before\n=== Header \nafter");
81  1 test("This is not a header: ===");
82    }
83   
84    /**
85    * @throws WikiParserException
86    */
 
87  1 toggle public void testLists() throws WikiParserException
88    {
89  1 test(" * item one\n"
90    + " * item two\n"
91    + " # item three\n"
92    + " # item four\n"
93    + " * item five - first line\n"
94    + " item five - second line\n"
95    + " * item six\n"
96    + " is on multiple\n"
97    + " lines");
98    }
99   
100    /**
101    * @throws WikiParserException
102    */
 
103  1 toggle public void testParagraphs() throws WikiParserException
104    {
105  1 test("First paragraph.\n"
106    + "Second line of the same paragraph.\n"
107    + "\n"
108    + "The second paragraph");
109    }
110   
111    /**
112    * @throws WikiParserException
113    */
 
114  1 toggle public void testProperties() throws WikiParserException
115    {
116  1 test(
117    "#toto hello world\n123",
118    "<div class='wikimodel-property' url='toto'><p>hello world</p>\n</div>\n<p>123</p>");
119  1 test(
120    "#prop1 value1\n#prop2 value2",
121    ""
122    + "<div class='wikimodel-property' url='prop1'><p>value1</p>\n</div>\n"
123    + "<div class='wikimodel-property' url='prop2'><p>value2</p>\n</div>");
124  1 test(
125    "#prop1 value1\nparagraph\n#prop2 value2",
126    ""
127    + "<div class='wikimodel-property' url='prop1'><p>value1</p>\n</div>\n"
128    + "<p>paragraph</p>\n"
129    + "<div class='wikimodel-property' url='prop2'><p>value2</p>\n</div>");
130    }
131   
132    /**
133    * @throws WikiParserException
134    */
 
135  1 toggle public void testQuot() throws WikiParserException
136    {
137  1 test("This is a paragraph\n"
138    + "\n"
139    + " and this is a quotations\n"
140    + " the second line");
141  1 test(" First\n" + " Second\n" + " Third");
142  1 test(" \n\n"
143    + " First\n"
144    + " Second\n"
145    + " Third");
146    }
147   
148    /**
149    * @throws WikiParserException
150    */
 
151  1 toggle public void testReferences() throws WikiParserException
152    {
153  1 test("before http://www.foo.bar/com after");
154  1 test("before [toto] after");
155    }
156   
157    /**
158    * @throws WikiParserException
159    */
 
160  1 toggle public void testTables() throws WikiParserException
161    {
162  1 test("|| cell1.1 || cell1.2\n" + "|| cell 2.1 || cell 2.2");
163  1 test("abc || cde");
164  1 test("||a\nb\nc || c\nd\ne\n{{{\n Hello\n * World}}} \n x ");
165    }
166   
167    /**
168    * @throws WikiParserException
169    */
 
170  1 toggle public void testVerbatimBlocks() throws WikiParserException
171    {
172  1 test("{{{verbatim}}}");
173  1 test("{{{verbatim");
174  1 test("{{{{{{verbatim");
175  1 test("{{{{{{verbatim}}}");
176  1 test("{{{{{{verbatim}}}}}}");
177  1 test("{{{before{{{verbatim}}}after}}}");
178  1 test("{{{before{{{123{{{verbatim}}}456}}}after}}}");
179  1 test("{{{verbatim}}}}}} - the three last symbols should be in a paragraph");
180   
181  1 test("before{{{verbatim}}}after");
182   
183  1 test("abc \n{{{ 123\n CDE\n 345 }}} efg");
184  1 test("abc {{{ 123\n CDE\n 345 }}} efg");
185  1 test("abc\n{{{before{{{ inside }}}after}}} efg");
186  1 test("`verbatim`");
187  1 test("before`verbatim`after");
188  1 test("`just like this...");
189    }
190    }