| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.officeimporter.internal.cleaner; |
| 21 |
|
|
| 22 |
|
import java.io.StringReader; |
| 23 |
|
|
| 24 |
|
import org.junit.Assert; |
| 25 |
|
|
| 26 |
|
import org.w3c.dom.Document; |
| 27 |
|
import org.xwiki.officeimporter.internal.AbstractOfficeImporterTest; |
| 28 |
|
import org.xwiki.xml.html.HTMLCleaner; |
| 29 |
|
import org.xwiki.xml.html.HTMLUtils; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@version |
| 35 |
|
@since |
| 36 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 37 |
|
public abstract class AbstractHTMLCleaningTest extends AbstractOfficeImporterTest |
| 38 |
|
{ |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
protected String header = "<html><head><title>Title</title></head><body>"; |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
protected String footer = "</body></html>"; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
@link |
| 51 |
|
|
| 52 |
|
protected HTMLCleaner officeHTMLCleaner; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@link |
| 56 |
|
|
| 57 |
|
protected HTMLCleaner wysiwygHTMLCleaner; |
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 59 |
19 |
@Override... |
| 60 |
|
public void setUp() throws Exception |
| 61 |
|
{ |
| 62 |
19 |
super.setUp(); |
| 63 |
19 |
this.officeHTMLCleaner = getComponentManager().getInstance(HTMLCleaner.class, "openoffice"); |
| 64 |
19 |
this.wysiwygHTMLCleaner = getComponentManager().getInstance(HTMLCleaner.class, "wysiwyg"); |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@param |
| 71 |
|
@param |
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 73 |
4 |
protected void assertCleanHTML(String dirtyHTML, String expectedCleanHTML)... |
| 74 |
|
{ |
| 75 |
4 |
Document document = officeHTMLCleaner.clean(new StringReader(header + dirtyHTML + footer)); |
| 76 |
4 |
Assert.assertEquals(header + expectedCleanHTML + footer, HTMLUtils.toString(document, true, true).trim()); |
| 77 |
|
} |
| 78 |
|
} |