1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering; |
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.component.descriptor.DefaultComponentDescriptor; |
27 |
|
import org.xwiki.component.manager.ComponentManager; |
28 |
|
import org.xwiki.model.reference.AttachmentReference; |
29 |
|
import org.xwiki.model.reference.AttachmentReferenceResolver; |
30 |
|
import org.xwiki.model.reference.DocumentReference; |
31 |
|
import org.xwiki.rendering.test.MockWikiModel; |
32 |
|
import org.xwiki.rendering.test.integration.RenderingTestSuite; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@RunWith(RenderingTestSuite.class) |
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
42 |
|
public class IntegrationTests |
43 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
44 |
1 |
@RenderingTestSuite.Initialized... |
45 |
|
public void initialize(ComponentManager componentManager) throws Exception |
46 |
|
{ |
47 |
1 |
Mockery mockery = new JUnit4Mockery(); |
48 |
|
|
49 |
|
|
50 |
1 |
final AttachmentReferenceResolver<String> mockResolver = mockery.mock(AttachmentReferenceResolver.class); |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
1 |
mockery.checking(new Expectations() {{... |
52 |
1 |
allowing(mockResolver).resolve("Space.ExistingPage@my.png"); |
53 |
1 |
will(returnValue( |
54 |
|
new AttachmentReference("my.png", new DocumentReference("wiki", "Space", "ExistingPage")))); |
55 |
|
}}); |
56 |
1 |
DefaultComponentDescriptor<AttachmentReferenceResolver<String>> descriptorARS = |
57 |
|
new DefaultComponentDescriptor<AttachmentReferenceResolver<String>>(); |
58 |
1 |
descriptorARS.setRoleType(AttachmentReferenceResolver.TYPE_STRING); |
59 |
1 |
descriptorARS.setRoleHint("current"); |
60 |
1 |
componentManager.registerComponent(descriptorARS, mockResolver); |
61 |
|
|
62 |
|
|
63 |
1 |
componentManager.registerComponent(MockWikiModel.getComponentDescriptor()); |
64 |
|
} |
65 |
|
} |