1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.officeimporter.internal.cleaner

File TableOfficeCleaningTest.java

 

Code metrics

0
5
4
1
73
31
4
0.8
1.25
4
1

Classes

Class Line # Actions
TableOfficeCleaningTest 30 5 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 4 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.officeimporter.internal.cleaner;
21   
22    import org.junit.Test;
23   
24    /**
25    * Test case for cleaning html tables in {@link OfficeHTMLCleaner}.
26    *
27    * @version $Id: 6050f09b991ba9d5e087f709b4daf4f09dc2e59b $
28    * @since 1.8
29    */
 
30    public class TableOfficeCleaningTest extends AbstractHTMLCleaningTest
31    {
32    /**
33    * An isolated paragraph inside a table cell item should be replaced with paragraph's content.
34    */
 
35  1 toggle @Test
36    public void testTableCellItemIsolatedParagraphCleaning()
37    {
38  1 assertCleanHTML("<table><tbody><tr><td><p>Test</p></td></tr></tbody></table>",
39    "<table><tbody><tr><td>Test</td></tr></tbody></table>");
40    }
41   
42    /**
43    * An isolated paragraph inside a table header item should be replaced with paragraph's content.
44    */
 
45  1 toggle @Test
46    public void testTableHeaderItemIsolatedParagraphCleaning()
47    {
48  1 assertCleanHTML("<table><thead><tr><th><p>Test</p></th></tr></thead><tbody><tr><td></td></tr></tbody></table>",
49    "<table><thead><tr><th>Test</th></tr></thead><tbody><tr><td></td></tr></tbody></table>");
50    }
51   
52    /**
53    * Tests that empty cells (e.g. those that contains just a line break) are preserved (i.e. are left unchanged).
54    */
 
55  1 toggle @Test
56    public void testEmptyCellsArePreserved()
57    {
58  1 String html =
59    "<table><thead><tr><th><br /></th><th></th></tr></thead>"
60    + "<tbody><tr><td></td><td><br /></td></tr></tbody></table>";
61  1 assertCleanHTML(html, html);
62    }
63   
64    /**
65    * Empty rows should be removed.
66    */
 
67  1 toggle @Test
68    public void testEmptyRowRemoving()
69    {
70  1 assertCleanHTML("<table><tbody><tr><td>cell</td></tr><tr></tr></tbody></table>",
71    "<table><tbody><tr><td>cell</td></tr></tbody></table>");
72    }
73    }