View Javadoc
1   /*
2    * #%L
3    * JRst :: Api
4    * %%
5    * Copyright (C) 2011 Codelutin, Chatellier Eric
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 3 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20   * #L%
21   */
22  
23  package org.nuiton.jrst.bugs;
24  
25  import java.io.File;
26  
27  import org.apache.commons.io.FileUtils;
28  import org.junit.Assert;
29  import org.junit.Test;
30  import org.nuiton.jrst.JRST;
31  import org.nuiton.jrst.JRSTAbstractTest;
32  
33  /**
34   * Test concernant les titres en général.
35   *
36   * @author chatellier
37   * @version $Revision$
38   *
39   * Last update : $Date$
40   * By : $Author$
41   */
42  public class TitlesTest extends JRSTAbstractTest {
43  
44      /**
45       * Test que la génération fonctionne meme s'il n'y a pas de titre
46       * de niveau 2.
47       * @throws Exception 
48       */
49      @Test
50      public void testNoSubtitle() throws Exception {
51          File in = new File("src/test/resources/bugs/testNoSubtitle.rst");
52          File out = File.createTempFile("jrst-RstToHtml2", ".html");
53  //        out.deleteOnExit();
54          generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
55      }
56  
57  
58      /**
59       * Test que s'il n'y a pas de content avant la premiere section, la section
60       * est bien parsée comme tel.
61       * 
62       * @throws Exception
63       */
64      @Test
65      public void testNoContentBetweenTitles() throws Exception {
66          File in = new File("src/test/resources/bugs/testNoContentSubtitles.rst");
67          File out = File.createTempFile("jrst-testNoContentSubtitles", ".html");
68  //        out.deleteOnExit();
69          new JRSTTestGenerator(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME) {
70  
71              @Override
72              public void assertJRST(File in, File out) throws Exception {
73                  String content = FileUtils.readFileToString(out, JRST.UTF_8);
74                  Assert.assertTrue(content.indexOf("<h2>Prérequis</h2>") > 0
75                          || content.indexOf("<h2 class=\"title\">Prérequis</h2>") > 0);
76              }
77          };
78      }
79  }