1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.imaging; |
35 |
|
|
36 |
|
import static org.mockito.Mockito.*; |
37 |
|
import info.magnolia.audit.AuditLoggingManager; |
38 |
|
import info.magnolia.context.SystemContext; |
39 |
|
import info.magnolia.imaging.operations.load.DefaultImageIOImageDecoder; |
40 |
|
import info.magnolia.imaging.operations.load.ImageDecoder; |
41 |
|
import info.magnolia.module.ModuleManagementException; |
42 |
|
import info.magnolia.module.ModuleManager; |
43 |
|
import info.magnolia.module.ModuleManagerImpl; |
44 |
|
import info.magnolia.module.ModuleRegistry; |
45 |
|
import info.magnolia.module.model.ModuleDefinition; |
46 |
|
import info.magnolia.module.model.reader.ModuleDefinitionReader; |
47 |
|
import info.magnolia.repository.RepositoryManager; |
48 |
|
import info.magnolia.test.ComponentsTestUtil; |
49 |
|
import info.magnolia.test.RepositoryTestCase; |
50 |
|
import info.magnolia.test.mock.MockContext; |
51 |
|
import info.magnolia.test.mock.MockRepositoryManager; |
52 |
|
|
53 |
|
import java.io.IOException; |
54 |
|
import java.io.Reader; |
55 |
|
import java.util.ArrayList; |
56 |
|
import java.util.HashMap; |
57 |
|
import java.util.List; |
58 |
|
import java.util.Map; |
59 |
|
|
60 |
|
import org.junit.After; |
61 |
|
import org.junit.Before; |
62 |
|
|
|
|
| 61.5% |
Uncovered Elements: 10 (26) |
Complexity: 7 |
Complexity Density: 0.37 |
|
63 |
|
public abstract class AbstractRepositoryTestCase extends RepositoryTestCase { |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
65 |
20 |
@Override... |
66 |
|
@Before |
67 |
|
public void setUp() throws Exception { |
68 |
20 |
super.setUp(); |
69 |
20 |
ComponentsTestUtil.setInstance(AuditLoggingManager.class, new AuditLoggingManager()); |
70 |
|
|
71 |
20 |
ComponentsTestUtil.setImplementation(ImageDecoder.class, DefaultImageIOImageDecoder.class); |
72 |
|
|
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
75 |
20 |
@Override... |
76 |
|
@After |
77 |
|
public void tearDown() throws Exception { |
78 |
|
|
79 |
20 |
super.tearDown(); |
80 |
20 |
ComponentsTestUtil.clear(); |
81 |
|
} |
82 |
|
|
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
84 |
20 |
@Override... |
85 |
|
protected void initDefaultImplementations() throws IOException, ModuleManagementException { |
86 |
|
|
87 |
20 |
ComponentsTestUtil.setImplementation(SystemContext.class, MockContext.class); |
88 |
20 |
ComponentsTestUtil.setImplementation(RepositoryManager.class, MockRepositoryManager.class); |
89 |
20 |
ModuleRegistry registry = mock(ModuleRegistry.class); |
90 |
20 |
ComponentsTestUtil.setInstance(ModuleRegistry.class, registry); |
91 |
|
|
92 |
20 |
final ModuleDefinitionReader fakeReader = new ModuleDefinitionReader() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0 |
@Override... |
94 |
|
public ModuleDefinition read(Reader in) throws ModuleManagementException { |
95 |
0 |
return null; |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
98 |
0 |
@Override... |
99 |
|
public Map readAll() throws ModuleManagementException { |
100 |
0 |
Map m = new HashMap(); |
101 |
0 |
m.put("moduleDef", "dummy"); |
102 |
0 |
return m; |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0 |
@Override... |
106 |
|
public ModuleDefinition readFromResource(String resourcePath) throws ModuleManagementException { |
107 |
0 |
return null; |
108 |
|
} |
109 |
|
}; |
110 |
20 |
final ModuleManagerImpl fakeModuleManager = new ModuleManagerImpl(null, fakeReader, null, null, null, null) { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0 |
@Override... |
112 |
|
public List loadDefinitions() throws ModuleManagementException { |
113 |
|
|
114 |
0 |
return new ArrayList(); |
115 |
|
} |
116 |
|
}; |
117 |
20 |
ComponentsTestUtil.setInstance(ModuleManager.class, fakeModuleManager); |
118 |
20 |
super.initDefaultImplementations(); |
119 |
|
} |
120 |
|
} |