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 |
|
@version |
35 |
|
@since |
36 |
|
|
37 |
|
@RunWith(Parameterized.class) |
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
38 |
|
public class WhiteSpaceContentAltererTest extends AbstractComponentTestCase |
39 |
|
{ |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
private String initial; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
private String altered; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
private ContentAlterer alterer; |
54 |
|
|
55 |
|
|
56 |
|
@param |
57 |
|
@param |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
59 |
5 |
public WhiteSpaceContentAltererTest(String initial, String altered)... |
60 |
|
{ |
61 |
5 |
this.initial = initial; |
62 |
5 |
this.altered = altered; |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
65 |
5 |
@Override... |
66 |
|
public void setUp() throws Exception |
67 |
|
{ |
68 |
5 |
super.setUp(); |
69 |
5 |
alterer = getComponentManager().getInstance(ContentAlterer.class, "whitespace"); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
@return |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
75 |
1 |
@Parameters... |
76 |
|
public static Collection<String[]> data() |
77 |
|
{ |
78 |
1 |
Collection<String[]> params = new ArrayList<String[]>(); |
79 |
|
|
80 |
1 |
params.add(new String[] {"not\u00A0to be", "nottobe"}); |
81 |
|
|
82 |
1 |
params.add(new String[] {"to be or not\tto be", "tobeornottobe"}); |
83 |
|
|
84 |
1 |
params.add(new String[] {"roses, see I in her cheeks;", "roses,seeIinhercheeks;"}); |
85 |
|
|
86 |
1 |
params.add(new String[] {"eyes nothing\nlike the sun", "eyesnothinglikethesun"}); |
87 |
|
|
88 |
1 |
params.add(new String[] {"eyes\n\rnothing", "eyesnothing"}); |
89 |
1 |
return params; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
95 |
5 |
@Test... |
96 |
|
public void testFiltering() |
97 |
|
{ |
98 |
5 |
AlteredContent alteredContent = alterer.alter(initial); |
99 |
5 |
assertEquals(altered, alteredContent.getContent().toString()); |
100 |
|
} |
101 |
|
} |