1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.nuiton.jrst.bugs;
24
25 import org.apache.commons.io.FileUtils;
26 import org.junit.Ignore;
27 import org.junit.Test;
28 import org.nuiton.jrst.JRST;
29 import org.nuiton.jrst.JRSTAbstractTest;
30
31 import java.io.File;
32 import java.util.regex.Matcher;
33 import java.util.regex.Pattern;
34
35
36
37
38
39
40
41
42
43
44 public class TextTest extends JRSTAbstractTest {
45
46
47
48
49
50
51 @Test
52 public void testLinksParameters() throws Exception {
53 File in = getBugTestFile("testLinks.rst");
54 File out = getOutputTestFile("jrst-testLinks.html");
55
56 new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
57
58 @Override
59 public void assertJRST(File in, File out) throws Exception {
60 String content = FileUtils.readFileToString(out, JRST.UTF_8);
61 assertTrue(content.indexOf("href=\"http://labs.libre-entreprise.org/tracker/?atid=113&group_id=8&func=browse\"") > 0);
62 assertTrue(content.indexOf("href=\"http://www.docbook.org/\"") > 0);
63 assertTrue(content.indexOf("href=\"http://www.docbook2.org/\"") > 0);
64 }
65 };
66 }
67
68
69
70
71
72
73
74 @Test
75 public void testLinksSpecialCharacters() throws Exception {
76 File in = getBugTestFile("testLinks1380.rst");
77 File out = getOutputTestFile("jrst-testLinks.html");
78
79 new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
80
81 @Override
82 public void assertJRST(File in, File out) throws Exception {
83 String content = FileUtils.readFileToString(out, JRST.UTF_8);
84 assertTrue(content.indexOf("nuiton's forge") > 0);
85 assertTrue(content.indexOf("build.xml") > 0);
86 }
87 };
88 }
89
90
91
92
93
94
95
96 @Test
97 public void testTabCharacter() throws Exception {
98 File in = getBugTestFile("testTab1378.rst");
99 File out = getOutputTestFile("jrst-testTab1378.html");
100
101 new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
102
103 @Override
104 public void assertJRST(File in, File out) throws Exception {
105 String content = FileUtils.readFileToString(out, JRST.UTF_8);
106 Pattern pattern = Pattern.compile(".*<blockquote>.*du bla bla \u00E9l\u00E9mentaire.*</blockquote>.*", Pattern.DOTALL);
107 Matcher matcher = pattern.matcher(content);
108 assertTrue(matcher.find());
109 }
110 };
111 }
112
113
114
115
116
117 @Test
118 public void testOptionLists() throws Exception {
119 File in = getBugTestFile("testOptionsList644.rst");
120 File out = getOutputTestFile("jrst-testOptionList644.html");
121
122 new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
123
124 @Override
125 public void assertJRST(File in, File out) throws Exception {
126 String content = FileUtils.readFileToString(out, JRST.UTF_8);
127 assertTrue(content.indexOf("<span class=\"option\">-a</span>") > 0);
128 assertTrue(content.indexOf("<p>options can have arguments\nand long descriptions</p>") > 0
129 ||content.indexOf("<p>options can have arguments and long descriptions</p>") > 0);
130 assertTrue(content.indexOf("<v3region.zip|v2region.xml|v2region.xml.gz>") > 0);
131 assertTrue(content.indexOf("<span class=\"option\">/V</span>") > 0);
132 assertTrue(content.indexOf("<p>DOS/VMS-style options too</p>") > 0);
133 }
134 };
135 }
136
137
138
139
140
141
142
143
144 @Test
145 @Ignore
146 public void testLinkEscape() throws Exception {
147 File in = getBugTestFile("testLinks.rst");
148 File out = getOutputTestFile("jrst-testLinks.html");
149
150 new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
151
152 @Override
153 public void assertJRST(File in, File out) throws Exception {
154 String content = FileUtils.readFileToString(out, JRST.UTF_8);
155 assertTrue(content.indexOf("echapement de lien1_") > 0);
156 assertTrue(content.indexOf("echapement de *.txt") > 0);
157 }
158 };
159 }
160
161
162
163
164
165
166 @Test
167 public void testEmbededURIs() throws Exception {
168 File in = getBugTestFile("testEmbeddedURIs.rst");
169 File out = getOutputTestFile("jrst-testEmbeddedURIs.html");
170
171 new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
172
173 @Override
174 public void assertJRST(File in, File out) throws Exception {
175 String content = FileUtils.readFileToString(out, JRST.UTF_8);
176 assertTrue(content.contains("href=\"http://www.python.org\""));
177 assertTrue(content.contains("href=\"./python\""));
178 assertTrue(content.contains("href=\"http://www.rfc-editor.org/rfc/rfc2396.txt\""));
179 assertTrue(content.contains("href=\"http://www.rfc-editor.org/rfc/rfc2732.txt\""));
180 }
181 };
182 }
183
184 }