1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.store; |
21 |
|
|
22 |
|
import org.suigeneris.jrcs.rcs.Version; |
23 |
|
import org.xwiki.model.reference.DocumentReference; |
24 |
|
|
25 |
|
import com.xpn.xwiki.XWiki; |
26 |
|
import com.xpn.xwiki.XWikiException; |
27 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
28 |
|
import com.xpn.xwiki.doc.XWikiAttachmentArchive; |
29 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
30 |
|
import com.xpn.xwiki.store.VoidAttachmentVersioningStore.VoidAttachmentArchive; |
31 |
|
import com.xpn.xwiki.test.AbstractBridgedXWikiComponentTestCase; |
32 |
|
|
33 |
|
|
34 |
|
@link@link |
35 |
|
|
36 |
|
@version |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 3 |
Complexity Density: 0.11 |
|
38 |
|
public class VoidAttachmentVersioningStoreTest extends AbstractBridgedXWikiComponentTestCase |
39 |
|
{ |
40 |
|
AttachmentVersioningStore store; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
42 |
2 |
@Override... |
43 |
|
protected void setUp() throws Exception |
44 |
|
{ |
45 |
2 |
super.setUp(); |
46 |
2 |
XWiki xwiki = new XWiki(); |
47 |
2 |
getContext().setWiki(xwiki); |
48 |
|
|
49 |
2 |
this.store = getComponentManager().getInstance(AttachmentVersioningStore.class, "void"); |
50 |
2 |
xwiki.setAttachmentVersioningStore(this.store); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
53 |
1 |
public void testStore() throws XWikiException... |
54 |
|
{ |
55 |
|
|
56 |
1 |
assertEquals(VoidAttachmentVersioningStore.class, this.store.getClass()); |
57 |
|
|
58 |
1 |
XWikiDocument doc = new XWikiDocument(new DocumentReference("Wiki", "Main", "Test")); |
59 |
1 |
XWikiAttachment attachment = new XWikiAttachment(doc, "filename"); |
60 |
1 |
attachment.setContent(new byte[] {1}); |
61 |
1 |
attachment.updateContentArchive(getContext()); |
62 |
|
|
63 |
1 |
this.store.saveArchive(attachment.getAttachment_archive(), this.getContext(), true); |
64 |
1 |
XWikiAttachmentArchive archive = this.store.loadArchive(attachment, this.getContext(), false); |
65 |
1 |
assertEquals(VoidAttachmentArchive.class, archive.getClass()); |
66 |
1 |
assertEquals(VoidAttachmentArchive.class, archive.clone().getClass()); |
67 |
1 |
assertEquals(archive, this.store.loadArchive(attachment, this.getContext(), true)); |
68 |
|
|
69 |
1 |
this.store.deleteArchive(attachment, getContext(), true); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
72 |
1 |
public void testHistory() throws XWikiException... |
73 |
|
{ |
74 |
1 |
XWikiDocument doc = new XWikiDocument(new DocumentReference("Wiki", "Main", "Test")); |
75 |
1 |
XWikiAttachment attachment = new XWikiAttachment(doc, "filename"); |
76 |
|
|
77 |
1 |
attachment.setContent(new byte[] {1}); |
78 |
1 |
attachment.updateContentArchive(this.getContext()); |
79 |
1 |
assertEquals(attachment, attachment.getAttachmentRevision("1.1", this.getContext())); |
80 |
|
|
81 |
1 |
attachment.setContent(new byte[] {2}); |
82 |
1 |
attachment.updateContentArchive(this.getContext()); |
83 |
1 |
assertEquals(attachment, attachment.getAttachmentRevision("1.2", this.getContext())); |
84 |
|
|
85 |
1 |
assertNull(attachment.getAttachmentRevision("1.1", this.getContext())); |
86 |
1 |
assertNull(attachment.getAttachmentRevision("1.3", this.getContext())); |
87 |
1 |
assertEquals(1, attachment.getVersions().length); |
88 |
1 |
assertEquals(new Version(1, 2), attachment.getVersions()[0]); |
89 |
|
} |
90 |
|
} |