1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.macro.formula; |
21 |
|
|
22 |
|
import org.jmock.Expectations; |
23 |
|
import org.jmock.Mockery; |
24 |
|
import org.jmock.integration.junit4.JUnit4Mockery; |
25 |
|
import org.junit.runner.RunWith; |
26 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
27 |
|
import org.xwiki.formula.ImageData; |
28 |
|
import org.xwiki.formula.ImageStorage; |
29 |
|
import org.xwiki.model.reference.AttachmentReference; |
30 |
|
import org.xwiki.model.reference.DocumentReference; |
31 |
|
import org.xwiki.rendering.test.integration.RenderingTestSuite; |
32 |
|
import org.xwiki.test.jmock.MockingComponentManager; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@RunWith(RenderingTestSuite.class) |
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 2 |
Complexity Density: 0.12 |
|
42 |
|
public class IntegrationTests |
43 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
44 |
2 |
@RenderingTestSuite.Initialized... |
45 |
|
public void initialize(MockingComponentManager componentManager) throws Exception |
46 |
|
{ |
47 |
2 |
Mockery mockery = new JUnit4Mockery(); |
48 |
|
|
49 |
|
|
50 |
2 |
final DocumentAccessBridge mockDocumentAccessBridge = |
51 |
|
componentManager.registerMockComponent(mockery, DocumentAccessBridge.class); |
52 |
|
|
53 |
|
|
54 |
2 |
final ImageStorage mockImageStorage = componentManager.registerMockComponent(mockery, ImageStorage.class); |
55 |
|
|
56 |
|
|
57 |
2 |
final FormulaMacroConfiguration mockConfiguration = |
58 |
|
componentManager.registerMockComponent(mockery, FormulaMacroConfiguration.class); |
59 |
|
|
60 |
2 |
mockery.checking(new Expectations() |
61 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
62 |
2 |
{... |
63 |
2 |
atLeast(1).of(mockDocumentAccessBridge).getCurrentDocumentReference(); |
64 |
2 |
DocumentReference documentReference = new DocumentReference("wiki", "space", "page"); |
65 |
2 |
will(returnValue(documentReference)); |
66 |
|
|
67 |
2 |
AttachmentReference attachmentReference = new AttachmentReference( |
68 |
|
"06fbba0acf130efd9e147fdfe91a943cc4f3e29972c6cd1d972e9aabf0900966", documentReference); |
69 |
2 |
atLeast(2).of(mockDocumentAccessBridge).getAttachmentURL(attachmentReference, false); |
70 |
2 |
will(returnValue( |
71 |
|
"/xwiki/bin/view/space/page/06fbba0acf130efd9e147fdfe91a943cc4f3e29972c6cd1d972e9aabf0900966")); |
72 |
|
|
73 |
2 |
atLeast(2).of(mockConfiguration).getRenderer(); |
74 |
2 |
will(returnValue("snuggletex")); |
75 |
|
|
76 |
2 |
atLeast(2).of(mockImageStorage).get(with(any(String.class))); |
77 |
2 |
will(returnValue(null)); |
78 |
|
|
79 |
2 |
atLeast(2).of(mockImageStorage).put(with(any(String.class)), with(any(ImageData.class))); |
80 |
|
} |
81 |
|
}); |
82 |
|
} |
83 |
|
} |