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

File JspWikiParserTest.java

 

Code metrics

0
59
14
1
215
128
14
0.24
4.21
14
1

Classes

Class Line # Actions
JspWikiParserTest 30 59 0% 14 0
1.0100%
 

Contributing tests

This file is covered by 12 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.jspwiki.JspWikiParser;
25   
26    /**
27    * @version $Id: 45540244712436a043c3c58296ba99d2884b5650 $
28    * @since 4.0M1
29    */
 
30    public class JspWikiParserTest extends AbstractWikiParserTest
31    {
32    /**
33    * @param name
34    */
 
35  12 toggle public JspWikiParserTest(String name)
36    {
37  12 super(name);
38    }
39   
 
40  57 toggle @Override
41    protected IWikiParser newWikiParser()
42    {
43  57 return new JspWikiParser();
44    }
45   
46    /**
47    * @throws WikiParserException
48    */
 
49  1 toggle public void testEscape() throws WikiParserException
50    {
51  1 test("[a reference]");
52  1 test("[[not a reference]");
53   
54  1 test("~First letter is escaped");
55  1 test("~[not a reference]");
56  1 test("~~escaped tilda");
57  1 test("~ just a tilda because there is an espace after this tilda...");
58   
59  1 test("!Heading\n~!Not a heading\n!Heading again!");
60    }
61   
62    /**
63    * @throws WikiParserException
64    */
 
65  1 toggle public void testFormats() throws WikiParserException
66    {
67  1 test("__bold__");
68  1 test("''italic''");
69  1 test("__bold");
70  1 test("''italic");
71   
72  1 test("not a bold__");
73  1 test("not an italic''");
74    }
75   
76    /**
77    * @throws WikiParserException
78    */
 
79  1 toggle public void testHeaders() throws WikiParserException
80    {
81  1 test("!!!Header");
82  1 test("\n!!!Header\n* list item");
83  1 test("before\n! Header\nafter");
84  1 test("before\n!! Header \nafter");
85  1 test("This is not a header: !!");
86    }
87   
88    /**
89    * @throws WikiParserException
90    */
 
91  1 toggle public void testHorLine() throws WikiParserException
92    {
93  1 test("----");
94  1 test("-------");
95  1 test("-----------");
96  1 test(" -----------");
97  1 test("---abc");
98    }
99   
100    /**
101    * @throws WikiParserException
102    */
 
103  1 toggle public void testLineBreak() throws WikiParserException
104    {
105  1 test("abc\\\\def");
106    }
107   
108    /**
109    * @throws WikiParserException
110    */
 
111  1 toggle public void testLists() throws WikiParserException
112    {
113  1 test("*first");
114  1 test("* first");
115  1 test("** second");
116  1 test("*item one\n"
117    + "* item two\n"
118    + "*#item three\n"
119    + "*# item four\n"
120    + "* item five - first line\n"
121    + " item five - second line\n"
122    + "* item six\n"
123    + " is on multiple\n"
124    + " lines");
125   
126  1 test(";term: definition");
127  1 test(";:just definition");
128  1 test(";just term");
129  1 test(";:");
130   
131  1 test(";term one: definition one\n"
132    + ";term two: definition two\n"
133    + ";term three: definition three");
134   
135  1 test(";One,\ntwo,\nbucle my shoes...:\n"
136    + "...Three\nfour,\nClose the door\n"
137    + ";Five,\nSix: Pick up\n sticks\n\ntam-tam, pam-pam...");
138   
139  1 test(";__term__: ''definition''");
140   
141  1 test("this is not a definition --\n"
142    + " ;__not__ a term: ''not'' a definition\n"
143    + "----toto");
144    }
145   
146    /**
147    * @throws WikiParserException
148    */
 
149  1 toggle public void testParagraphs() throws WikiParserException
150    {
151  1 test("First paragraph.\n"
152    + "Second line of the same paragraph.\n"
153    + "\n"
154    + "The second paragraph");
155   
156  1 test("\n<toto");
157    }
158   
159    /**
160    * @throws ParseException
161    */
 
162  1 toggle public void testQuot() throws WikiParserException
163    {
164  1 test("This is a paragraph\n\n and this is a quotations\n the second line");
165    }
166   
167    /**
168    * @throws WikiParserException
169    */
 
170  1 toggle public void testReferences() throws WikiParserException
171    {
172  1 test("before http://www.foo.bar/com after");
173  1 test("before [toto] after");
174  1 test("before wiki:Hello after");
175  1 test("before wiki~:Hello after");
176  1 test("before [#local ancor] after");
177   
178  1 test("not [[a reference] at all!");
179    }
180   
181    /**
182    * @throws WikiParserException
183    */
 
184  1 toggle public void testSpecialSymbols() throws WikiParserException
185    {
186  1 test(":)");
187    }
188   
189    /**
190    * @throws WikiParserException
191    */
 
192  1 toggle public void testTables() throws WikiParserException
193    {
194  1 test("|| cell 1.1 || cell 1.2\n" + "|| cell 2.1|| cell 2.2");
195  1 test("|| Head 1.1 || Head 1.2\n" + "| cell 2.1| cell 2.2");
196  1 test("|| Multi \nline \nheader \n"
197    + "| Multi\nline\ncell\n\nOne,two,three...");
198  1 test("this is not || a table");
199  1 test("this is not | a table");
200  1 test("|| ''Italic header'' || __Bold header__\n"
201    + "| ''Italic cell'' | __Bold cell__\n");
202    }
203   
204    /**
205    * @throws WikiParserException
206    */
 
207  1 toggle public void testVerbatimeBlocks() throws WikiParserException
208    {
209  1 test("abc \n{{{ 123\n CDE\n 345 }}} efg");
210  1 test("abc {{{ 123\n CDE\n 345 }}} efg");
211  1 test("abc\n{{{\n {{{ 123 \n}\\}} \n}}} efg");
212  1 test("inline{{verbatime}}block");
213  1 test("{{just like this...");
214    }
215    }