1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.officeimporter.document; |
21 |
|
|
22 |
|
import java.io.StringReader; |
23 |
|
import java.util.HashMap; |
24 |
|
|
25 |
|
import org.junit.Assert; |
26 |
|
|
27 |
|
import org.junit.Test; |
28 |
|
import org.xwiki.officeimporter.internal.AbstractOfficeImporterTest; |
29 |
|
import org.xwiki.rendering.block.XDOM; |
30 |
|
import org.xwiki.rendering.parser.Parser; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 2 |
Complexity Density: 0.12 |
|
38 |
|
public class XDOMOfficeDocumentTest extends AbstractOfficeImporterTest |
39 |
|
{ |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@throws |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
45 |
1 |
@Test... |
46 |
|
public void testTitleExtraction() throws Exception |
47 |
|
{ |
48 |
1 |
String content = "content before title\n" + "%s Title %s\n" + "content after title."; |
49 |
1 |
XDOMOfficeDocument doc = createOfficeDocument(String.format(content, "=", "="), "xwiki/2.0"); |
50 |
1 |
Assert.assertEquals("Title", doc.getTitle()); |
51 |
|
|
52 |
1 |
doc = createOfficeDocument(String.format(content, "==", "=="), "xwiki/2.0"); |
53 |
1 |
Assert.assertEquals("Title", doc.getTitle()); |
54 |
|
|
55 |
1 |
doc = createOfficeDocument(String.format(content, "===", "==="), "xwiki/2.0"); |
56 |
1 |
Assert.assertEquals("Title", doc.getTitle()); |
57 |
|
|
58 |
1 |
doc = createOfficeDocument(String.format(content, "====", "===="), "xwiki/2.0"); |
59 |
1 |
Assert.assertEquals("Title", doc.getTitle()); |
60 |
|
|
61 |
1 |
doc = createOfficeDocument(String.format(content, "=====", "====="), "xwiki/2.0"); |
62 |
1 |
Assert.assertEquals("Title", doc.getTitle()); |
63 |
|
|
64 |
1 |
doc = createOfficeDocument(String.format(content, "======", "======"), "xwiki/2.0"); |
65 |
1 |
Assert.assertEquals("Title", doc.getTitle()); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
@link |
70 |
|
|
71 |
|
@param |
72 |
|
@param |
73 |
|
@return@link |
74 |
|
@throws |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
76 |
6 |
private XDOMOfficeDocument createOfficeDocument(String content, String syntax) throws Exception... |
77 |
|
{ |
78 |
6 |
Parser parser = getComponentManager().getInstance(Parser.class, syntax); |
79 |
6 |
XDOM xdom = parser.parse(new StringReader(content)); |
80 |
6 |
return new XDOMOfficeDocument(xdom, new HashMap<String, byte[]>(), getComponentManager()); |
81 |
|
} |
82 |
|
} |