1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.component.internal.namespace; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
|
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.component.namespace.NamespaceNotAllowedException; |
26 |
|
|
27 |
|
import static org.junit.Assert.assertFalse; |
28 |
|
import static org.junit.Assert.assertTrue; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.3 |
|
35 |
|
public class DefaultNamespaceValidatorTest |
36 |
|
{ |
37 |
|
private DefaultNamespaceValidator validator = new DefaultNamespaceValidator(); |
38 |
|
|
39 |
|
|
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
41 |
1 |
@Test... |
42 |
|
public void isAllowed() |
43 |
|
{ |
44 |
1 |
assertTrue(this.validator.isAllowed(Arrays.asList("namespace"), "namespace")); |
45 |
1 |
assertTrue(this.validator.isAllowed(Arrays.asList("{root}"), null)); |
46 |
1 |
assertTrue(this.validator.isAllowed(Arrays.asList("{}"), null)); |
47 |
1 |
assertTrue(this.validator.isAllowed(Arrays.asList("[.*]"), "namespace")); |
48 |
1 |
assertTrue(this.validator.isAllowed(Arrays.asList("[wiki:(?!xwiki$).*]"), "wiki:test")); |
49 |
|
|
50 |
1 |
assertFalse(this.validator.isAllowed(Arrays.asList("namespace"), "wrong")); |
51 |
1 |
assertFalse(this.validator.isAllowed(Arrays.asList("{root}"), "wrong")); |
52 |
1 |
assertFalse(this.validator.isAllowed(Arrays.asList("[\\d*]"), "namespace")); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void checlAllowed() throws NamespaceNotAllowedException |
57 |
|
{ |
58 |
1 |
this.validator.checkAllowed(Arrays.asList("namespace"), "namespace"); |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
61 |
1 |
@Test(expected = NamespaceNotAllowedException.class)... |
62 |
|
public void checlNoAllowed() throws NamespaceNotAllowedException |
63 |
|
{ |
64 |
1 |
this.validator.checkAllowed(Arrays.asList("namespace"), "wrong"); |
65 |
|
} |
66 |
|
} |