1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.annotation.content; |
21 |
|
|
22 |
|
import static org.junit.Assert.assertEquals; |
23 |
|
|
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.Collection; |
26 |
|
|
27 |
|
import org.junit.Test; |
28 |
|
import org.junit.runner.RunWith; |
29 |
|
import org.junit.runners.Parameterized; |
30 |
|
import org.junit.runners.Parameterized.Parameters; |
31 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
32 |
|
|
33 |
|
|
34 |
|
@link |
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
39 |
|
@RunWith(Parameterized.class) |
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 4 |
Complexity Density: 0.17 |
|
40 |
|
public class SpaceNormalizerContentAltererTest extends AbstractComponentTestCase |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
private String initial; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private String altered; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
private ContentAlterer alterer; |
56 |
|
|
57 |
|
|
58 |
|
@param |
59 |
|
@param |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
15 |
public SpaceNormalizerContentAltererTest(String initial, String altered)... |
62 |
|
{ |
63 |
15 |
this.initial = initial; |
64 |
15 |
this.altered = altered; |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
15 |
@Override... |
68 |
|
public void setUp() throws Exception |
69 |
|
{ |
70 |
15 |
super.setUp(); |
71 |
15 |
alterer = getComponentManager().getInstance(ContentAlterer.class, "space-normalizer"); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
@return |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
77 |
1 |
@Parameters... |
78 |
|
public static Collection<String[]> data() |
79 |
|
{ |
80 |
1 |
Collection<String[]> params = new ArrayList<String[]>(); |
81 |
|
|
82 |
1 |
params.add(new String[] {"not\u00A0to be", "not to be"}); |
83 |
|
|
84 |
1 |
params.add(new String[] {"to be or not\tto be", "to be or not to be"}); |
85 |
|
|
86 |
1 |
params.add(new String[] {"roses, see I in her cheeks;", "roses, see I in her cheeks;"}); |
87 |
|
|
88 |
1 |
params.add(new String[] {"eyes nothing\nlike the sun", "eyes nothing like the sun"}); |
89 |
|
|
90 |
1 |
params.add(new String[] {"eyes\n\rnothing", "eyes nothing"}); |
91 |
|
|
92 |
1 |
params.add(new String[] {"roses, see I in her cheeks;", "roses, see I in her cheeks;"}); |
93 |
1 |
params.add(new String[] {"roses, see I\u00A0 in her cheeks;", "roses, see I in her cheeks;"}); |
94 |
1 |
params.add(new String[] {"roses, see I\n \n in her cheeks;", "roses, see I in her cheeks;"}); |
95 |
|
|
96 |
1 |
params.add(new String[] {" roses, see I in her cheeks; ", "roses, see I in her cheeks;"}); |
97 |
1 |
params.add(new String[] {"\n\n\nroses, see I in her cheeks;", "roses, see I in her cheeks;"}); |
98 |
1 |
params.add(new String[] {"roses, see I in her cheeks;\n\n", "roses, see I in her cheeks;"}); |
99 |
|
|
100 |
1 |
params.add(new String[] {"\u00A0roses, see I in her cheeks;", "roses, see I in her cheeks;"}); |
101 |
1 |
params.add(new String[] {"roses, see I in her cheeks;\u00A0", "roses, see I in her cheeks;"}); |
102 |
|
|
103 |
|
|
104 |
1 |
params.add(new String[] {"", ""}); |
105 |
|
|
106 |
1 |
params.add(new String[] {" \t\n", ""}); |
107 |
|
|
108 |
1 |
return params; |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
114 |
15 |
@Test... |
115 |
|
public void testFiltering() |
116 |
|
{ |
117 |
15 |
AlteredContent alteredContent = alterer.alter(initial); |
118 |
15 |
assertEquals(altered, alteredContent.getContent().toString()); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
} |