1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.velocity.internal; |
21 |
|
|
22 |
|
import java.util.Properties; |
23 |
|
|
24 |
|
import org.apache.commons.lang3.StringUtils; |
25 |
|
import org.apache.velocity.tools.generic.ListTool; |
26 |
|
import org.junit.Before; |
27 |
|
import org.junit.Rule; |
28 |
|
import org.junit.Test; |
29 |
|
import org.xwiki.configuration.ConfigurationSource; |
30 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
31 |
|
import org.xwiki.velocity.VelocityConfiguration; |
32 |
|
import org.xwiki.velocity.introspection.DeprecatedCheckUberspector; |
33 |
|
import org.xwiki.velocity.introspection.MethodArgumentsUberspector; |
34 |
|
import org.xwiki.velocity.introspection.SecureUberspector; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
import static org.mockito.Mockito.when; |
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.43 |
|
45 |
|
public class DefaultVelocityConfigurationTest |
46 |
|
{ |
47 |
|
@Rule |
48 |
|
public MockitoComponentMockingRule<VelocityConfiguration> mocker = |
49 |
|
new MockitoComponentMockingRule<VelocityConfiguration>(DefaultVelocityConfiguration.class); |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
51 |
2 |
@Before... |
52 |
|
public void configure() throws Exception |
53 |
|
{ |
54 |
2 |
ConfigurationSource source = this.mocker.getInstance(ConfigurationSource.class); |
55 |
2 |
when(source.getProperty("velocity.tools", Properties.class)).thenReturn(new Properties()); |
56 |
2 |
when(source.getProperty("velocity.properties", Properties.class)).thenReturn(new Properties()); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
public void testDefaultToolsPresent() throws Exception |
61 |
|
{ |
62 |
|
|
63 |
1 |
assertEquals(ListTool.class.getName(), this.mocker.getComponentUnderTest().getTools().get("listtool")); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void testDefaultPropertiesPresent() throws Exception |
68 |
|
{ |
69 |
|
|
70 |
1 |
assertEquals( |
71 |
|
StringUtils.join(new String[] { SecureUberspector.class.getName(), |
72 |
|
DeprecatedCheckUberspector.class.getName(), MethodArgumentsUberspector.class.getName() }, ','), |
73 |
|
this.mocker.getComponentUnderTest().getProperties().getProperty("runtime.introspector.uberspect")); |
74 |
|
|
75 |
|
|
76 |
1 |
assertEquals(Boolean.TRUE.toString(), |
77 |
|
this.mocker.getComponentUnderTest().getProperties().getProperty("directive.set.null.allowed")); |
78 |
|
|
79 |
|
|
80 |
1 |
assertEquals(Boolean.TRUE.toString(), this.mocker.getComponentUnderTest().getProperties() |
81 |
|
.getProperty("velocimacro.permissions.allow.inline.local.scope")); |
82 |
|
} |
83 |
|
} |