1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.plugin.packaging; |
21 |
|
|
22 |
|
import java.util.Locale; |
23 |
|
|
24 |
|
import org.jmock.Mock; |
25 |
|
import org.xwiki.model.reference.DocumentReference; |
26 |
|
|
27 |
|
import com.xpn.xwiki.XWiki; |
28 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 3 |
Complexity Density: 0.09 |
|
35 |
|
public class PackageTest extends AbstractPackageTest |
36 |
|
{ |
37 |
|
private Package pack; |
38 |
|
|
39 |
|
private Mock mockXWiki; |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
41 |
2 |
@Override... |
42 |
|
protected void setUp() throws Exception |
43 |
|
{ |
44 |
2 |
super.setUp(); |
45 |
2 |
this.pack = new Package(); |
46 |
|
|
47 |
2 |
this.mockXWiki = mock(XWiki.class); |
48 |
2 |
this.mockXWiki.stubs().method("getEncoding").will(returnValue("UTF-8")); |
49 |
2 |
this.mockXWiki.stubs().method("checkAccess").will(returnValue(true)); |
50 |
|
|
51 |
|
|
52 |
2 |
this.mockXWiki.stubs().method("getVersioningStore").will(returnValue(null)); |
53 |
|
|
54 |
2 |
getContext().setWiki((XWiki) this.mockXWiki.proxy()); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
57 |
1 |
public void testImportWithHeterogeneousEncodingInFiles() throws Exception... |
58 |
|
{ |
59 |
1 |
String docTitle = "Un \u00e9t\u00e9 36"; |
60 |
1 |
String docContent = "\u00e0\u00e7\u00e9\u00e8\u00c0\u00c7\u00c9\u00c8\u00ef\u00f6\u00eb\u00fc"; |
61 |
|
|
62 |
1 |
XWikiDocument doc1 = new XWikiDocument(new DocumentReference("Wiki", "Main", "Document1")); |
63 |
1 |
doc1.setTitle(docTitle); |
64 |
1 |
doc1.setContent(docContent); |
65 |
|
|
66 |
1 |
XWikiDocument doc2 = new XWikiDocument(new DocumentReference("Wiki", "Main", "Document2")); |
67 |
1 |
doc2.setTitle(docTitle); |
68 |
1 |
doc2.setContent(docContent); |
69 |
|
|
70 |
1 |
XWikiDocument docs[] = { doc1, doc2 }; |
71 |
|
|
72 |
1 |
this.pack.Import(this.createZipFile(docs, new String[] { "ISO-8859-1", "UTF-8" }, null), getContext()); |
73 |
|
|
74 |
1 |
assertEquals(2, this.pack.getFiles().size()); |
75 |
1 |
assertEquals(this.pack.getFiles().get(0).getDoc().getTitle(), |
76 |
|
(this.pack.getFiles().get(1)).getDoc().getTitle()); |
77 |
1 |
assertEquals(this.pack.getFiles().get(0).getDoc().getContent(), |
78 |
|
this.pack.getFiles().get(1).getDoc().getContent()); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
81 |
1 |
public void testImportWithHeterogeneousEncodingInFilesUsingCommonsCompress() throws Exception... |
82 |
|
{ |
83 |
1 |
String docTitle = "Un \u00e9t\u00e9 36"; |
84 |
1 |
String docContent = "\u00e0\u00e7\u00e9\u00e8\u00c0\u00c7\u00c9\u00c8\u00ef\u00f6\u00eb\u00fc"; |
85 |
|
|
86 |
1 |
XWikiDocument doc1 = new XWikiDocument(new DocumentReference("Wiki", "Main", "Document1")); |
87 |
1 |
doc1.setTitle(docTitle); |
88 |
1 |
doc1.setContent(docContent); |
89 |
|
|
90 |
1 |
XWikiDocument doc2 = new XWikiDocument(new DocumentReference("Wiki", "Main", "Document2")); |
91 |
1 |
doc2.setTitle(docTitle); |
92 |
1 |
doc2.setContent(docContent); |
93 |
|
|
94 |
1 |
XWikiDocument docs[] = { doc1, doc2 }; |
95 |
|
|
96 |
1 |
this.pack.Import(this.createZipFileUsingCommonsCompress(docs, new String[] { "ISO-8859-1", "UTF-8" }, null), |
97 |
|
getContext()); |
98 |
|
|
99 |
1 |
assertEquals(2, this.pack.getFiles().size()); |
100 |
1 |
assertEquals(this.pack.getFiles().get(0).getDoc().getTitle(), |
101 |
|
(this.pack.getFiles().get(1)).getDoc().getTitle()); |
102 |
1 |
assertEquals(this.pack.getFiles().get(0).getDoc().getContent(), |
103 |
|
this.pack.getFiles().get(1).getDoc().getContent()); |
104 |
|
} |
105 |
|
|
106 |
|
} |