1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.configuration.internal; |
21 |
|
|
22 |
|
import org.jmock.Expectations; |
23 |
|
import org.junit.Before; |
24 |
|
import org.junit.Test; |
25 |
|
import org.slf4j.Logger; |
26 |
|
import org.xwiki.component.util.ReflectionUtils; |
27 |
|
import org.xwiki.environment.Environment; |
28 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
36 |
|
public class XWikiPropertiesConfigurationSourceTest extends AbstractComponentTestCase |
37 |
|
{ |
38 |
|
private XWikiPropertiesConfigurationSource source; |
39 |
|
|
40 |
|
private Logger logger; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
42 |
1 |
@Before... |
43 |
|
@Override |
44 |
|
public void setUp() throws Exception |
45 |
|
{ |
46 |
1 |
super.setUp(); |
47 |
|
|
48 |
1 |
final Environment environment = getMockery().mock(Environment.class); |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
1 |
getMockery().checking(new Expectations() {{... |
50 |
1 |
oneOf(environment).getResource("/WEB-INF/xwiki.properties"); |
51 |
1 |
will(returnValue(null)); |
52 |
|
}}); |
53 |
|
|
54 |
|
|
55 |
1 |
this.logger = getMockery().mock(Logger.class); |
56 |
|
|
57 |
1 |
this.source = new XWikiPropertiesConfigurationSource(); |
58 |
1 |
ReflectionUtils.setFieldValue(this.source, "environment", environment); |
59 |
1 |
ReflectionUtils.setFieldValue(this.source, "logger", this.logger); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void testInitializeWhenNoPropertiesFile() throws Exception |
64 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
1 |
getMockery().checking(new Expectations() {{... |
66 |
|
|
67 |
1 |
oneOf(logger).debug("No configuration file [{}] found. Using default configuration values.", |
68 |
|
"/WEB-INF/xwiki.properties"); |
69 |
|
}}); |
70 |
|
|
71 |
1 |
this.source.initialize(); |
72 |
|
|
73 |
|
|
74 |
1 |
this.source.getProperty("key"); |
75 |
|
} |
76 |
|
} |